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

Don't swallow errors when uninstalling FluxCD #4394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions cmd/flux/uninstall.go
Expand Up @@ -90,16 +90,24 @@ func uninstallCmdRun(cmd *cobra.Command, args []string) error {
}

logger.Actionf("deleting components in %s namespace", *kubeconfigArgs.Namespace)
uninstall.Components(ctx, logger, kubeClient, *kubeconfigArgs.Namespace, uninstallArgs.dryRun)
if err := uninstall.Components(ctx, logger, kubeClient, *kubeconfigArgs.Namespace, uninstallArgs.dryRun); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to ignore not found errors using https://github.com/kubernetes/apimachinery/blob/v0.27.4/pkg/api/errors/errors.go#L527 . Any other errors may be important.

return err
}

logger.Actionf("deleting toolkit.fluxcd.io finalizers in all namespaces")
uninstall.Finalizers(ctx, logger, kubeClient, uninstallArgs.dryRun)
if err := uninstall.Finalizers(ctx, logger, kubeClient, uninstallArgs.dryRun); err != nil {
return err
}

logger.Actionf("deleting toolkit.fluxcd.io custom resource definitions")
uninstall.CustomResourceDefinitions(ctx, logger, kubeClient, uninstallArgs.dryRun)
if err := uninstall.CustomResourceDefinitions(ctx, logger, kubeClient, uninstallArgs.dryRun); err != nil {
return err
}

if !uninstallArgs.keepNamespace {
uninstall.Namespace(ctx, logger, kubeClient, *kubeconfigArgs.Namespace, uninstallArgs.dryRun)
if err := uninstall.Namespace(ctx, logger, kubeClient, *kubeconfigArgs.Namespace, uninstallArgs.dryRun); err != nil {
return err
}
}

logger.Successf("uninstall finished")
Expand Down