GoogleContainerTools / GoogleContainerTools/skaffold

Helm: error adding label to runtime object: patching resource default jobs.batch

Open
#5,471 3 comments 0 reactions 0 assignees View on GitHub
area/labels deploy/helm kind/bug priority/p3
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

### Expected behavior

I have a helm chart that create a k8s job:

```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: "my-job"
annotations:
helm.sh/hook: pre-install,pre-upgrade
helm.sh/hook-delete-policy: hook-succeeded
spec:
template:
spec:
restartPolicy: Never
containers:
- name: "my-job-container"
image: "{{ .Values.image }}"
command: ["echo hello"]
```

When using `skaffold run` or `skaffold dev`, I would expect no warnings.

### Actual behavior

The deployment goes well, however the following warning is printed:

```
level=warning msg="error adding label to runtime object: patching resource default/\"my-job\": jobs.batch \"my-job\" not found"
```

This is happening because helm deletes the job once it succeeds, because we have the `helm.sh/hook-delete-policy: hook-succeeded` annotation. Skaffold tries to patch this object, but fails since it no longer exists.

Maybe we should check if `helm.sh/hook-delete-policy` annotation is set, and depending on its value, ignore the error.

### Information

- Skaffold version: v1.20.0
- Operating system: Windows 10 Pro
- Contents of skaffold.yaml: Just a simple skaffold file, with a local helm chart with a job like the one above

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.