Skip to content

Commit

Permalink
Error handling for when a pod does not support the new ts reload func…
Browse files Browse the repository at this point in the history
…tionality.
  • Loading branch information
Miles-Garnsey committed Aug 28, 2024
1 parent d97b1d1 commit 3e14620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/controllers/control/cassandratask_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type TaskConfiguration struct {
// Execution functionality per pod
AsyncFeature httphelper.Feature
AsyncFunc AsyncTaskExecutorFunc
SyncFeature httphelper.Feature
SyncFunc SyncTaskExecutorFunc
PodFilter PodFilterFunc

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3e14620

Please sign in to comment.