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

Confirm before overriding installation by another manager #4355

Merged
merged 2 commits into from Nov 1, 2023

Conversation

somtochiama
Copy link
Member

@somtochiama somtochiama commented Oct 24, 2023

This pull request prompts a user to confirm before overriding an existing Flux installation that's not managed by flux when running install or bootstrap.

The pull request also adds a better uninstallation prompt when flux is managed by some other tool.

Fixes: #4342

cmd/flux/bootstrap.go Outdated Show resolved Hide resolved
cmd/flux/cluster_info.go Outdated Show resolved Hide resolved
cmd/flux/install.go Outdated Show resolved Hide resolved
cmd/flux/cluster_info.go Outdated Show resolved Hide resolved
cmd/flux/bootstrap_git.go Show resolved Hide resolved
@stefanprodan stefanprodan added enhancement New feature or request area/bootstrap Bootstrap related issues and pull requests area/install Install and uninstall related issues and pull requests labels Oct 24, 2023
@somtochiama somtochiama marked this pull request as ready for review October 24, 2023 15:27
cmd/flux/bootstrap.go Outdated Show resolved Hide resolved
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @somtochiama 🥇

Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

The overall implementation looks good to me.
Left a minor suggestion.

cmd/flux/bootstrap_gitlab.go Outdated Show resolved Hide resolved
@darkowlzz
Copy link
Contributor

darkowlzz commented Oct 31, 2023

I think the uninstall command can also be updated along the same lines to provide some extra information based on the cluster info. There's already a confirmation prompt for uninstall. We can just mention who is managing flux. By confirming, users will be acknowledging that although flux is managed by someone else, they want to proceed and uninstall.

Comment on lines +76 to +77
}
}
Copy link
Contributor

@darkowlzz darkowlzz Oct 31, 2023

Choose a reason for hiding this comment

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

Here we know that flux is not installed at all if there's an error and it's not found error. We can print some accurate message and quit early. At present, even if it's not installed, it blindly runs the uninstall operations.

? Are you sure you want to delete Flux and its custom resource definitions? [y/N] y
► deleting toolkit.fluxcd.io finalizers in all namespaces
► deleting toolkit.fluxcd.io custom resource definitions
✗ Namespace/flux-system deletion failed: namespaces "flux-system" not found
✔ uninstall finished

Ending with status code 0 is another issue which can be addressed separately.

Copy link
Member Author

@somtochiama somtochiama Oct 31, 2023

Choose a reason for hiding this comment

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

. Here we know that flux is not installed at all if there's an error and it's not found error.

Should we consider a case where the CRDs might not be present (maybe due to a previous incomplete uninstall) but the flux-system namespace is still present? Returning early will not delete the namespace

Copy link
Member

Choose a reason for hiding this comment

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

We should always uninstall, this saved so many users from Helm uninstall and TF delete partial failures where some objects were stuck. I'm also not for extending this PR to uninstall, let's write an issue for improving the uninstall procedure if we must, and discuss there the specs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can keep the uninstall prompt as it doesn't change any existing uninstall behaviour and only gives the user some more information. I will open a new issue for any other changes around the uninstall procedure.

cmd/flux/uninstall.go Outdated Show resolved Hide resolved
@somtochiama somtochiama force-pushed the safe-bootstrap branch 2 times, most recently from 2cd38df to d6f0247 Compare October 31, 2023 15:53
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!
Left a comment about an old in-line comment that can be updated before merging.

cmd/flux/cluster_info.go Outdated Show resolved Hide resolved
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bootstrap Bootstrap related issues and pull requests area/install Install and uninstall related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add prompt when overriding a Helm-managed Flux installation
3 participants