From 2250450b88fbf6cdb7345afd36fb44bef82e9592 Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Tue, 6 Dec 2022 12:41:42 +0000 Subject: [PATCH] Don't mutate original Pod's labels because we don't want to, plus annotations may not fit in labels because they have different character limit. Fix for error about 63 character limit Signed-off-by: Dimitris Karakasilis --- controllers/webhooks/pod.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controllers/webhooks/pod.go b/controllers/webhooks/pod.go index 329cb30..68eec00 100644 --- a/controllers/webhooks/pod.go +++ b/controllers/webhooks/pod.go @@ -60,11 +60,16 @@ func (w *Webhook) Mutate(ctx context.Context, request admission.Request, object pod := object.(*corev1.Pod) // Let user use both label and annotations - info := pod.Labels + info := make(map[string]string) // Annotations take precedence - for ann, v := range pod.Annotations { - info[ann] = v + for k, v := range pod.Labels { + info[k] = v + } + + // Annotations take precedence + for k, v := range pod.Annotations { + info[k] = v } entanglementName, exists := info[EntanglementNameLabel]