Hi,
      We have set up podtemplates to facilitate the writing of jenkinsfile. Developers only have to override the values ​​when needed. However, this inheritance relationship does not work as indicated in the doc. In fact, the values ​​put in the jenkinsfile do not override the values ​​in the parent podtemplate.
      In the podtemplate I defined a "main" container based on an ubuntu image. In the jenkinsfile I defined a "main" container but based on a maven image. The pod was created with ubuntu and not maven. By activating the logs (org.csanchez.jenkins.plugins.kubernetes), it seems to me that the podtemplates are reversed. Because, I see in the parent the maven image and in the podtemplate the ubuntu image (see attaced log file).

          [JENKINS-70473] Contradiction in podTemplate inheritance

          There is no contradiction : UI fields always take precedence on what is defined by yaml.

          Vincent Latombe added a comment - There is no contradiction : UI fields always take precedence on what is defined by yaml.

          Zied added a comment - - edited

          Hi vlatombe
          This is not what is described in the doc with the maven example.
          https://plugins.jenkins.io/kubernetes/#plugin-content-inheritance

          Zied added a comment - - edited Hi vlatombe ,  This is not what is described in the doc with the maven example. https://plugins.jenkins.io/kubernetes/#plugin-content-inheritance

          Peter Loron added a comment -

          This behavior (yaml merge not overriding template being inherited from) is a new. Older versions of the plugin behaved differently.

          With plugin 3724.v0920c1e0ec69, I can override values (e.g. memory limit). With plugin 
          3900.va_dce992317b_4 or 3923.v294a_d4250b_91, the values specified in yaml do not override the values defined in the pod template. This is with 'yamlMergeStrategy: merge()' set.

          This is breaking a bunch of our pipelines. 

          Peter Loron added a comment - This behavior (yaml merge not overriding template being inherited from) is a new. Older versions of the plugin behaved differently. With plugin 3724.v0920c1e0ec69, I can override values (e.g. memory limit). With plugin  3900.va_dce992317b_4 or 3923.v294a_d4250b_91, the values specified in yaml do not override the values defined in the pod template. This is with 'yamlMergeStrategy: merge()' set. This is breaking a bunch of our pipelines. 

          Jeremy added a comment -

          Hi,

           

          I encountered the same issue when trying to override the jnlp container (to tailor its resource request/limit).
          It works using podTemplate/containerTemplate but not YAML.
          Playing with yamlMergeStrategy & inheritFrom was ineffective.

           

          I identified that at one point the controller configuration was always taking precedence over the YAML in the Jenkinsfile (after several nested template merges).
          The plugin version was 3743.v1fa_4c724c3b_7

          In org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder.build() #L293

          Pod pod = combine(template.getYamlsPod(), builder.endSpec().build());

          The YAML template from the Jenkinsfile is part of template.getYamlsPod(), while the controller config is part of builder.endSpec().build().
          The YAML from the Jenkinsfile is processed as the parent, not as the template

           

          I am not sure if reverting the 2 params solves the issue without side effects (it'll require in-depth testing) or if the bug is in fact somewhere else.

          More worrying: I found a test for jnlp override. It exists and it passes while IRL it does not work. I think the init of this test does not match our reality (jnlp customized at controller level with a containerTemplate)
          https://github.com/jenkinsci/kubernetes-plugin/blob/3743.v1fa_4c724c3b_7/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilderTest.java#L451

          it is consistent with what Vincent describes (assuming UI fields == containerTemplate), but not with the documentation.

          Regards,

           

          cc acontes 

          Jeremy added a comment - Hi,   I encountered the same issue when trying to override the jnlp container (to tailor its resource request/limit). It works using podTemplate/containerTemplate but not YAML. Playing with yamlMergeStrategy & inheritFrom was ineffective.   I identified that at one point the controller configuration was always taking precedence over the YAML in the Jenkinsfile (after several nested template merges). The plugin version was 3743.v1fa_4c724c3b_7 In org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder.build() #L293 Pod pod = combine(template.getYamlsPod(), builder.endSpec().build()); The YAML template from the Jenkinsfile is part of template.getYamlsPod(), while the controller config is part of builder.endSpec().build() . The YAML from the Jenkinsfile is processed as the parent, not as the template   I am not sure if reverting the 2 params solves the issue without side effects (it'll require in-depth testing) or if the bug is in fact somewhere else. More worrying: I found a test for jnlp override. It exists and it passes while IRL it does not work. I think the init of this test does not match our reality (jnlp customized at controller level with a containerTemplate) https://github.com/jenkinsci/kubernetes-plugin/blob/3743.v1fa_4c724c3b_7/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilderTest.java#L451 it is consistent with what Vincent describes (assuming UI fields == containerTemplate), but not with the documentation. Regards,   cc acontes  

            Unassigned Unassigned
            zandolsipsee Zied
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: