Skip to content

Commit

Permalink
Don't advertise blocks with pending affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydavenport committed Mar 2, 2018
1 parent 400387f commit ae79ed3
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ function calico_aggr ()
{{range ls "/"}}
{{$parts := split . "-"}}
{{$cidr := join $parts "/"}}
if ( net = {{$cidr}} ) then { accept; }
if ( net ~ {{$cidr}} ) then { reject; }
{{$affinity := json (getv (printf "/%s" .))}}

{{if $affinity.state}}
# Block {{$cidr}} is {{$affinity.state}}
{{if eq $affinity.state "confirmed"}}
if ( net = {{$cidr}} ) then { accept; }
if ( net ~ {{$cidr}} ) then { reject; }
{{end}}
{{ else }}
# Block {{$cidr}} is implicitly confirmed.
if ( net = {{$cidr}} ) then { accept; }
if ( net ~ {{$cidr}} ) then { reject; }
{{ end }}

{{end}}
}

0 comments on commit ae79ed3

Please sign in to comment.