Skip to content

Hook delete policy not honored for preceding resource on a failure #3714

Closed

Description

@mtheck

I have two jobs configured in pre-upgrade hook which both have hook-succeeded,hook-failed as the delete policy.

If both jobs succeed they are properly deleted. But if the second job is failing (and obviously the first has succeeded), the first job is not deleted.

Documentation about hooks being not very precise, I don't know is this should be the expected behavior, but this is not what I would expect intuitively.

Here a simple template that can be used to easily reproduce it with the latest version (2.8.2):

apiVersion: batch/v1
kind: Job
metadata:
  name: test-hook-1
  annotations:
    helm.sh/hook: pre-upgrade
    helm.sh/hook-weight: "1"
    helm.sh/hook-delete-policy: hook-succeeded,hook-failed
spec:
  backoffLimit: 1
  template:
    metadata:
      name: test-hook-1
    spec:
      restartPolicy: Never
      containers:
      - name: hook-script
        image: quay.io/coreos/hyperkube:v1.9.4_coreos.1
        command:
          - bash
          - -c
          - exit 0
---
apiVersion: batch/v1
kind: Job
metadata:
  name: test-hook-2
  annotations:
    helm.sh/hook: pre-upgrade
    helm.sh/hook-weight: "2"
    helm.sh/hook-delete-policy: hook-succeeded,hook-failed
spec:
  template:
    metadata:
      name: test-hook-2
    spec:
      restartPolicy: Never
      containers:
      - name: hook-script
        image: quay.io/coreos/hyperkube:v1.9.4_coreos.1
        command:
          - bash
          - -c
          - exit 1

Activity

  1. lentil1016 commented on Mar 22, 2018

    @lentil1016
    Contributor

    https://github.com/kubernetes/helm/blob/48e703997016f3edeb4f0b90e6cfdb3456ce3db0/pkg/tiller/release_server.go#L359-L373

    If any hook failed, tiller will delete this single hook then return at L372. Which makes other hooks' delete policy trivial.

  2. lentil1016 commented on Mar 22, 2018

    @lentil1016
    Contributor

    @DoctorZK sorry for bothering. Any chance of getting some eyes on this? Is that make sense to delete previous succeeded hooks with hook-delete-policy: hook-succeeded annotation before delete the failed hook and return err?

  3. consideRatio commented on Apr 19, 2018

    @consideRatio
    Contributor

    /kind bug

  4. added
    bug
    on Apr 19, 2018
  5. bounddog commented on Jun 29, 2018

    @bounddog

    I hit this issue with v2.7.2

  6. bacongobbler commented on Dec 9, 2019

    @bacongobbler
    Member

    Closing due to inactivity. Please open a new ticket against Helm 3 if this issue persists. Thanks!

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

    bugquestion/support

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions