From 19ed28196f2549a763ec7d3794328565f6d4b127 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Wed, 2 Oct 2024 09:37:01 +0300 Subject: [PATCH] Use metav1.SetMetadataAnnotation instead of secret.Annotations[] to set a value to prevent nil reference (#706) --- CHANGELOG.md | 1 + pkg/reconciliation/reconcile_configsecret.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b993ffc..a17178e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti ## unreleased * [FEATURE] [#651](https://github.com/k8ssandra/cass-operator/issues/651) Add tsreload task for DSE deployments and ability to check if sync operation is available on the mgmt-api side +* [BUGFIX] [#705](https://github.com/k8ssandra/cass-operator/issues/705) Ensure ConfigSecret has annotations map before trying to set a value ## v1.22.4 diff --git a/pkg/reconciliation/reconcile_configsecret.go b/pkg/reconciliation/reconcile_configsecret.go index 038c3b76..8ce3625c 100644 --- a/pkg/reconciliation/reconcile_configsecret.go +++ b/pkg/reconciliation/reconcile_configsecret.go @@ -90,7 +90,7 @@ func (rc *ReconciliationContext) checkDatacenterNameAnnotation(secret *corev1.Se } patch := client.MergeFrom(secret.DeepCopy()) - secret.Annotations[api.DatacenterAnnotation] = rc.Datacenter.Name + metav1.SetMetaDataAnnotation(&secret.ObjectMeta, api.DatacenterAnnotation, rc.Datacenter.Name) return rc.Client.Patch(rc.Ctx, secret, patch) }