🐛 Fix work rolebinding cleanup when hubAcceptsClient is set to false (#1318)
Some checks failed
Scorecard supply-chain security / Scorecard analysis (push) Failing after 13s
Post / images (amd64, addon-manager) (push) Failing after 48s
Post / images (amd64, placement) (push) Failing after 1m22s
Post / images (amd64, registration) (push) Failing after 42s
Post / images (amd64, work) (push) Failing after 41s
Post / images (arm64, addon-manager) (push) Failing after 42s
Post / images (arm64, placement) (push) Failing after 41s
Post / images (arm64, registration) (push) Failing after 41s
Post / images (arm64, registration-operator) (push) Failing after 41s
Post / images (arm64, work) (push) Failing after 42s
Post / images (amd64, registration-operator) (push) Failing after 21m14s
Post / image manifest (addon-manager) (push) Has been skipped
Post / image manifest (placement) (push) Has been skipped
Post / image manifest (registration) (push) Has been skipped
Post / image manifest (registration-operator) (push) Has been skipped
Post / image manifest (work) (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 39m11s
Close stale issues and PRs / stale (push) Successful in 50s

* Fix work rolebinding cleanup when hubAcceptsClient is set to false
Signed-off-by: Erico G. Rimoli <erico.rimoli@totvs.com.br>

* Adds error handling to the removeClusterRbac call within the controller synchronization function
Signed-off-by: Erico G. Rimoli <erico.rimoli@totvs.com.br>
This commit is contained in:
Érico GR
2026-01-08 10:46:13 -03:00
committed by GitHub
parent 8e401c34a9
commit ad89f05351
2 changed files with 24 additions and 21 deletions

View File

@@ -181,6 +181,17 @@ func (c *managedClusterController) sync(ctx context.Context, syncCtx factory.Syn
}
}
// Remove the cluster role binding files for registration-agent and work-agent.
err := c.removeClusterRbac(ctx, syncCtx, managedClusterName, managedCluster.Spec.HubAcceptsClient)
if errors.Is(err, requeueError) {
syncCtx.Queue().AddAfter(managedClusterName, requeueError.RequeueTime)
return nil
}
if err != nil {
errs = append(errs, err)
}
if err = c.hubDriver.Cleanup(ctx, managedCluster); err != nil {
errs = append(errs, err)
}
@@ -200,13 +211,7 @@ func (c *managedClusterController) sync(ctx context.Context, syncCtx factory.Syn
return err
}
// Remove the cluster role binding files for registration-agent and work-agent.
err = c.removeClusterRbac(ctx, syncCtx, managedClusterName, managedCluster.Spec.HubAcceptsClient)
if errors.Is(err, requeueError) {
syncCtx.Queue().AddAfter(managedClusterName, requeueError.RequeueTime)
return nil
}
return err
return nil
}
// TODO consider to add the managedcluster-namespace.yaml back to staticFiles,