Skip to content

Commit ac65cd5

Browse files
committed
add warnings about changing the name of the controllers unless we add stale condition fixes
1 parent 4085601 commit ac65cd5

File tree

41 files changed

+273
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+273
-83
lines changed

pkg/operator/apiserver/controller/apiservice/apiservice_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (c *APIServiceController) updateOperatorStatus(
121121
defer func() {
122122
status := applyoperatorv1.OperatorStatus().
123123
WithConditions(conditionAPIServicesDegraded, conditionAPIServicesAvailable)
124-
updateError := c.operatorClient.ApplyOperatorStatus(ctx, factory.ControllerFieldManager(c.controllerInstanceName, "updateOperatorStatus"), status)
124+
updateError := c.operatorClient.ApplyOperatorStatus(ctx, c.controllerInstanceName, status)
125125
if updateError != nil {
126126
// overrides error returned through 'return <ERROR>' statement
127127
err = updateError

pkg/operator/apiserver/controller/auditpolicy/auditpolicy_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ func NewAuditPolicyController(
5858
configInformers.Config().V1().APIServers().Informer(),
5959
kubeInformersForTargetNamesace.Core().V1().ConfigMaps().Informer(),
6060
operatorClient.Informer(),
61-
).ToController("auditPolicyController", eventRecorder.WithComponentSuffix("audit-policy-controller"))
61+
).ToController(
62+
"auditPolicyController", // don't change what is passed here unless you also remove the old FooDegraded condition
63+
eventRecorder.WithComponentSuffix("audit-policy-controller"),
64+
)
6265
}
6366

6467
func (c *auditPolicyController) sync(ctx context.Context, syncCtx factory.SyncContext) error {

pkg/operator/apiserver/controller/nsfinalizer/finalizer_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ func NewFinalizerController(
5353
return factory.New().ResyncEvery(time.Minute).WithSync(c.sync).WithInformers(
5454
kubeInformersForTargetNamespace.Core().V1().Pods().Informer(),
5555
kubeInformersForTargetNamespace.Apps().V1().DaemonSets().Informer(),
56-
).ToController(fullname, eventRecorder.WithComponentSuffix("finalizer-controller"))
56+
).ToController(
57+
fullname, // don't change what is passed here unless you also remove the old FooDegraded condition
58+
eventRecorder.WithComponentSuffix("finalizer-controller"),
59+
)
5760
}
5861

5962
func (c finalizerController) sync(ctx context.Context, syncCtx factory.SyncContext) error {

pkg/operator/apiserver/controller/workload/workload.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ func NewController(name, operatorNamespace, targetNamespace, targetOperandVersio
110110

111111
return c.WithSync(controllerRef.sync).
112112
WithInformers(informers...).
113-
ToController(fmt.Sprintf("%sWorkloadController", name), eventRecorder)
113+
ToController(
114+
fmt.Sprintf("%sWorkloadController", name), // don't change what is passed here unless you also remove the old FooDegraded condition
115+
eventRecorder,
116+
)
114117
}
115118

116119
func (c *Controller) sync(ctx context.Context, controllerContext factory.SyncContext) error {

pkg/operator/certrotation/client_cert_rotation_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ func NewCertRotationController(
9898
WithPostStartHooks(
9999
c.targetCertRecheckerPostRunHook,
100100
).
101-
ToController("CertRotationController", recorder.WithComponentSuffix("cert-rotation-controller").WithComponentSuffix(name))
101+
ToController(
102+
"CertRotationController", // don't change what is passed here unless you also remove the old FooDegraded condition
103+
recorder.WithComponentSuffix("cert-rotation-controller").WithComponentSuffix(name),
104+
)
102105
}
103106

104107
func (c CertRotationController) Sync(ctx context.Context, syncCtx factory.SyncContext) error {

pkg/operator/configobserver/config_observer_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ func NewNestedConfigObserver(
119119
degradedConditionType: degradedConditionPrefix + condition.ConfigObservationDegradedConditionType,
120120
}
121121

122-
return factory.New().ResyncEvery(time.Minute).WithSync(c.sync).WithInformers(append(informers, listersToInformer(listers)...)...).ToController("ConfigObserver", eventRecorder.WithComponentSuffix("config-observer"))
122+
return factory.New().
123+
ResyncEvery(time.Minute).
124+
WithSync(c.sync).
125+
WithInformers(append(informers, listersToInformer(listers)...)...).
126+
ToController(
127+
"ConfigObserver", // don't change what is passed here unless you also remove the old FooDegraded condition
128+
eventRecorder.WithComponentSuffix("config-observer"),
129+
)
123130
}
124131

125132
// sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This

pkg/operator/connectivitycheckcontroller/connectivity_check_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ func NewConnectivityCheckController(
7878
c.Controller = factory.New().
7979
WithSync(c.Sync).
8080
WithInformers(allTriggers...).
81-
ToController("ConnectivityCheckController", recorder.WithComponentSuffix("connectivity-check-controller"))
81+
ToController(
82+
"ConnectivityCheckController", // don't change what is passed here unless you also remove the old FooDegraded condition
83+
recorder.WithComponentSuffix("connectivity-check-controller"),
84+
)
8285
return c
8386
}
8487

pkg/operator/csi/credentialsrequestcontroller/credentials_request_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func NewCredentialsRequestController(
7575
).WithSyncDegradedOnError(
7676
operatorClient,
7777
).ToController(
78-
c.name,
78+
c.name, // don't change what is passed here unless you also remove the old FooDegraded condition
7979
recorder.WithComponentSuffix("credentials-request-controller-"+strings.ToLower(name)),
8080
)
8181
}

pkg/operator/csi/csidrivernodeservicecontroller/csi_driver_node_service_controller.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ type DaemonSetHookFunc func(*opv1.OperatorSpec, *appsv1.DaemonSet) error
7171
// <name>Progressing: indicates that the CSI Node Service is being deployed.
7272
// <name>Degraded: produced when the sync() method returns an error.
7373
type CSIDriverNodeServiceController struct {
74-
name string
75-
manifest []byte
76-
operatorClient v1helpers.OperatorClientWithFinalizers
77-
kubeClient kubernetes.Interface
78-
dsInformer appsinformersv1.DaemonSetInformer
74+
// instanceName is the name to identify what instance this belongs too: FooDriver for instance
75+
instanceName string
76+
// controllerInstanceName is the name to identify this instance of this particular control loop: FooDriver-CSIDriverNodeService for instance.
77+
controllerInstanceName string
78+
manifest []byte
79+
operatorClient v1helpers.OperatorClientWithFinalizers
80+
kubeClient kubernetes.Interface
81+
dsInformer appsinformersv1.DaemonSetInformer
7982
// Optional hook functions to modify the DaemonSet.
8083
// If one of these functions returns an error, the sync
8184
// fails indicating the ordinal position of the failed function.
@@ -85,7 +88,7 @@ type CSIDriverNodeServiceController struct {
8588
}
8689

8790
func NewCSIDriverNodeServiceController(
88-
name string,
91+
instanceName string,
8992
manifest []byte,
9093
recorder events.Recorder,
9194
operatorClient v1helpers.OperatorClientWithFinalizers,
@@ -95,7 +98,8 @@ func NewCSIDriverNodeServiceController(
9598
optionalDaemonSetHooks ...DaemonSetHookFunc,
9699
) factory.Controller {
97100
c := &CSIDriverNodeServiceController{
98-
name: name,
101+
instanceName: instanceName,
102+
controllerInstanceName: factory.ControllerInstanceName(instanceName, "CSIDriverNodeService"),
99103
manifest: manifest,
100104
operatorClient: operatorClient,
101105
kubeClient: kubeClient,
@@ -115,13 +119,13 @@ func NewCSIDriverNodeServiceController(
115119
).WithSyncDegradedOnError(
116120
operatorClient,
117121
).ToController(
118-
c.name,
119-
recorder.WithComponentSuffix("csi-driver-node-service_"+strings.ToLower(name)),
122+
c.instanceName, // don't change what is passed here unless you also remove the old FooDegraded condition
123+
recorder.WithComponentSuffix("csi-driver-node-service_"+strings.ToLower(instanceName)),
120124
)
121125
}
122126

123127
func (c *CSIDriverNodeServiceController) Name() string {
124-
return c.name
128+
return c.instanceName
125129
}
126130

127131
func (c *CSIDriverNodeServiceController) sync(ctx context.Context, syncContext factory.SyncContext) error {
@@ -154,7 +158,7 @@ func (c *CSIDriverNodeServiceController) sync(ctx context.Context, syncContext f
154158
func (c *CSIDriverNodeServiceController) syncManaged(ctx context.Context, opSpec *opv1.OperatorSpec, opStatus *opv1.OperatorStatus, syncContext factory.SyncContext) error {
155159
klog.V(4).Infof("syncManaged")
156160
if management.IsOperatorRemovable() {
157-
if err := v1helpers.EnsureFinalizer(ctx, c.operatorClient, c.name); err != nil {
161+
if err := v1helpers.EnsureFinalizer(ctx, c.operatorClient, c.instanceName); err != nil {
158162
return err
159163
}
160164
}
@@ -187,7 +191,7 @@ func (c *CSIDriverNodeServiceController) syncManaged(ctx context.Context, opSpec
187191

188192
// Set Available condition
189193
availableCondition := applyoperatorv1.OperatorCondition().
190-
WithType(c.name + opv1.OperatorStatusTypeAvailable).
194+
WithType(c.instanceName + opv1.OperatorStatusTypeAvailable).
191195
WithStatus(opv1.ConditionTrue)
192196

193197
if daemonSet.Status.NumberAvailable > 0 {
@@ -202,7 +206,7 @@ func (c *CSIDriverNodeServiceController) syncManaged(ctx context.Context, opSpec
202206

203207
// Set Progressing condition
204208
progressingCondition := applyoperatorv1.OperatorCondition().
205-
WithType(c.name + opv1.OperatorStatusTypeProgressing).
209+
WithType(c.instanceName + opv1.OperatorStatusTypeProgressing).
206210
WithStatus(opv1.ConditionFalse)
207211

208212
if ok, msg := isProgressing(opStatus, daemonSet); ok {
@@ -215,7 +219,7 @@ func (c *CSIDriverNodeServiceController) syncManaged(ctx context.Context, opSpec
215219

216220
return c.operatorClient.ApplyOperatorStatus(
217221
ctx,
218-
factory.ControllerFieldManager(c.name, "updateOperatorStatus"),
222+
c.controllerInstanceName,
219223
status,
220224
)
221225
}
@@ -301,5 +305,5 @@ func (c *CSIDriverNodeServiceController) syncDeleting(ctx context.Context, opSpe
301305
}
302306

303307
// All removed, remove the finalizer as the last step
304-
return v1helpers.RemoveFinalizer(ctx, c.operatorClient, c.name)
308+
return v1helpers.RemoveFinalizer(ctx, c.operatorClient, c.instanceName)
305309
}

pkg/operator/csi/csistorageclasscontroller/csi_storageclass_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func NewCSIStorageClassController(
9696
informerFactory.Storage().V1().StorageClasses().Informer(),
9797
operatorInformer.Operator().V1().ClusterCSIDrivers().Informer(),
9898
).ToController(
99-
"StorageClassController",
99+
"StorageClassController", // don't change what is passed here unless you also remove the old FooDegraded condition
100100
eventRecorder,
101101
)
102102
}

0 commit comments

Comments
 (0)