Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discovery: Call correct callback when cleaning dynamic #3189

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go/lib/infra/modules/itopo/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"time"

"github.com/scionproto/scion/go/lib/infra/modules/itopo/internal/metrics"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/periodic"
)
Expand All @@ -44,6 +45,8 @@ func (c cleaner) Run(ctx context.Context) {
log.FromCtx(ctx).Info("[itopo.cleaner] Dropping expired dynamic topology",
"ts", st.topo.dynamic.Timestamp, "ttl", st.topo.dynamic.TTL,
"expired", st.topo.dynamic.Expiry())
st.dropDynamic()
st.topo.dynamic = nil
call(st.clbks.CleanDynamic)
metrics.Current.Active().Set(0)
}
}
10 changes: 3 additions & 7 deletions go/lib/infra/modules/itopo/itopo.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,6 @@ func (s *state) updateDynamic(dynamic *topology.Topo) {
metrics.Current.Expiry(cl).Set(metrics.Expiry(dynamic.Expiry()))
}

func (s *state) dropDynamic() {
s.topo.dynamic = nil
call(s.clbks.DropDynamic)
metrics.Current.Active().Set(0)
}

func (s *state) beginSetDynamic(dynamic *topology.Topo) (Transaction, error) {
s.Lock()
defer s.Unlock()
Expand Down Expand Up @@ -329,7 +323,9 @@ func (s *state) beginSetStatic(static *topology.Topo, allowed bool) (Transaction
func (s *state) updateStatic(static *topology.Topo) {
// Drop dynamic topology if necessary.
if s.validator.MustDropDynamic(static, s.topo.static) && s.topo.dynamic != nil {
s.dropDynamic()
s.topo.dynamic = nil
call(s.clbks.DropDynamic)
metrics.Current.Active().Set(0)
}
s.topo.static = static
call(s.clbks.UpdateStatic)
Expand Down