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 438a917 commit b37c170
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cmd/plugins/topology-aware/policy/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

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 b37c170

Please sign in to comment.