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

Invalid merge of `command` & `args` fields in PodTemplate

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • Latest kubernetes-plugin, master branch - commit 46e33be7aef41862bd6c5cf9ecbbf6135ff052d0
    • 4203.v1dd44f5b_1cf9

      When parent PodTemplate specifies command & args for container and child container doesn't, then these fields are overridden by empty values. This is current behavior:

        15.505 [id=19]    FINEST    o.c.j.p.k.PodTemplateUtils#combine: Combining pods, parent: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata: {}
      spec:
        containers:
        - args:
          - "argument1"
          - "argument2"
          command:
          - "parent command"
          image: "parent-image"
          name: "docker"
       
      template: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata: {}
      spec:
        containers:
        - name: "docker"
          resources:
            requests:
              cpu: "300m"
              memory: "300Mi"  
      
      15.522 [id=19]    FINEST    o.c.j.p.k.PodTemplateUtils#combine
      Pods combined: ---
      apiVersion: "v1"
      kind: "Pod"
      metadata: {}
      spec:
        containers:
        - image: "parent-image"
          name: "docker"
          resources:
            requests:
              cpu: "300m"
              memory: "300Mi"
          workingDir: "/home/jenkins/agent" 

      In the pods combined we expect command and args to be present.

      This issue occurs because of null check at this line. this.args is initialized as an empty list by default in Container class, so it's not null. That's why this check is always false.

      I suggest to use getArgs().isEmpty() to check if args are present in container template.

       

            moleus Pavel
            moleus Pavel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: