From 346a06e92079af60073684ff7969d1707b29dff4 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Tue, 17 Sep 2024 15:22:56 +0300 Subject: [PATCH] Use metav1.SetMetadataAnnotation instead of secret.Annotations[] to set a value to prevent nil reference --- 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 9acc5778..38fcdf86 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.2 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) }