From 07355a0720f4ebc938f47eede07050e12337889b Mon Sep 17 00:00:00 2001 From: Zach Aller Date: Wed, 24 Jan 2024 15:43:13 -0600 Subject: [PATCH] fix: keep rs inormer updated upon updating labels and annotations (#3321) * fix: keep rs inormer updated upon updating labels and annotations Signed-off-by: Zach Aller * give error some context Signed-off-by: Zach Aller --------- Signed-off-by: Zach Aller --- rollout/ephemeralmetadata.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rollout/ephemeralmetadata.go b/rollout/ephemeralmetadata.go index 92fc5d2670..60b745ed29 100644 --- a/rollout/ephemeralmetadata.go +++ b/rollout/ephemeralmetadata.go @@ -2,6 +2,7 @@ package rollout import ( "context" + "fmt" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -81,9 +82,13 @@ func (c *rolloutContext) syncEphemeralMetadata(ctx context.Context, rs *appsv1.R } // 2. Update ReplicaSet so that any new pods it creates will have the metadata - _, err = c.kubeclientset.AppsV1().ReplicaSets(modifiedRS.Namespace).Update(ctx, modifiedRS, metav1.UpdateOptions{}) + rs, err = c.kubeclientset.AppsV1().ReplicaSets(modifiedRS.Namespace).Update(ctx, modifiedRS, metav1.UpdateOptions{}) if err != nil { - return err + return fmt.Errorf("error updating replicaset in syncEphemeralMetadata: %w", err) + } + err = c.replicaSetInformer.GetIndexer().Update(rs) + if err != nil { + return fmt.Errorf("error updating replicaset informer in syncEphemeralMetadata: %w", err) } c.log.Infof("synced ephemeral metadata %v to ReplicaSet %s", podMetadata, rs.Name) return nil