Skip to content

Commit 4fdb3a4

Browse files
pedjakclaude
andcommitted
fix: address review feedback and upgrade test failure
- Remove unused saClient parameter from ServiceAccountDeprecationWarning - Relax serviceAccount.name immutability rule to allow clearing the deprecated field (self == oldSelf || size(self) == 0) - Delete old ClusterRoleBinding before kubectl apply during upgrade — Kubernetes does not allow changing roleRef on existing CRBs Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f7d67d8 commit 4fdb3a4

10 files changed

Lines changed: 20 additions & 17 deletions

File tree

api/v1/clusterextension_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ type ServiceAccountReference struct {
400400
// [RFC 1123]: https://tools.ietf.org/html/rfc1123
401401
//
402402
// +kubebuilder:validation:MaxLength:=253
403-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
403+
// +kubebuilder:validation:XValidation:rule="self == oldSelf || size(self) == 0",message="name is immutable once set, but may be cleared"
404404
// +kubebuilder:validation:XValidation:rule="size(self) == 0 || self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="name must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
405405
// +optional
406406
Name string `json:"name"`

cmd/operator-controller/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ func (c *boxcutterReconcilerConfigurator) Configure(ceReconciler *controllers.Cl
652652
ceReconciler.ReconcileSteps = []controllers.ReconcileStepFunc{
653653
controllers.HandleFinalizers(c.finalizers),
654654
controllers.ValidateClusterExtension(
655-
controllers.ServiceAccountDeprecationWarning(coreClient),
655+
controllers.ServiceAccountDeprecationWarning(),
656656
),
657657
controllers.MigrateStorage(storageMigrator),
658658
controllers.RetrieveRevisionStates(revisionStatesGetter),
@@ -740,7 +740,7 @@ func (c *helmReconcilerConfigurator) Configure(ceReconciler *controllers.Cluster
740740
ceReconciler.ReconcileSteps = []controllers.ReconcileStepFunc{
741741
controllers.HandleFinalizers(c.finalizers),
742742
controllers.ValidateClusterExtension(
743-
controllers.ServiceAccountDeprecationWarning(coreClient),
743+
controllers.ServiceAccountDeprecationWarning(),
744744
),
745745
controllers.RetrieveRevisionStates(revisionStatesGetter),
746746
controllers.ResolveBundle(c.resolver, c.mgr.GetClient()),

helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ spec:
206206
maxLength: 253
207207
type: string
208208
x-kubernetes-validations:
209-
- message: name is immutable
210-
rule: self == oldSelf
209+
- message: name is immutable once set, but may be cleared
210+
rule: self == oldSelf || size(self) == 0
211211
- message: name must be a valid DNS1123 subdomain. It must contain
212212
only lowercase alphanumeric characters, hyphens (-) or periods
213213
(.), start and end with an alphanumeric character, and be

helm/olmv1/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ spec:
158158
maxLength: 253
159159
type: string
160160
x-kubernetes-validations:
161-
- message: name is immutable
162-
rule: self == oldSelf
161+
- message: name is immutable once set, but may be cleared
162+
rule: self == oldSelf || size(self) == 0
163163
- message: name must be a valid DNS1123 subdomain. It must contain
164164
only lowercase alphanumeric characters, hyphens (-) or periods
165165
(.), start and end with an alphanumeric character, and be

internal/operator-controller/controllers/clusterextension_reconcile_steps.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
apimeta "k8s.io/apimachinery/pkg/api/meta"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26-
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
2726
ctrl "sigs.k8s.io/controller-runtime"
2827
"sigs.k8s.io/controller-runtime/pkg/client"
2928
"sigs.k8s.io/controller-runtime/pkg/finalizer"
@@ -99,7 +98,7 @@ func ValidateClusterExtension(validators ...ClusterExtensionValidator) Reconcile
9998

10099
// ServiceAccountDeprecationWarning returns a validator that checks if the deprecated
101100
// serviceAccount field is populated and logs a warning if found.
102-
func ServiceAccountDeprecationWarning(saClient corev1client.ServiceAccountsGetter) ClusterExtensionValidator {
101+
func ServiceAccountDeprecationWarning() ClusterExtensionValidator {
103102
return func(ctx context.Context, ext *ocv1.ClusterExtension) error {
104103
l := log.FromContext(ctx)
105104
if len(ext.Spec.ServiceAccount.Name) > 0 { //nolint:staticcheck // intentional read of deprecated field to emit deprecation warning

manifests/experimental-e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ spec:
820820
maxLength: 253
821821
type: string
822822
x-kubernetes-validations:
823-
- message: name is immutable
824-
rule: self == oldSelf
823+
- message: name is immutable once set, but may be cleared
824+
rule: self == oldSelf || size(self) == 0
825825
- message: name must be a valid DNS1123 subdomain. It must contain
826826
only lowercase alphanumeric characters, hyphens (-) or periods
827827
(.), start and end with an alphanumeric character, and be

manifests/experimental.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ spec:
781781
maxLength: 253
782782
type: string
783783
x-kubernetes-validations:
784-
- message: name is immutable
785-
rule: self == oldSelf
784+
- message: name is immutable once set, but may be cleared
785+
rule: self == oldSelf || size(self) == 0
786786
- message: name must be a valid DNS1123 subdomain. It must contain
787787
only lowercase alphanumeric characters, hyphens (-) or periods
788788
(.), start and end with an alphanumeric character, and be

manifests/standard-e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ spec:
772772
maxLength: 253
773773
type: string
774774
x-kubernetes-validations:
775-
- message: name is immutable
776-
rule: self == oldSelf
775+
- message: name is immutable once set, but may be cleared
776+
rule: self == oldSelf || size(self) == 0
777777
- message: name must be a valid DNS1123 subdomain. It must contain
778778
only lowercase alphanumeric characters, hyphens (-) or periods
779779
(.), start and end with an alphanumeric character, and be

manifests/standard.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ spec:
733733
maxLength: 253
734734
type: string
735735
x-kubernetes-validations:
736-
- message: name is immutable
737-
rule: self == oldSelf
736+
- message: name is immutable once set, but may be cleared
737+
rule: self == oldSelf || size(self) == 0
738738
- message: name must be a valid DNS1123 subdomain. It must contain
739739
only lowercase alphanumeric characters, hyphens (-) or periods
740740
(.), start and end with an alphanumeric character, and be

scripts/install.tpl.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ if [ -f "${olmv1_manifest}" ]; then
116116
olmv1_manifest=file://localhost$(realpath ${olmv1_manifest})
117117
fi
118118

119+
# Delete the old ClusterRoleBinding if it exists — Kubernetes does not allow
120+
# changing roleRef via kubectl apply, so we must delete before re-creating.
121+
kubectl delete clusterrolebinding operator-controller-manager-rolebinding --ignore-not-found
122+
119123
curl -L -s "${olmv1_manifest}" | sed "s/olmv1-system/${olmv1_namespace}/g" | kubectl apply -f -
120124
# Wait for the rollout, and then wait for the deployment to be Available
121125
kubectl_wait_rollout "${olmv1_namespace}" "deployment/catalogd-controller-manager" "60s"

0 commit comments

Comments
 (0)