Skip to content

Commit 6d3f256

Browse files
committed
fix(controller): skip bucket-class label when BucketClassName is not a valid label value
Signed-off-by: harshitrwt <[email protected]>
1 parent 588404d commit 6d3f256

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎internal/controller/workloadmonitor_controller.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
apierrors "k8s.io/apimachinery/pkg/api/errors"
1616
"k8s.io/apimachinery/pkg/runtime"
1717
"k8s.io/apimachinery/pkg/types"
18+
"k8s.io/apimachinery/pkg/util/validation"
1819
"k8s.io/client-go/tools/record"
1920
"k8s.io/client-go/util/retry"
2021
"k8s.io/utils/pointer"
@@ -329,8 +330,13 @@ func (r *WorkloadMonitorReconciler) reconcileBucketClaimForMonitor(
329330
workload.Labels[workloadMonitorLabel] = monitor.Name
330331

331332
if bc.Spec.BucketClassName != "" {
332-
workload.Labels["workloads.cozystack.io/bucket-class"] = bc.Spec.BucketClassName
333-
}
333+
if errs := validation.IsValidLabelValue(bc.Spec.BucketClassName); len(errs) == 0 {
334+
workload.Labels["workloads.cozystack.io/bucket-class"] = bc.Spec.BucketClassName
335+
} else {
336+
logger.Info("Skipping bucket-class label: not a valid label value",
337+
"bucketClaim", bc.Name, "bucketClassName", bc.Spec.BucketClassName, "errors", errs)
338+
}
339+
}
334340

335341
// Start from the sizes already recorded on the Workload: when the
336342
// metrics endpoint is unreachable or reports nothing for this bucket,

0 commit comments

Comments
 (0)