diff --git a/internal/controllers/control/cassandratask_controller.go b/internal/controllers/control/cassandratask_controller.go index 2de2a17b..e7016ce9 100644 --- a/internal/controllers/control/cassandratask_controller.go +++ b/internal/controllers/control/cassandratask_controller.go @@ -98,6 +98,7 @@ type TaskConfiguration struct { // Execution functionality per pod AsyncFeature httphelper.Feature AsyncFunc AsyncTaskExecutorFunc + SyncFeature httphelper.Feature SyncFunc SyncTaskExecutorFunc PodFilter PodFilterFunc @@ -649,13 +650,9 @@ func (r *CassandraTaskReconciler) reconcileEveryPodTask(ctx context.Context, dc if !taskConfig.Filter(&pod) { continue } - - features := &httphelper.FeatureSet{} - if taskConfig.AsyncFeature != "" { - features, err = nodeMgmtClient.FeatureSet(&pod) - if err != nil { - return ctrl.Result{}, failed, completed, errMsg, err - } + features, err := nodeMgmtClient.FeatureSet(&pod) + if err != nil { + return ctrl.Result{}, failed, completed, errMsg, err } if pod.Annotations == nil { @@ -817,6 +814,13 @@ func (r *CassandraTaskReconciler) reconcileEveryPodTask(ctx context.Context, dc <-jobRunner }() + if taskConfig.SyncFeature != "" { + if !features.Supports(taskConfig.SyncFeature) { + logger.Error(err, "Pod doesn't support this feature", "Pod", pod, "Feature", taskConfig.SyncFeature) + jobStatus.Status = podJobError + } + } + if err = taskConfig.SyncFunc(nodeMgmtClient, &pod, taskConfig); err != nil { // We only log, nothing else to do - we won't even retry this pod logger.Error(err, "executing the sync task failed", "Pod", pod) diff --git a/internal/controllers/control/cassandratask_controller_test.go b/internal/controllers/control/cassandratask_controller_test.go index dd0557bf..71411940 100644 --- a/internal/controllers/control/cassandratask_controller_test.go +++ b/internal/controllers/control/cassandratask_controller_test.go @@ -634,6 +634,7 @@ var _ = Describe("CassandraTask controller tests", func() { completedTask := waitForTaskCompletion(taskKey) Expect(callDetails.URLCounts["/api/v0/ops/node/encryption/internode/truststore/reload"]).To(Equal(1)) + Expect(callDetails.URLCounts["/api/v0/metadata/versions/features"]).To(BeNumerically(">", 1)) // verifyPodsHaveAnnotations(testNamespaceName, string(task.UID)) Expect(completedTask.Status.Succeeded).To(BeNumerically(">=", 1))