@@ -90,10 +90,10 @@ var (
9090 "storageclasses" ,
9191 "validatingwebhookconfigurations" ,
9292 }
93- )
9493
95- const (
96- injectedCABundleConfigMap = "injected-cabundle-stackrox-central-services"
94+ injectedCABundleConfigMapPrefix = "injected-cabundle-"
95+ injectedCABundleConfigMapCentral = injectedCABundleConfigMapPrefix + centralCrName
96+ injectedCABundleConfigMapSecuredCluster = injectedCABundleConfigMapPrefix + securedClusterCrName
9797)
9898
9999// Deployer is the base deployer for ACS
@@ -189,14 +189,13 @@ func (d *Deployer) deleteCentralResources(ctx context.Context, wait bool) error
189189 // Pause reconciliation for other controllers, not just our RHACS operator.
190190 // This is needed to ensure that there is no race causing the Cluster Network Operator
191191 // to re-create the injected-ca-bundle ConfigMap during resource deletion.
192- err := d .preventOtherControllersFromReconciling (ctx )
193- if err != nil {
194- return fmt .Errorf ("failed to prevent other controllers from reconciling: %w" , err )
192+ if err := d .preventOtherControllersFromReconciling (ctx , component .Central ); err != nil {
193+ return fmt .Errorf ("failed to prevent other controllers from reconciling Central resources: %w" , err )
195194 }
196195
197196 // Delete other resources by brute force.
198197 resourceKinds := d .filterResourceKinds (allInstallableCentralResourceKinds )
199- err = d .deleteResources (ctx , d .config .Central .Namespace , resourceKinds , "-l=app.kubernetes.io/part-of=stackrox-central-services" )
198+ err : = d .deleteResources (ctx , d .config .Central .Namespace , resourceKinds , "-l=app.kubernetes.io/part-of=stackrox-central-services" )
200199 if err != nil {
201200 return err
202201 }
@@ -206,9 +205,9 @@ func (d *Deployer) deleteCentralResources(ctx context.Context, wait bool) error
206205 {Name : "central-db-backup" , Kind : "pvc" , OwnerName : centralCrName },
207206 {Name : "admin-password" , Kind : "secret" },
208207 {Name : "scanner-db-password" , Kind : "secret" , OwnerName : centralCrName },
209- // In case the Cluster Network Operator has succeeded in re-creating the injectedCABundleConfigMap
208+ // In case the Cluster Network Operator has succeeded in re-creating the injected-cabundle configmap
210209 // after our operator has already deleted it.
211- {Name : injectedCABundleConfigMap , Kind : "configmap" },
210+ {Name : injectedCABundleConfigMapCentral , Kind : "configmap" },
212211 } {
213212 d .logger .Dimf ("Attempting to delete %s/%s" , resource .Kind , resource .Name )
214213 if resource .OwnerName != "" {
@@ -243,17 +242,22 @@ func (d *Deployer) deleteCentralResources(ctx context.Context, wait bool) error
243242 return nil
244243}
245244
246- func (d * Deployer ) preventOtherControllersFromReconciling (ctx context.Context ) error {
247- return d .preventCABundleInjection (ctx )
245+ func (d * Deployer ) preventOtherControllersFromReconciling (ctx context.Context , comp component.Component ) error {
246+ switch comp {
247+ case component .Central :
248+ return d .preventCABundleInjection (ctx , injectedCABundleConfigMapCentral , d .config .Central .Namespace )
249+ case component .SecuredCluster :
250+ return d .preventCABundleInjection (ctx , injectedCABundleConfigMapSecuredCluster , d .config .SecuredCluster .Namespace )
251+ default :
252+ return nil
253+ }
248254}
249255
250- func (d * Deployer ) preventCABundleInjection (ctx context.Context ) error {
251- configMapName := injectedCABundleConfigMap
252-
256+ func (d * Deployer ) preventCABundleInjection (ctx context.Context , configMapName , namespace string ) error {
253257 d .logger .Info ("Removing CNO label from injected-cabundle ConfigMap to prevent CNO from injecting the CA bundle during cleanup" )
254258 _ , err := d .runKubectl (ctx , k8s.KubectlOptions {
255259 Args : []string {
256- "label" , "configmap" , configMapName , "-n" , d . config . Central . Namespace ,
260+ "label" , "configmap" , configMapName , "-n" , namespace ,
257261 "config.openshift.io/inject-trusted-cabundle-" ,
258262 },
259263 IgnoreErrors : true ,
@@ -285,6 +289,13 @@ func (d *Deployer) deleteSecuredClusterResources(ctx context.Context, wait bool)
285289 }
286290 }
287291
292+ // Pause reconciliation for other controllers, not just our RHACS operator.
293+ // This is needed to ensure that there is no race causing the Cluster Network Operator
294+ // to re-create the injected-ca-bundle ConfigMap during resource deletion.
295+ if err := d .preventOtherControllersFromReconciling (ctx , component .SecuredCluster ); err != nil {
296+ return fmt .Errorf ("failed to prevent other controllers from reconciling SecuredCluster resources: %w" , err )
297+ }
298+
288299 // In the meantime, delete other resources by brute force.
289300 resourceKinds := d .filterResourceKinds (allInstallableSecuredClusterResourceKinds )
290301 err := d .deleteResources (ctx , d .config .SecuredCluster .Namespace , resourceKinds , "-l=app.kubernetes.io/part-of=stackrox-secured-cluster-services" )
@@ -297,6 +308,9 @@ func (d *Deployer) deleteSecuredClusterResources(ctx context.Context, wait bool)
297308 // We need to make sure that don't accidentally delete a scanner-db-password belonging to the central CR,
298309 // when both are deployed into the same namespace.
299310 {Name : "scanner-db-password" , Kind : "secret" , OwnerName : securedClusterCrName },
311+ // In case the Cluster Network Operator has succeeded in re-creating the injected-cabundle configmap
312+ // after our operator has already deleted it.
313+ {Name : injectedCABundleConfigMapSecuredCluster , Kind : "configmap" },
300314 } {
301315 d .logger .Dimf ("Attempting to delete %s/%s" , resource .Kind , resource .Name )
302316 if resource .OwnerName != "" {
0 commit comments