Skip to content

Tilt helm extension fails to cleanup resources and fails to restart with kyverno #543

@bb03

Description

@bb03

Setup:
Kubernetes cluster: kind v0.20.0 go1.20.5 linux/amd64
Python version: Python 3.9.16

With this file as kyverno-test.tilt

load("ext://helm_resource", "helm_repo", "helm_resource")
load("ext://namespace", "namespace_create")

namespace_create("kyverno")

k8s_resource(
    new_name = "kyverno-ns",
    labels = ["kyverno"],
    objects = ["kyverno:namespace"],
)

helm_repo(
    name = "kyverno",
    url = "https://kyverno.github.io/kyverno/",
    labels = ["kyverno"],
)

helm_resource(
    name = "kyverno-deployment",
    chart = "kyverno/kyverno",
    labels = ["kyverno"],
    resource_deps = [
        "kyverno",
        "kyverno-ns",
    ],
    namespace = "kyverno",
)

Repro steps
I ran the following commands in this order

  1. kind delete cluster && kind create cluster
  2. tilt up -f kyverno-test.tilt
  3. Ctrl-c to exit tilt from the legacy terminal
  4. tilt down -f kyverno-test.tilt
  5. tilt up -f kyverno-test.tilt

On step 4 I'm seeing the following issue

Loading Tiltfile at: <path>/tilt/kyverno/kyverno-test.tilt
Successfully loaded Tiltfile (358.015303ms)
Not deleting namespaces: kyverno
Run with --delete-namespaces to delete namespaces as well.
Running cmd: python3  <path>/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-delete-helper.py
Running cmd: helm uninstall --namespace kyverno kyverno-deployment
Error: Deleting k8s entities for cmd: python3 <path>/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-delete-helper.py: exit status 137

And then on step 5 I see this

kyverno-depl… │ 
kyverno-depl… │ Initial Build
kyverno-depl… │ STEP 1/1 — Deploying
kyverno-depl… │      Running cmd: python3 <path>/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-apply-helper.py
kyverno-depl… │      Running cmd: ['helm', 'upgrade', '--install', '--namespace', 'kyverno', 'kyverno-deployment', 'kyverno/kyverno']
kyverno-depl… │      Error: UPGRADE FAILED: "kyverno-deployment" has no deployed releases
kyverno-depl… │      Traceback (most recent call last):
kyverno-depl… │        File "<path>/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-apply-helper.py", line 71, in <module>
kyverno-depl… │          subprocess.check_call(install_cmd, stdout=sys.stderr)
kyverno-depl… │        File "/opt/pyenv/versions/3.9.16/lib/python3.9/subprocess.py", line 373, in check_call
kyverno-depl… │          raise CalledProcessError(retcode, cmd)
kyverno-depl… │      subprocess.CalledProcessError: Command '['helm', 'upgrade', '--install', '--namespace', 'kyverno', 'kyverno-deployment', 'kyverno/kyverno']' returned non-zero exit status 1.
kyverno-depl… │ 
kyverno-depl… │ ERROR: Build Failed: apply command exited with status 1

Adding --delete-namespaces to the delete command - step 4, resulted in

 % tilt down -f kyverno-test.tilt --delete-namespaces
Loading Tiltfile at: <path>/kyverno-test.tilt
Successfully loaded Tiltfile (357.493223ms)
Deleting kubernetes objects:
→ Namespace/kyverno
Running cmd: python3 <path>/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-delete-helper.py
Running cmd: helm uninstall --namespace kyverno kyverno-deployment
Error: warning: Hook pre-delete kyverno/templates/hooks/pre-delete.yaml failed: 1 error occurred:
	* jobs.batch "kyverno-deployment-hook-pre-delete" is forbidden: unable to create new content in namespace kyverno because it is being terminated

Expected outcomes
I would like to understand why the helm-delete-helper failed to delete the kyverno resourcess, and if possible, can tilt handle these types of errors so that all resources created by a tilt up get cleaned up. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions