Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when linting 'Job' that uses generateName instead of name in metadata #9488

Closed
ganto opened this issue Mar 15, 2021 · 2 comments · May be fixed by #9644
Closed

Error when linting 'Job' that uses generateName instead of name in metadata #9488

ganto opened this issue Mar 15, 2021 · 2 comments · May be fixed by #9644

Comments

@ganto
Copy link

ganto commented Mar 15, 2021

Environment

Output of helm version:

version.BuildInfo{Version:"v3.5.3", GitCommit:"041ce5a2c17a58be0fcd5f5e16fb3e7e95fea622", GitTreeState:"dirty", GoVersion:"go1.15.8"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"02c110006bfef4ba53fa5042bb9eae170dd3dc1c", GitTreeState:"clean", BuildDate:"2021-01-09T01:48:22Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0+e405995", GitCommit:"e40599583c035332dc295d9ea2c52e7635d48a6e", GitTreeState:"clean", BuildDate:"2021-02-05T01:23:59Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): OpenShift 4.6.17

Problem

When linting a Helm chart that defines a Job resource (batch/v1) which defines metadata.generateName instead of metadata.name linting fails with an error:

[ERROR] templates/job.yaml: object name must be between 0 and 253 characters: ""

The resource definition looks like this:

apiVersion: batch/v1
kind: Job
metadata:
  generateName: test-
spec:
  template:
    spec:
      containers:
        - command:
          - "/bin/sh"
          - "-c"
          - |
            echo Hello World
          image: "alpine:latest"
          name: "echo"
      restartPolicy: "OnFailure"

According to the documentation generateName can be used instead of name:

generateName
GenerateName is an optional prefix, used by the server, to generate a
unique name ONLY IF the Name field has not been provided. If this field is
used, the name returned to the client will be different than the name
passed. This value will also be combined with a unique suffix. The provided
value has the same validation rules as the Name field, and may be truncated
by the length of the suffix required to make the value unique on the
server.

If this field is specified and the generated name exists, the server will
NOT return a 409 - instead, it will either return 201 Created or 500 with
Reason ServerTimeout indicating a unique name could not be found in the
time allotted, and the client should retry (optionally after the time
indicated in the Retry-After header).

Applied only if Name is not specified. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency

Source: ObjectMeta documentation

In our case we are using this in combination with ArgoCD sync hooks.

According to the documentation it seems that generateName might be valid for other resources as well. Is there a reason why this is not supported in Helm? If so, would it maybe be possible to change this to a warning instead of an error?

Work-around

The current work-around is to use an older helm version (e.g. 3.2.4) where this resource doesn't fail linting.

@jdolitsky
Copy link
Contributor

Here is some background context: #3348

@github-actions
Copy link

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.

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

Successfully merging a pull request may close this issue.

2 participants