Skip to content

Commit

Permalink
Fix checking the controller installation state at startup
Browse files Browse the repository at this point in the history
The controller manager's client being used was not yet started, so this
check failed and was just ignored.

Relates:
https://issues.redhat.com/browse/ACM-8826

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl committed Dec 4, 2023
1 parent f3029de commit e67c752
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,25 @@ func main() {

uninstallingCtx, uninstallingCtxCancel := context.WithCancel(terminatingCtx)

beingUninstalled, err := controllers.IsBeingUninstalled(mgr.GetClient())
var beingUninstalled bool

// Can't use the manager client because the manager isn't started yet.
uninstallCheckClient, err := client.New(cfg, client.Options{Scheme: scheme})
if err != nil {
log.Error(err, "Failed to determine if the controller is being uninstalled at startup. Will assume it's not.")
} else {
beingUninstalled, err = controllers.IsBeingUninstalled(uninstallCheckClient)
if err != nil {
log.Error(err, "Failed to determine if the controller is being uninstalled at startup. Will assume it's not.")
}
}

if beingUninstalled {
log.Info("The controller is being uninstalled. Will enter uninstall mode.")

uninstallingCtxCancel()
} else {
log.V(2).Info("The controller is not being uninstalled. Will continue as normal.")
}

var targetK8sClient kubernetes.Interface
Expand Down

0 comments on commit e67c752

Please sign in to comment.