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 uninstall dry-run has confirmation #46347

Merged
merged 1 commit into from
Aug 7, 2023
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
fix uninstall dry-run has confirmation
  • Loading branch information
hanxiaop committed Aug 7, 2023
commit e3262a64154214e49166317770e4651b69de813c
8 changes: 4 additions & 4 deletions operator/cmd/mesh/uninstall.go
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@ func uninstall(cmd *cobra.Command, rootArgs *RootArgs, uiArgs *uninstallArgs, lo
if err != nil {
return err
}
preCheckWarnings(cmd, kubeClientWithRev, uiArgs, uiArgs.revision, objectsList, nil, l)
preCheckWarnings(cmd, kubeClientWithRev, uiArgs, uiArgs.revision, objectsList, nil, l, rootArgs.DryRun)

if err := h.DeleteObjectsList(objectsList, ""); err != nil {
return fmt.Errorf("failed to delete control plane resources by revision: %v", err)
@@ -198,7 +198,7 @@ func uninstall(cmd *cobra.Command, rootArgs *RootArgs, uiArgs *uninstallArgs, lo
if err != nil {
return err
}
preCheckWarnings(cmd, kubeClientWithRev, uiArgs, iop.Spec.Revision, nil, cpObjects, l)
preCheckWarnings(cmd, kubeClientWithRev, uiArgs, iop.Spec.Revision, nil, cpObjects, l, rootArgs.DryRun)
h, err = helmreconciler.NewHelmReconciler(client, kubeClient, iop, opts)
if err != nil {
return fmt.Errorf("failed to create reconciler: %v", err)
@@ -214,7 +214,7 @@ func uninstall(cmd *cobra.Command, rootArgs *RootArgs, uiArgs *uninstallArgs, lo
// 1. checks proxies still pointing to the target control plane revision.
// 2. lists to be pruned resources if user uninstall by --revision flag.
func preCheckWarnings(cmd *cobra.Command, kubeClient kube.CLIClient, uiArgs *uninstallArgs,
rev string, resourcesList []*unstructured.UnstructuredList, objectsList object.K8sObjects, l *clog.ConsoleLogger,
rev string, resourcesList []*unstructured.UnstructuredList, objectsList object.K8sObjects, l *clog.ConsoleLogger, dryRun bool,
) {
pids, err := proxyinfo.GetIDsFromProxyInfo(kubeClient, uiArgs.istioNamespace)
if err != nil {
@@ -250,7 +250,7 @@ func preCheckWarnings(cmd *cobra.Command, kubeClient kube.CLIClient, uiArgs *uni
message += fmt.Sprintf(GatewaysRemovedWarning, gwList)
}
}
if uiArgs.skipConfirmation {
if dryRun || uiArgs.skipConfirmation {
Copy link
Member

Choose a reason for hiding this comment

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

Is it really dry running? It seems like it will just print the message and continue with the run.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dryrun itself is functioning well. This is simply to bypass confirmation in --dry-run mode - which is no need in dryrun, similar to other istioctl commands.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Thanks.

l.LogAndPrint(message)
return
}