From 5e821ab4b0d721a4f4b2b8b7f681d53ca7ac1d8b Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Fri, 12 Jan 2024 11:16:39 +0200 Subject: [PATCH] agent: fall back to deprecated group labels. Fall back to looking for deprecated group labels if the default or configured one is not found. Signed-off-by: Krisztian Litkey --- pkg/agent/agent.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index f5c8adafe..31c1a396c 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -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) } @@ -607,6 +617,11 @@ var ( defaultGroupLabel string defaultKubeConfig string defaultConfigFile string + + deprecatedGroupLabels = []string{ + "group.config.nri", + "resource-policy.nri.io/group", + } ) func init() {