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

inheritFrom ignored when getting pod from shared-library with libraryResource

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

      Scenario 0:

      I have a custom pod defined on my shared-library that I usualy use for some pipelines.

      pipeline{
          agent {
              kubernetes {
                  yaml libraryResource("kubernetes/pod/custom-pod.yaml")
                  defaultContainer 'jnlp'
              }
        } 

      Result: custom-pod runs as expected.

      Scenario 1:
      There is a pipeline where I need to define a ephemeral-storage request. I didn't want to create another custom pod, so I wanted to resuse the custom-pod and merged the changes I needed using the inheritFrom attribute from kubernetes-plugin.

      pipeline{
          agent {
              kubernetes {
                  inheritFrom libraryResource("kubernetes/pod/custom-pod.yaml")
                  yaml '''
                      spec:
                        containers:
                          - name: jnlp
                            resources:
                              requests:
                                ephemeral-storage: "16Gi"
                      '''
                  defaultContainer 'jnlp'
              }
          }

      Result: inheritFrom is ignored. instead the kubernetes default template is merged with the yaml defined.

          [JENKINS-72818] inheritFrom ignored when getting pod from shared-library with libraryResource

          viriatis created issue -
          viriatis made changes -
          Description Original: *Scenario 0:*

          I have a custom pod defined on my shared-library that I usualy use for some pipelines.


          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      yaml libraryResource("com/desigual/kubernetes/pod/custom-pod.yaml")
                      defaultContainer 'jnlp'
                  }
            } {code}
          Result: custom-pod runs as expected.

          *Scenario 1:*
          There is a pipeline where I need to define a ephemeral-storage request. I didn't want to create another custom pod, so I wanted to resuse the custom-pod and merged the changes I needed using the inheritFrom attribute from kubernetes-plugin.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      inheritFrom libraryResource("com/desigual/kubernetes/pod/custom-pod.yaml")
                      yaml '''
                          spec:
                            containers:
                              - name: jnlp
                                resources:
                                  requests:
                                    ephemeral-storage: "16Gi"
                          '''
                      yamlMergeStrategy merge()
                      defaultContainer 'jnlp'
                  }
              }{code}
          Result: inheritFrom is ignored. instead the kubernetes default template is merged with the yaml defined.
          New: *Scenario 0:*

          I have a custom pod defined on my shared-library that I usualy use for some pipelines.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      yaml libraryResource("kubernetes/pod/custom-pod.yaml")
                      defaultContainer 'jnlp'
                  }
            } {code}
          Result: custom-pod runs as expected.

          *Scenario 1:*
          There is a pipeline where I need to define a ephemeral-storage request. I didn't want to create another custom pod, so I wanted to resuse the custom-pod and merged the changes I needed using the inheritFrom attribute from kubernetes-plugin.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      inheritFrom libraryResource("kubernetes/pod/custom-pod.yaml")
                      yaml '''
                          spec:
                            containers:
                              - name: jnlp
                                resources:
                                  requests:
                                    ephemeral-storage: "16Gi"
                          '''
                      yamlMergeStrategy merge()
                      defaultContainer 'jnlp'
                  }
              }{code}
          Result: inheritFrom is ignored. instead the kubernetes default template is merged with the yaml defined.
          viriatis made changes -
          Description Original: *Scenario 0:*

          I have a custom pod defined on my shared-library that I usualy use for some pipelines.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      yaml libraryResource("kubernetes/pod/custom-pod.yaml")
                      defaultContainer 'jnlp'
                  }
            } {code}
          Result: custom-pod runs as expected.

          *Scenario 1:*
          There is a pipeline where I need to define a ephemeral-storage request. I didn't want to create another custom pod, so I wanted to resuse the custom-pod and merged the changes I needed using the inheritFrom attribute from kubernetes-plugin.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      inheritFrom libraryResource("kubernetes/pod/custom-pod.yaml")
                      yaml '''
                          spec:
                            containers:
                              - name: jnlp
                                resources:
                                  requests:
                                    ephemeral-storage: "16Gi"
                          '''
                      yamlMergeStrategy merge()
                      defaultContainer 'jnlp'
                  }
              }{code}
          Result: inheritFrom is ignored. instead the kubernetes default template is merged with the yaml defined.
          New: *Scenario 0:*

          I have a custom pod defined on my shared-library that I usualy use for some pipelines.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      yaml libraryResource("kubernetes/pod/custom-pod.yaml")
                      defaultContainer 'jnlp'
                  }
            } {code}
          Result: custom-pod runs as expected.

          *Scenario 1:*
          There is a pipeline where I need to define a ephemeral-storage request. I didn't want to create another custom pod, so I wanted to resuse the custom-pod and merged the changes I needed using the inheritFrom attribute from kubernetes-plugin.
          {code:java}
          pipeline{
              agent {
                  kubernetes {
                      inheritFrom libraryResource("kubernetes/pod/custom-pod.yaml")
                      yaml '''
                          spec:
                            containers:
                              - name: jnlp
                                resources:
                                  requests:
                                    ephemeral-storage: "16Gi"
                          '''
                      defaultContainer 'jnlp'
                  }
              }{code}
          Result: inheritFrom is ignored. instead the kubernetes default template is merged with the yaml defined.

          Roi added a comment -

          viriatis I have the same issue. I figure that inheritFrom expects a PodTemplate, and we're passing a YAML string.
          If only we could find a way to create a PodTemplate object out of this string.

          Roi added a comment - viriatis I have the same issue. I figure that inheritFrom expects a PodTemplate, and we're passing a YAML string. If only we could find a way to create a PodTemplate object out of this string.

            Unassigned Unassigned
            viriatis viriatis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: