Skip to content

priorityClassName specified in yaml not appplied with yamlMergeStrategy: merge #2813

@dadurex

Description

@dadurex

Jenkins and plugins versions report

Environment
Jenkins: 2.541.1
OS: Linux - 6.8.0-100-generic
Java: 25.0.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
configuration-as-code:2037.v8e5349845172
...
kubernetes:4423.vb_59f230b_ce53
kubernetes-client-api:7.3.1-256.v788a_0b_787114
kubernetes-credentials:207.v492f58828b_ed
...

What Operating System are you using (both controller, and any agents involved in the problem)?

All deployed on RKE2 kubernetes cluster with version v1.32.7+rke2r1.
Jenkins controller version: 2.541.1-lts-jdk25-3
Agents base on: inbound-agent:3355.v388858a_47b_33-12-jdk25

Jenkins image is prebuilt with by installing plugins. Agent images are patched by custom CA etc.

Reproduction steps

  1. Create pod templates in casc which will inherit from other as below:
              - name: base
                label: base
                containers:
                - name: jnlp
                  image: some.repository/agent:1
                  ttyEnabled: true
                  alwaysPullImage: true
                  command: "/home/build/entrypoint.sh"
                  args: "/bin/bash -c \"jenkins-agent && cat\""
                imagePullSecrets:
                  - name: docker-registry

              - name: custom
                label: custom
                inheritFrom: base
                yamlMergeStrategy: merge
                yaml: |-
                  spec:
                    nodeSelector:
                      role: deployment
                    priorityClassName: high-priority
  1. Create pipeline which will run on pod based on label custom: Example pipeline definition:
node('custom') {
  sh "whoami"
}
  1. Review pod definition created for above pipeline

Expected Results

Expected is that created POD template definition will contain:

  • nodeSelector with required filter
  • priorityClassName with required value

Actual Results

POD template contain nodeSelector with proper filter but priorityClassName is not added to pod template which result that priority assigned to pod is default - 0.

Anything else?

yamlMergeStrategy: merge does not merge ALL fields from yaml - merge only fields which are covered in code.

https://github.com/jenkinsci/kubernetes-plugin/blob/4423.vb_59f230b_ce53/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java#L328-L342

There is need to add function which will cover merge of priorityClassName field.

Are you interested in contributing a fix?

Yes.

Suggestion - allow to not only specify it in yaml section but as variable - same as nodeSelector, volumes and many others options.

PR prepared: #2814

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions