helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

podTemplate helper does not allow setting command: "" in container spec

Open bartsqueezy opened this issue 3 years ago • 3 comments

Describe the bug Setting the following in values.yaml...

additionalAgents:
  newagent:
    podName: newagent
    sideContainerName: jnlp
    command: ""
    args: ""

Results in the following under /configureClouds/

Screen Shot 2021-08-06 at 5 33 20 PM

As you can see, Command to run is being set to sleep, when it should be empty.

Version of Helm and Kubernetes:

Helm Version: v3.6.1

Kubernetes Version: v1.19.9

Which version of the chart: 3.5.9

What happened: The jnlp container in the pod template has Command to run set to sleep.

What you expected to happen: The jnlp container in the pod template should have Command to run set to no value/empty string.

How to reproduce it (as minimally and precisely as possible):

  1. Add the following to your values.yaml:
    additionalAgents:
      newagent:
        podName: newagent
        sideContainerName: jnlp
        command: ""
        args: ""
    
  2. helm install
  3. Check jenkins-jenkins-jcasc-config ConfigMap value. Verify that command is NOT set to an empty string (e.g. command:
  4. Go https:///configureClouds/
  5. Expand Pod Template Details for the "newagent" pod template
  6. Verify that Command to run is set to sleep

Anything else we need to know:

I think the issue is that the jenkins.casc.podTemplate helper method is not wrapping {{ .Values.agent.command }} with double quotes (e.g. "{{ .Values.agent.command }}"). I assume this is why setting command: "" in values.yaml results in command: in the jenkins-jenkins-jcasc-config ConfigMap. Additionally, if no value is provided to command, the Kubernetes plugin for Jenkins will default it to sleep.

This issue most notably impacts Windows versions of the jenkins/inbound-agent Docker image. The agent process does not properly launch as the default command is set to sleep.

bartsqueezy avatar Aug 06 '21 22:08 bartsqueezy

I think the issue is that the jenkins.casc.podTemplate helper method is not wrapping {{ .Values.agent.command }} with double quotes (e.g. "{{ .Values.agent.command }}"). I assume this is why setting command: "" in values.yaml results in command: in the jenkins-jenkins-jcasc-config ConfigMap. Additionally, if no value is provided to command, the Kubernetes plugin for Jenkins will default it to sleep.

@bartsqueezy Could you try quoting the command and check if that works? I suspect that we can't change it as empty would result in the default of the Kubernetes plugin being used.

torstenwalter avatar Aug 11 '21 10:08 torstenwalter

Sure, let me give it a test and get back to you.

bartsqueezy avatar Aug 11 '21 19:08 bartsqueezy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 11:04 stale[bot]

I think the issue is that the jenkins.casc.podTemplate helper method is not wrapping {{ .Values.agent.command }} with double quotes (e.g. "{{ .Values.agent.command }}"). I assume this is why setting command: "" in values.yaml results in command: in the jenkins-jenkins-jcasc-config ConfigMap. Additionally, if no value is provided to command, the Kubernetes plugin for Jenkins will default it to sleep.

@bartsqueezy Could you try quoting the command and check if that works? I suspect that we can't change it as empty would result in the default of the Kubernetes plugin being used.

For what it's worth I also ran into this issue with the sleep command being added. Quoting it seems to work.

agent:
  command: '""'

TeamTeaTime avatar Oct 06 '22 17:10 TeamTeaTime