helm / helm/helm

Helm4 upgrade with dry-run and server-side enabled doesn't catch errors

Open
#31,505 10 comments 1 reaction 0 assignees View on GitHub
feature help wanted
Dominant language
Go
Stars
30.2k
Forks
7.8k
Avg merge
20h 58m
Merged PRs (30d)
36

Description

Hi.

Let's assume we have the following chart:
1) Chart.yaml
```yaml
apiVersion: v2
name: helm4-test
version: 1.0.0
```
2) templates/deployment.yaml
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: bash
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: bash
app.kubernetes.io/instance: bash
template:
metadata:
labels:
app.kubernetes.io/name: bash
app.kubernetes.io/instance: bash
spec:
resources:
requests:
memory: "100Mi"
limits:
memory: "200Mi"
containers:
- image: bash
imagePullPolicy: IfNotPresent
name: bash
command: ["bash", "-c", "echo 'Hello, World!'"]
restartPolicy: Always
```

This is wrong spec - `resources` block is placed not under container.

Run helm dry-run with server-side:
```shell
helm upgrade test -n default --dry-run=server --server-side=true --install .
```

Result: No errors.

What is expected?

I expected that `Helm4` should return error that `resources` is unknown field for `spec`.

Because if we run actual `upgrade` without dry-run, we will get the error:
```shell
╰─ helm upgrade test -n default --server-side=true --install .
Release "test" does not exist. Installing it now.
Error: failed to create typed patch object (default/bash; apps/v1, Kind=Deployment): .spec.template.spec.resources: field not declared in schema
```

Comparing to `kubectl`, if we use just `deployment.yaml` in apply command, it will catch the error:
```shell
╰─ kubectl apply --dry-run=server --server-side=true -f manifests.yaml
Error from server: failed to create typed patch object (default/bash; apps/v1, Kind=Deployment): .spec.template.spec.resources: field not declared in schema
╰─ kubectl apply --dry-run=server -f manifests.yaml
Error from server (BadRequest): error when creating "manifests.yaml": Deployment in version "v1" cannot be handled as a Deployment: strict decoding error: unknown field "spec.template.spec.resources"
```

Should `Helm4` with server-side work the same way?

Otherwise, `dry-run` doesn't catch such errors and it can be a surprise in actual install/upgrade.

Tested on `1.28` k8s server
Helm `4.0.0`

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.