diff --git a/docs/TektonConfig.md b/docs/TektonConfig.md index 6627f4f0c8..8a83e5548b 100644 --- a/docs/TektonConfig.md +++ b/docs/TektonConfig.md @@ -533,6 +533,7 @@ The following fields are supported in `deployment` * `template` * `spec` * `affinity` - replaces the existing Affinity with this, if not empty + * `priorityClassName` - replaces the existing PriorityClassName with this, if not empty * `nodeSelector` - replaces the existing NodeSelector with this, if not empty * `tolerations` - replaces the existing tolerations with this, if not empty * `topologySpreadConstraints` - replaces the existing TopologySpreadConstraints with this, if not empty @@ -563,6 +564,7 @@ The following fields are supported in `StatefulSet` * `template` * `spec` * `affinity` - replaces the existing Affinity with this, if not empty + * `priorityClassName` - replaces the existing PriorityClassName with this, if not empty * `nodeSelector` - replaces the existing NodeSelector with this, if not empty * `tolerations` - replaces the existing tolerations with this, if not empty * `topologySpreadConstraints` - replaces the existing TopologySpreadConstraints with this, if not empty diff --git a/pkg/reconciler/common/testdata/test-additional-options-test-deployment.yaml b/pkg/reconciler/common/testdata/test-additional-options-test-deployment.yaml index 62985072a2..2a15dda3f3 100644 --- a/pkg/reconciler/common/testdata/test-additional-options-test-deployment.yaml +++ b/pkg/reconciler/common/testdata/test-additional-options-test-deployment.yaml @@ -64,7 +64,7 @@ spec: creationTimestamp: null labels: app.kubernetes.io/name: controller - operator.tekton.dev/deployment-spec-applied-hash: dd069273de050a47c5552fd79a70d4c3 + operator.tekton.dev/deployment-spec-applied-hash: 1704bb3edd32937a1659b4d42c9f1669 spec: affinity: nodeAffinity: @@ -77,6 +77,7 @@ spec: - ssd - nvme - ramdisk + priorityClassName: test serviceAccountName: tekton-pipelines-controller nodeSelector: zone: east diff --git a/pkg/reconciler/common/testdata/test-additional-options-test-statefulsets.yaml b/pkg/reconciler/common/testdata/test-additional-options-test-statefulsets.yaml index 886c652b96..1d38961fbb 100644 --- a/pkg/reconciler/common/testdata/test-additional-options-test-statefulsets.yaml +++ b/pkg/reconciler/common/testdata/test-additional-options-test-statefulsets.yaml @@ -30,6 +30,7 @@ spec: - ssd - nvme - ramdisk + priorityClassName: test containers: - args: - --mode=production diff --git a/pkg/reconciler/common/transformer_additional_options.go b/pkg/reconciler/common/transformer_additional_options.go index f7cafa41a3..ed4021f17a 100644 --- a/pkg/reconciler/common/transformer_additional_options.go +++ b/pkg/reconciler/common/transformer_additional_options.go @@ -256,6 +256,11 @@ func (ot *OptionsTransformer) updateDeployments(u *unstructured.Unstructured) er targetDeployment.Spec.Template.Spec.Affinity = deploymentOptions.Spec.Template.Spec.Affinity } + // update PriorityClassName + if deploymentOptions.Spec.Template.Spec.PriorityClassName != "" { + targetDeployment.Spec.Template.Spec.PriorityClassName = deploymentOptions.Spec.Template.Spec.PriorityClassName + } + // update node selectors if len(deploymentOptions.Spec.Template.Spec.NodeSelector) > 0 { targetDeployment.Spec.Template.Spec.NodeSelector = deploymentOptions.Spec.Template.Spec.NodeSelector @@ -441,6 +446,12 @@ func (ot *OptionsTransformer) updateStatefulSets(u *unstructured.Unstructured) e targetStatefulSet.Spec.Template.Spec.Affinity = statefulSetOptions.Spec.Template.Spec.Affinity } + // update priorityClassName + if statefulSetOptions.Spec.Template.Spec.PriorityClassName != "" { + targetStatefulSet.Spec.Template.Spec.PriorityClassName = statefulSetOptions.Spec.Template.Spec.PriorityClassName + + } + // update node selectors if len(statefulSetOptions.Spec.Template.Spec.NodeSelector) > 0 { targetStatefulSet.Spec.Template.Spec.NodeSelector = statefulSetOptions.Spec.Template.Spec.NodeSelector diff --git a/pkg/reconciler/common/transformer_additional_options_test.go b/pkg/reconciler/common/transformer_additional_options_test.go index a1a0b8bb32..7955a30d0a 100644 --- a/pkg/reconciler/common/transformer_additional_options_test.go +++ b/pkg/reconciler/common/transformer_additional_options_test.go @@ -155,6 +155,7 @@ func TestExecuteAdditionalOptionsTransformer(t *testing.T) { }, }, }, + PriorityClassName: "test", Volumes: []corev1.Volume{ { Name: "my-custom-logs", @@ -334,6 +335,7 @@ func TestExecuteAdditionalOptionsTransformer(t *testing.T) { }, }, }, + PriorityClassName: "test", Volumes: []corev1.Volume{ { Name: "my-custom-logs",