k8ssandra/cass-operator

RequiresUpdate condition is not set when expected

Closed this issue · 0 comments

Following #566, an operator upgrade that triggers changes to an existing CassandraDatacenter should result in a new RequiresUpdate condition to be set. This does not appear to work.

Reproduction steps

Install the operator in a local kind cluster:

kind create cluster
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
make docker-build docker-logger-build
make docker-kind docker-logger-kind
make deploy

Create a DC:

apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
  namespace: cass-operator
  name: dc1
spec:
  clusterName: demo
  racks:
    - name: rack1
  serverType: cassandra
  serverVersion: 4.1.0
  size: 1
  storageConfig:
    cassandraDataVolumeClaimSpec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 100Mi
      storageClassName: standard

Add a mock label to simulate an operator change:

diff --git a/pkg/reconciliation/construct_statefulset.go b/pkg/reconciliation/construct_statefulset.go
index a9b1ca8..38e0ee4 100644
--- a/pkg/reconciliation/construct_statefulset.go
+++ b/pkg/reconciliation/construct_statefulset.go
@@ -75,6 +75,7 @@ func newStatefulSetForCassandraDatacenter(

        statefulSetLabels := dc.GetRackLabels(rackName)
        oplabels.AddOperatorLabels(statefulSetLabels, dc)
+       statefulSetLabels["mock-label"] = "mock-value"

        statefulSetSelectorLabels := dc.GetRackLabels(rackName)

Commit the changes and redeploy the operator (same make commands as above).

I see the expected log message in the operator logs:

update is blocked, but statefulset needs an update. Marking datacenter as requiring update

The STS does not have the new label, which shows that the update was correctly blocked.
However, the CassandraDatacenter has the condition set to false. It seems that either the patch was not applied correctly (unlikely because I don't get any error logs), or it got overridden.

If I annotate the DC, the update is unblocked and the new label appears on the STS.

kubectl annotate CassandraDatacenter dc1 -ncass-operator \
  cassandra.datastax.com/autoupdate-spec=once