From 23a641f3f1bba4743a3493bad9af3d5ecedc5b0b Mon Sep 17 00:00:00 2001 From: sm43 Date: Tue, 10 Aug 2021 15:57:22 +0530 Subject: [PATCH] [OpenShift] fixes the disable affinity assistant configuration This is always true in case of openshift due to which user would not able to enable it. so this fixes by removing the defaulting in Operator CR and adding the field only when user adds it. By default, the value in configmap is false for kubernetes and will be changed to true for openshift which user can change if requires. Signed-off-by: Shivam Mukhade --- pkg/apis/operator/v1alpha1/tektonpipeline_defaults.go | 3 --- .../operator/v1alpha1/tektonpipeline_defaults_test.go | 1 - pkg/reconciler/openshift/tektonpipeline/extension.go | 9 +++++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/apis/operator/v1alpha1/tektonpipeline_defaults.go b/pkg/apis/operator/v1alpha1/tektonpipeline_defaults.go index a9a6b0b7c5..1a82990b42 100644 --- a/pkg/apis/operator/v1alpha1/tektonpipeline_defaults.go +++ b/pkg/apis/operator/v1alpha1/tektonpipeline_defaults.go @@ -27,9 +27,6 @@ func (tp *TektonPipeline) SetDefaults(ctx context.Context) { } func (p *PipelineProperties) setDefaults() { - if p.DisableAffinityAssistant == nil { - p.DisableAffinityAssistant = ptr.Bool(false) - } if p.DisableHomeEnvOverwrite == nil { p.DisableHomeEnvOverwrite = ptr.Bool(true) } diff --git a/pkg/apis/operator/v1alpha1/tektonpipeline_defaults_test.go b/pkg/apis/operator/v1alpha1/tektonpipeline_defaults_test.go index 9ac5bca7bf..ae709129e3 100644 --- a/pkg/apis/operator/v1alpha1/tektonpipeline_defaults_test.go +++ b/pkg/apis/operator/v1alpha1/tektonpipeline_defaults_test.go @@ -40,7 +40,6 @@ func Test_SetDefaults_PipelineProperties(t *testing.T) { } properties := PipelineProperties{ - DisableAffinityAssistant: ptr.Bool(false), DisableHomeEnvOverwrite: ptr.Bool(true), DisableWorkingDirectoryOverwrite: ptr.Bool(true), DisableCredsInit: ptr.Bool(false), diff --git a/pkg/reconciler/openshift/tektonpipeline/extension.go b/pkg/reconciler/openshift/tektonpipeline/extension.go index 8b10e5feef..a57734f4c0 100644 --- a/pkg/reconciler/openshift/tektonpipeline/extension.go +++ b/pkg/reconciler/openshift/tektonpipeline/extension.go @@ -33,6 +33,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/injection" "knative.dev/pkg/logging" + "knative.dev/pkg/ptr" ) const ( @@ -135,10 +136,10 @@ func SetDefault(properties *v1alpha1.PipelineProperties) bool { updated = true } - // Set `disable-affinity-assistant` to true - // webhook will set `false` as default value - if properties.DisableAffinityAssistant == nil || !*properties.DisableAffinityAssistant { - *properties.DisableAffinityAssistant = DefaultDisableAffinityAssistant + // Set `disable-affinity-assistant` to true if not set in CR + // webhook will not set any value but by default in pipelines configmap it will be false + if properties.DisableAffinityAssistant == nil { + properties.DisableAffinityAssistant = ptr.Bool(DefaultDisableAffinityAssistant) updated = true }