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

helm uninstall #12968

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

sjeandeaux
Copy link

@sjeandeaux sjeandeaux commented Apr 19, 2024

What this PR does / why we need it:

The goal is to have the same behaviour with or without dry-run with --ignore-not-found on uninstall.

I am developping a CD pipeline:

  • on pull request, it executes a dry-run but it fails with --ignore-not-found even if the release is not found
  • on merge on default branch, it executes and succeeds even if the release is not found which what we expect

The fact is the pull request will be blocked due a failed build. The dry-run does not have the same behaviour.

Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

refs #12970

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 19, 2024
The goal is to have the same behaviour with or without dry-run with --ignore-not-found

close helm#12970

Signed-off-by: Stephane Jeandeaux <stephane.jeandeaux@gmail.com>
Copy link

@eddymoulton eddymoulton left a comment

Choose a reason for hiding this comment

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

Successfully tested this locally with the below process.
The standard dry run output (without --ignore-not-found) still differs from the regular output, but I'm happy that this PR fixes the issue it set out to fix.

helm install hello-world examples/hello-world

# Check behaviour is the same when a release exists
./bin/helm uninstall --dry-run --ignore-not-found hello-world
./bin/helm uninstall --ignore-not-found hello-world

# Check behaviour when the release doesn't exist (this change)
./bin/helm uninstall --dry-run --ignore-not-found hello-world
./bin/helm uninstall --ignore-not-found hello-world

# Check the behaviour without `--ignore-not-found`
./bin/helm uninstall --dry-run hello-world
./bin/helm uninstall hello-world

Before

➜  helm git:(main) helm install hello-world examples/hello-world
NAME: hello-world
LAST DEPLOYED: Mon May 13 14:20:38 2024
NAMESPACE: helm-12968
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace helm-12968 -l "app.kubernetes.io/name=hello-world,app.kubernetes.io/instance=hello-world" -o jsonpath="{.items[0].metadata.name}")
  export CONTAINER_PORT=$(kubectl get pod --namespace helm-12968 $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl --namespace helm-12968 port-forward $POD_NAME 8080:$CONTAINER_PORT
➜  helm git:(main) ./bin/helm uninstall --dry-run --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(main) ./bin/helm uninstall --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(main) ./bin/helm uninstall --dry-run --ignore-not-found hello-world
Error: release: not found
➜  helm git:(main) ./bin/helm uninstall --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(main) ./bin/helm uninstall --dry-run hello-world
Error: release: not found
➜  helm git:(main) ./bin/helm uninstall hello-world
Error: uninstall: Release not loaded: hello-world: release: not found

After

➜  helm git:(helm-uninstall-dry-run) helm install hello-world examples/hello-world
NAME: hello-world
LAST DEPLOYED: Mon May 13 14:16:46 2024
NAMESPACE: helm-12968
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace helm-12968 -l "app.kubernetes.io/name=hello-world,app.kubernetes.io/instance=hello-world" -o jsonpath="{.items[0].metadata.name}")
  export CONTAINER_PORT=$(kubectl get pod --namespace helm-12968 $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl --namespace helm-12968 port-forward $POD_NAME 8080:$CONTAINER_PORT
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall --dry-run --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall --dry-run --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall --ignore-not-found hello-world
release "hello-world" uninstalled
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall --dry-run hello-world
Error: release: not found
➜  helm git:(helm-uninstall-dry-run) ./bin/helm uninstall hello-world
Error: uninstall: Release not loaded: hello-world: release: not found

pkg/action/uninstall.go Outdated Show resolved Hide resolved
sjeandeaux and others added 2 commits May 13, 2024 20:17
Co-authored-by: Eddy Moulton <eddy@moulton.com.au>
Signed-off-by: Stephane Jeandeaux <sjeandeaux@users.noreply.github.com>
Signed-off-by: Stephane Jeandeaux <stephane.jeandeaux@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants