Skip to content

Commit

Permalink
topology-aware: reconfigure implicit affinities.
Browse files Browse the repository at this point in the history
Fix the handling of implicit affinities corresponding to the
colocate{Pods,Namespaces} configuration settings. Unregister
and reregister disabled and enabled implicit affinities as
necessary when we receive a new configuration.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Nov 5, 2024
1 parent 625d7a1 commit 49792be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/plugins/topology-aware/policy/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,28 @@ func (p *policy) registerImplicitAffinities() error {
},
}

enabled := map[string]cache.ImplicitAffinity{}
var (
enabled = map[string]cache.ImplicitAffinity{}
disabled = []string{}
)
for _, a := range affinities {
if a.disabled {
log.Info("implicit affinity %s is disabled", a.name)
disabled = append(disabled, PolicyName+":"+a.name)
continue
}
log.Info("implicit affinity %s is enabled", a.name)
enabled[PolicyName+":"+a.name] = a.affinity
}

if err := p.cache.AddImplicitAffinities(enabled); err != nil {
return policyError("failed to register implicit affinities: %v", err)
if len(enabled) > 0 {
if err := p.cache.AddImplicitAffinities(enabled); err != nil {
return policyError("failed to register implicit affinities: %v", err)
}
}

if len(disabled) > 0 {
p.cache.DeleteImplicitAffinities(disabled)
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions cmd/plugins/topology-aware/policy/topology-aware-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ func (p *policy) Reconfigure(newCfg interface{}) error {
return policyError("failed to reconfigure: %v", err)
}

p.registerImplicitAffinities()

for _, grant := range allocations.grants {
if err := grant.RefetchNodes(); err != nil {
*p = savedPolicy
Expand Down

0 comments on commit 49792be

Please sign in to comment.