Skip to content

Hook delete policy of "hook-failed" not honored for preceding resource on a failure #10279

Closed

Description

@tobalsgithub

Output of helm version: version.BuildInfo{Version:"v3.6.0", GitCommit:"7f2df6467771a75f5646b7f12afb408590ed1755", GitTreeState:"clean", GoVersion:"go1.16.3"}

Output of kubectl version: Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:50:19Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.17-eks-087e67", GitCommit:"087e67e479962798594218dc6d99923f410c145e", GitTreeState:"clean", BuildDate:"2021-07-31T01:39:55Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): AWS / EKS

This looks to be the same issue as this which was closed due to inactivity. That issue is for on helm 2, but I believe the same issue persists on helm 3.

Let's say I have 2 Job resources that i want to run during the helm test hook. I set both of them with "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed".

Now if both succeed, they are both deleted. Perfect.

But, if the first one succeeds and the second one fails, then the first one is never deleted.

From looking at the code, it looks like if all hook resources succeed, we delete all of the ones with hook-succeeded at the very end of the process. But, if one of them fails, we only delete that 1 resource and immediately return with the error.

This isn't what I would expect, and believe it's probably not what most people would want.

In the case of Job resources specifically, this isn't much of an issue cause we can just set the ttlSecondsAfterFinished. But for things like Deployment resources, it causes more problems cause you end up with running pods sticking around when you don't want them to.

Here's a relatively simple demonstration.

apiVersion: batch/v1
kind: Job
metadata:
  name: "successful-job"
  labels:
    "app": "hook-testing"
  annotations:
    "helm.sh/hook": "test"
    "helm.sh/hook-weight": "1"
    "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed"
spec:
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: "successful-job"
        command:
          - bash
          - -c 
          - exit 0
        image: bash:latest
---
apiVersion: batch/v1
kind: Job
metadata:
  name: "failure-job"
  labels:
    "app": "hook-testing"
  annotations:
    "helm.sh/hook": "test"
    "helm.sh/hook-weight": "2"
    "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed"
spec:
  backoffLimit: 0
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: "failure-job"
        command:
          - bash
          - -c 
          - exit 1
        image: bash:latest
---
apiVersion: v1
kind: Pod
metadata:
  name: "non-hook-pod"
  labels:
    "app": "hook-testing"
spec:
  containers:
  - name: "sleeping-pod"
    command:
      - bash
      - -c 
      -  while :; do sleep 1; done
    image: bash:latest

Activity

  1. added
    bug
    on Nov 3, 2021
  2. zonggen commented on Nov 9, 2021

    @zonggen
    Member

    I can reproduce the behavior on:
    version.BuildInfo{Version:"v3.7.1", GitCommit:"1d11fcb5d3f3bf00dbe6fe31b8412839a96b3dc4", GitTreeState:"dirty", GoVersion:"go1.16.6"}, Cloud Provider/Platform (AKS, GKE, Minikube etc.): Minikube.

    Steps to reproduce:

    • helm create issue-10279
    • Modify tests/test-connection.yaml with above job definition.
    • helm install issue-10279 .
    • helm test issue-10279
  3. github-actions commented on Feb 8, 2022

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  4. himanshu-trilio commented on Mar 28, 2022

    @himanshu-trilio

    hit the same issue and still reproducible

  5. himanshu-trilio commented on Mar 28, 2022

    @himanshu-trilio

    can we reopen this ticket and get this bug resolved? @bacongobbler

  6. bacongobbler commented on Mar 28, 2022

    @bacongobbler
    Member

    Hi @himanshu-trilio, we’d welcome a patch to fix this behaviour. Please feel free to submit something.

  7. himanshu-trilio commented on Apr 4, 2022

    @himanshu-trilio

    @bacongobbler patch fix for the above issue is created by @prafull01 . can we get that reviewed and merged quick?

  8. prafull01 commented on Apr 6, 2022

    @prafull01

    @bacongobbler I have raised a PR to fix this behaviour. Kindly review.

  9. github-actions commented on Jul 6, 2022

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  10. fschmied commented on Oct 30, 2022

    @fschmied

    @bacongobbler @hickeyma Would it be possible to reopen this issue (and mark it not stale) as long as the bug is still not fixed? That would enable us to subscribe to the issue in order to be notified when it is fixed.

  11. github-actions commented on Feb 7, 2023

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  12. jerryguowei commented on Feb 29, 2024

    @jerryguowei

    Is there any progress on this issue. its causing the resource not deleted when any failures in my cluster.

  13. jtackaberry commented on May 29, 2024

    @jtackaberry

    Is there any progress on this issue. its causing the resource not deleted when any failures in my cluster.

    AFAICT #11334 is the fix but that has stalled out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugin progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions