diff --git a/cmd/plugins/topology-aware/policy/affinity.go b/cmd/plugins/topology-aware/policy/affinity.go index 21c38309d..5cba1eb39 100644 --- a/cmd/plugins/topology-aware/policy/affinity.go +++ b/cmd/plugins/topology-aware/policy/affinity.go @@ -119,16 +119,25 @@ func (p *policy) registerImplicitAffinities() error { }, } - enabled := map[string]cache.ImplicitAffinity{} + var ( + add = map[string]cache.ImplicitAffinity{} + del = []string{} + ) + for _, a := range affinities { - if a.disabled { + name := PolicyName + ":" + a.name + del = append(del, name) + + if !a.disabled { + log.Info("implicit affinity %s is enabled", a.name) + add[name] = a.affinity + } else { log.Info("implicit affinity %s is disabled", a.name) - continue } - enabled[PolicyName+":"+a.name] = a.affinity } - if err := p.cache.AddImplicitAffinities(enabled); err != nil { + p.cache.DeleteImplicitAffinities(del...) + if err := p.cache.AddImplicitAffinities(add); err != nil { return policyError("failed to register implicit affinities: %v", err) } diff --git a/cmd/plugins/topology-aware/policy/topology-aware-policy.go b/cmd/plugins/topology-aware/policy/topology-aware-policy.go index 687ab63f8..97da8328d 100644 --- a/cmd/plugins/topology-aware/policy/topology-aware-policy.go +++ b/cmd/plugins/topology-aware/policy/topology-aware-policy.go @@ -111,7 +111,9 @@ func (p *policy) Setup(opts *policyapi.BackendOptions) error { return policyError("failed to initialize %s policy: %w", PolicyName, err) } - p.registerImplicitAffinities() + if err := p.registerImplicitAffinities(); err != nil { + return policyError("failed to initialize %s policy: %w", PolicyName, err) + } log.Info("***** default CPU priority is %s", defaultPrio) @@ -484,6 +486,10 @@ func (p *policy) Reconfigure(newCfg interface{}) error { return policyError("failed to reconfigure: %v", err) } + if err := p.registerImplicitAffinities(); err != nil { + return policyError("failed to reconfigure: %v", err) + } + for _, grant := range allocations.grants { if err := grant.RefetchNodes(); err != nil { *p = savedPolicy