Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TektonConfig CR's addon params to remove cluster tasks params #2439

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pkg/apis/operator/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ const (
ProfileLite = "lite"

// Addon Params
// Keeping ClusterTasksParams and CommunityClusterTasks params for backward compatibility
// will be removed from next operator api release
ClusterTasksParam = "clusterTasks"
CommunityClusterTasks = "communityClusterTasks"
PipelineTemplatesParam = "pipelineTemplates"
ResolverTasks = "resolverTasks"
ResolverStepActions = "resolverStepActions"
Expand Down Expand Up @@ -113,10 +109,6 @@ var (
}

AddonParams = map[string]ParamValue{
// Keeping ClusterTasks and CommunityClusterTasks params
// for backward compatibility and will be removed in next operator api release
ClusterTasksParam: defaultParamValue,
CommunityClusterTasks: defaultParamValue,
PipelineTemplatesParam: defaultParamValue,
ResolverTasks: defaultParamValue,
ResolverStepActions: defaultParamValue,
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/operator/v1alpha1/tektonaddon_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Test_AddonSetDefaults_DefaultParamsWithValues(t *testing.T) {
}

ta.SetDefaults(context.TODO())
assert.Equal(t, 5, len(ta.Spec.Params))
assert.Equal(t, 3, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[PipelineTemplatesParam]
Expand Down Expand Up @@ -70,7 +70,7 @@ func Test_AddonSetDefaults_ResolverTaskIsFalse(t *testing.T) {
}

ta.SetDefaults(context.TODO())
assert.Equal(t, 5, len(ta.Spec.Params))
assert.Equal(t, 3, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[ResolverTasks]
Expand Down Expand Up @@ -101,7 +101,7 @@ func Test_AddonSetDefaults_ResolverStepActions(t *testing.T) {
}

ta.SetDefaults(context.TODO())
assert.Equal(t, 5, len(ta.Spec.Params))
assert.Equal(t, 3, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[ResolverStepActions]
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonaddon_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func validateAddonParams(params []Param, pathToParams string) *apis.FieldError {
var errs *apis.FieldError

for i, p := range params {
// Todo: Remove this in next operator release
if p.Name == "clusterTasks" || p.Name == "communityClusterTasks" {
continue
}
paramValue, ok := AddonParams[p.Name]
if !ok {
errs = errs.Also(apis.ErrInvalidKeyName(p.Name, pathToParams))
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/operator/v1alpha1/tektonconfig_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func Test_SetDefaults_Addon_Params(t *testing.T) {
t.Setenv("PLATFORM", "openshift")

tc.SetDefaults(context.TODO())
if len(tc.Spec.Addon.Params) != 5 {
if len(tc.Spec.Addon.Params) != 3 {
t.Error("Setting default failed for TektonConfig (spec.addon.params)")
}
}
Expand Down
27 changes: 27 additions & 0 deletions pkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,30 @@ func upgradePipelineProperties(ctx context.Context, logger *zap.SugaredLogger, k
}
return nil
}

// previous version of the TektonConfig CR's addon params has cluster task params to manage the cluster tasks
// and cluster tasks have been deprecated and removed so need to remove the clusterTasks and communityClusterTasks
// params from TektonConfig's addon params and this removes the cluster tasks params and updates TektonConfig's addon params
// Todo: remove this in the next operator release
func removeDeprecatedAddonParams(ctx context.Context, logger *zap.SugaredLogger, k8sClient kubernetes.Interface, operatorClient versioned.Interface, restConfig *rest.Config) error {
tcCR, err := operatorClient.OperatorV1alpha1().TektonConfigs().Get(ctx, v1alpha1.ConfigResourceName, metav1.GetOptions{})
if err != nil {
if apierrs.IsNotFound(err) {
return nil
}
return err
}

updatedParams := []v1alpha1.Param{}
for _, p := range tcCR.Spec.Addon.Params {
if p.Name == "clusterTasks" || p.Name == "communityClusterTasks" {
continue
}
updatedParams = append(updatedParams, p)
}

// update the Tekton config's addon params
tcCR.Spec.Addon.Params = updatedParams
_, err = operatorClient.OperatorV1alpha1().TektonConfigs().Update(ctx, tcCR, metav1.UpdateOptions{})
return err
}
4 changes: 3 additions & 1 deletion pkg/reconciler/shared/tektonconfig/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ var (
// pre upgrade functions
preUpgradeFunctions = []upgradeFunc{
resetTektonConfigConditions, // upgrade #1: removes conditions from TektonConfig CR, clears outdated conditions
upgradePipelineProperties, // update default value of enable-step-actions from false to true
upgradePipelineProperties, // upgrade #2: update default value of enable-step-actions from false to true
// Todo: Remove the removeDeprecatedAddonParams upgrade function in next operator release
removeDeprecatedAddonParams, // upgrade #3: remove the deprecated cluster task params from TektonConfig CR's addon params
}

// post upgrade functions
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/common/00_tektonconfigdeployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ func (s *TektonConfigTestSuite) Test05_DisableAndEnableAddons() {
// disable addons and update
tc := s.getCurrentConfig(timeout)
tc.Spec.Addon.Params = []v1alpha1.Param{
{Name: v1alpha1.ClusterTasksParam, Value: "false"},
{Name: v1alpha1.CommunityClusterTasks, Value: "false"},
{Name: v1alpha1.PipelineTemplatesParam, Value: "false"},
}
_, err := s.clients.TektonConfig().Update(context.TODO(), tc, metav1.UpdateOptions{})
Expand Down
Loading