Skip to content

Commit

Permalink
agent: fall back to deprecated group labels.
Browse files Browse the repository at this point in the history
Fall back to looking for deprecated group labels if the default or
configured one is not found.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Jan 15, 2024
1 parent 3c944bb commit 5e821ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ func (a *Agent) Start(notifyFn NotifyFn) error {
}
if e.Type == watch.Added || e.Type == watch.Modified {
group, _ := e.Object.(*corev1.Node).Labels[a.groupLabel]
if group == "" {
for _, l := range deprecatedGroupLabels {
group, _ = e.Object.(*corev1.Node).Labels[l]
if group != "" {
log.Warnf("Using DEPRECATED config group label %q", l)
log.Warnf("Please switch to using label %q instead", a.groupLabel)
break
}
}
}
if err = a.setupGroupConfigWatch(group); err != nil {
log.Errorf("%v", err)
}
Expand Down Expand Up @@ -607,6 +617,11 @@ var (
defaultGroupLabel string
defaultKubeConfig string
defaultConfigFile string

deprecatedGroupLabels = []string{
"group.config.nri",
"resource-policy.nri.io/group",
}
)

func init() {
Expand Down

0 comments on commit 5e821ab

Please sign in to comment.