Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55094

"commands" and "args" are being defaulted using Kubernetes plugin

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • None

      We are using terraform and Jenkins configuration as yaml file to deploy Jenkins. When defining Kubernetes Pod templates, whether we set command and args to empty string or not providing it at all, after the deploying Jenkins or refreshing with new configuration, both values are being defaulted to:

       

      command: /bin/sh -c 
      args: cat
      

      This causes issues because each docker image has its own entrypoint or cmd and this overrides them. So now everytime we redeploy Jenkins we have to manually remove command and args within the Jenkins user interface.

      For example, the jnlp container requires to run a specific command defined in jenkins/jnlp-slave:3.23-1-alpine Dockerfile but those default value makes the container not to be able to communicate with Jenkins

       

      I believe this is the issue with the UI template: https://github.com/jenkinsci/kubernetes-plugin/blob/b1ba0de0fc1fcc46937ab5f984289ff7b5594cef/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly#L26

       

      I have created a question in stackoverflow but nobody replied: https://stackoverflow.com/questions/53625733/jenkins-kubernetes-plugin-defaults-command-and-args-to-bash-even-if-we-set-them

       

          [JENKINS-55094] "commands" and "args" are being defaulted using Kubernetes plugin

          This is now becoming painful, We have a nice configuration but each redeployment of Jenkins requires someone manually remove those commands/args

          Mohammad Norouzi added a comment - This is now becoming painful, We have a nice configuration but each redeployment of Jenkins requires someone manually remove those commands/args

          it's a bit strange... looks like when we go to Jenkins -> Manage Jenkins > Configure System and make some change and hit save, those text boxes get defaulted, if there is no command or args already for them

          Mohammad Norouzi added a comment - it's a bit strange... looks like when we go to Jenkins -> Manage Jenkins > Configure System and make some change and hit save, those text boxes get defaulted, if there is no command or args already for them

          This works fine from the UI, are you using config-as-code plugin ?

          Carlos Sanchez added a comment - This works fine from the UI, are you using config-as-code plugin ?

          csanchez Yes we're using config-as-code plugin and the values are defined in a yaml file which then will be imported. If there is no command/args defined in the file, what you see in the UI is those default values. This causes all the builds that resume after Jenkins is up will wait forever because the containers' command/args are not correct and therefore they don't function properly

           

          Thanks

           

          Mohammad Norouzi added a comment - csanchez Yes we're using config-as-code plugin and the values are defined in a yaml file which then will be imported. If there is no command/args defined in the file, what you see in the UI is those default values. This causes all the builds that resume after Jenkins is up will wait forever because the containers' command/args are not correct and therefore they don't function properly   Thanks  

          csanchez We're running into this now after moving back the stable jenkins chart after forking away a year ago, where now our agents are now being constructed through jcasc as opposed to xml. This default is killing our IaC flow (https://github.com/jenkinsci/kubernetes-plugin/blob/2f3c959591d6191891f2da1446c2b2a52db5c11c/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly#L26) and it seems passing an empty string in gets dropped somewhere in the process so I can't override the default with nothing

           

          Can we just make the default an empty command?

           

          Love the plugin btw, fabulous work!

          Aidan Moriarty added a comment - csanchez We're running into this now after moving back the stable jenkins chart after forking away a year ago, where now our agents are now being constructed through jcasc as opposed to xml. This default is killing our IaC flow ( https://github.com/jenkinsci/kubernetes-plugin/blob/2f3c959591d6191891f2da1446c2b2a52db5c11c/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/config.jelly#L26)  and it seems passing an empty string in gets dropped somewhere in the process so I can't override the default with nothing   Can we just make the default an empty command?   Love the plugin btw, fabulous work!

          admoriarty What version of kubernetes plugin and casc plugin are you using ? I am able to reproduce the behavior with CasC. But using an Empty string in the command solves this:

          jenkins:
            clouds:
            - kubernetes:
                name: "local1"
                templates:
                - containers:
                  - args: "^${computer.jnlpmac} ^${computer.name}"
                    command: ""
                    image: "jenkins/inbound-agent"
                    name: "jnlp"
                    ttyEnabled: true
                    workingDir: "/home/jenkins/agent"
                  hostNetwork: false
                  name: "testcommand"
                  yamlMergeStrategy: "override"
          

          Allan BURDAJEWICZ added a comment - admoriarty What version of kubernetes plugin and casc plugin are you using ? I am able to reproduce the behavior with CasC. But using an Empty string in the command solves this: jenkins: clouds: - kubernetes: name: "local1" templates: - containers: - args: "^${computer.jnlpmac} ^${computer.name}" command: "" image: "jenkins/inbound-agent" name: "jnlp" ttyEnabled: true workingDir: "/home/jenkins/agent" hostNetwork: false name: "testcommand" yamlMergeStrategy: "override"

            Unassigned Unassigned
            xbmono Mohammad Norouzi
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: