Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking the controller installation state at startup #181

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,28 @@ 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