Skip to content

Commit

Permalink
Add support to update PriorityClassName via options
Browse files Browse the repository at this point in the history
This patch sdds support to update PriorityClassName via options in Deployment
and StatefulSet, also updates TektonConfig doc

Fixes: #1835

Signed-off-by: Shiv Verma <shverma@redhat.com>
  • Loading branch information
pratap0007 authored and tekton-robot committed Nov 13, 2023
1 parent a698748 commit e5c4b7e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/TektonConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -77,6 +77,7 @@ spec:
- ssd
- nvme
- ramdisk
priorityClassName: test
serviceAccountName: tekton-pipelines-controller
nodeSelector:
zone: east
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
- ssd
- nvme
- ramdisk
priorityClassName: test
containers:
- args:
- --mode=production
Expand Down
11 changes: 11 additions & 0 deletions pkg/reconciler/common/transformer_additional_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/reconciler/common/transformer_additional_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func TestExecuteAdditionalOptionsTransformer(t *testing.T) {
},
},
},
PriorityClassName: "test",
Volumes: []corev1.Volume{
{
Name: "my-custom-logs",
Expand Down Expand Up @@ -334,6 +335,7 @@ func TestExecuteAdditionalOptionsTransformer(t *testing.T) {
},
},
},
PriorityClassName: "test",
Volumes: []corev1.Volume{
{
Name: "my-custom-logs",
Expand Down

0 comments on commit e5c4b7e

Please sign in to comment.