Skip to content

Commit

Permalink
Remove cluster task installersets
Browse files Browse the repository at this point in the history
This patch will remove cluster task installersets and also
remove the existing cluster task installersets during operator upgrade

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 committed Nov 12, 2024
1 parent 8c9e935 commit 3dd935d
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 387 deletions.
8 changes: 4 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- [Iterating](#iterating)
- [Install Operator](#install-operator)
- [Accessing logs](#accessing-logs)
- [Updating the clustertasks in OpenShift addons](#updating-the-clustertasks-in-openshift-addons)
- [Updating the tasks in OpenShift addons](#updating-the-tasks-in-openshift-addons)
- [Running Codegen](#running-codegen)
- [Setup development environment on localhost](#setup-development-environment-on-localhost)
- [Pre-requests](#pre-requests)
Expand Down Expand Up @@ -206,16 +206,16 @@ watch this space!**
**Note: this needs to be completed! We don't yet have any code or config to deploy,
watch this space!**

## Updating the clustertasks in OpenShift addons
## Updating the tasks in OpenShift addons

You can update the clustertasks present in the codebase with the latest using the script present at `/hack/openshift/update-tasks.sh`
You can update the tasks present in the codebase with the latest using the script present at `/hack/openshift/update-tasks.sh`

You can edit the script to mention the specific version of the task or to add a new task.

Then all the tasks mentioned in the script can be added to codebase using

```shell
./hack/openshift/fetch-tektoncd-catalog-tasks.sh cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_external
./hack/openshift/fetch-tektoncd-catalog-tasks.sh cmd/openshift/operator/kodata/tekton-addon/addons/02-tasks/source_external
```
## Running Codegen

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ifeq ($(TARGET), openshift)
rm -rf ./cmd/$(TARGET)/operator/kodata/manual-approval-gate
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-pruner
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/pipelines-as-code
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/addons/02-clustertasks/source_external/
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/addons/02-tasks/source_external/
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/addons/07-ecosystem/tasks
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/addons/07-ecosystem/stepactions
rm -rf ./cmd/$(TARGET)/operator/kodata/tekton-addon/pipelines-as-code-templates/go.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ spec:
tasks:
- name: fetch-repository
taskRef:
name: git-clone
kind: ClusterTask
resolver: cluster
params:
- name: git-clone-task
value: git-clone
workspaces:
- name: output
workspace: workspace
Expand All @@ -39,7 +41,10 @@ spec:

- name: build
taskRef:
kind: ClusterTask
resolver: cluster
params:
- name: build-task
value: s2i
runAfter:
- fetch-repository
workspaces:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ spec:
targetNamespace: openshift-pipelines
addon:
params:
- name: clusterTasks
value: "true"
- name: pipelineTemplates
value: "true"
- name: communityClusterTasks
value: "true"
- name: resolverTasks
value: "true"
- name: resolverStepActions
Expand Down
8 changes: 2 additions & 6 deletions docs/TektonAddon.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ weight: 6
-->
# Tekton Addon

TektonAddon custom resource allows user to install resource like clusterTasks and pipelineTemplate along with Pipelines.
TektonAddon custom resource allows user to install resource like resolverTasks, resolverStepActions and pipelineTemplate along with Pipelines.
It also allows user to install various Tasks in openshift-pipelines namespace.

**NOTE:** TektonAddon is currently available only for OpenShift Platform. This is roadmap to enable it for Kubernetes platform.
Expand All @@ -22,8 +22,6 @@ metadata:
spec:
targetNamespace: openshift-pipelines
params:
- name: clusterTasks
value: "true"
- name: pipelineTemplates
value: "true"
- name: resolverTasks
Expand All @@ -37,12 +35,10 @@ You can install this component using [TektonConfig](./TektonConfig.md) by choosi

params provide a way to enable/disable the installation of resources.
Available params are

- `clusterTasks` (Default: `true`)
- `pipelineTemplates` (Default: `true`)
- `resolverTasks` (Default: `true`)
- `resolverStepActions` (Default: `true`)

User can disable the installation of resources by changing the value to `false`.

Pipelines templates uses clustertasks in them so to install pipelineTemplates, clusterTasks must be `true`.
- Pipelines templates uses tasks from `openshift-pipelines` in them so to install pipelineTemplates, resolverTasks must be `true`
4 changes: 1 addition & 3 deletions docs/TektonConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,14 @@ By default pruner job will be created from the global pruner config (`spec.prune
> `keep: 100` <br>
### Addon

TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few ClusterTasks, PipelineTemplates, Tasks.
TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few PipelineTemplates, ResolverTasks and ResolverStepActions.

This section allows to customize installation of those resources through params. You can read more about the supported params [here](./TektonAddon.md).

Example:
```yaml
addon:
params:
- name: "clusterTask"
value: "true"
- name: "pipelineTemplates"
value: "true"
- name: "resolverTasks"
Expand Down
2 changes: 1 addition & 1 deletion hack/fetch-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ release_yaml_hub() {

fetch_openshift_addon_tasks() {
fetch_addon_task_script="${SCRIPT_DIR}/hack/openshift"
local dest_dir="cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_external"
local dest_dir="cmd/openshift/operator/kodata/tekton-addon/addons/02-tasks/source_external"
${fetch_addon_task_script}/fetch-tektoncd-catalog-tasks.sh ${dest_dir}
dest_dir='cmd/openshift/operator/kodata/tekton-addon/addons/07-ecosystem/tasks'
${fetch_addon_task_script}/fetch-tektoncd-catalog-tasks.sh ${dest_dir} "ecosystem_tasks"
Expand Down
4 changes: 2 additions & 2 deletions hack/openshift/fetch-tektoncd-catalog-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ USAGE:
$SCRIPT_NAME DEST_DIR
Example:
$SCRIPT_NAME cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_external
$SCRIPT_NAME cmd/openshift/operator/kodata/tekton-addon/addons/02-tasks/source_external
EOF
exit 1
}
Expand Down Expand Up @@ -142,7 +142,7 @@ main() {

case "$type" in
"default")
dest_dir=${1:-'cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_external'}
dest_dir=${1:-'cmd/openshift/operator/kodata/tekton-addon/addons/02-tasks/source_external'}
resources=TEKTON_CATALOG_TASKS
branch="main"
catalog="$TEKTON_CATALOG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:label
version: v1alpha1
- description: Represents an installation of latest version of Addons (exclusively ClusterTasks, consoleyamlsamples, consoleclidownloads and consolequickstarts)
- description: Represents an installation of latest version of Addons (exclusively Tasks, StepActions, consoleyamlsamples, consoleclidownloads and consolequickstarts)
displayName: Tekton Addons
kind: TektonAddon
name: tektonaddons.operator.tekton.dev
Expand Down
8 changes: 6 additions & 2 deletions pkg/apis/operator/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ const (
ProfileLite = "lite"

// Addon Params
// Keeping ClusterTasksParams and CommunityClusterTasks params for api compatibility
// will be removed from next api release
ClusterTasksParam = "clusterTasks"
PipelineTemplatesParam = "pipelineTemplates"
CommunityClusterTasks = "communityClusterTasks"
PipelineTemplatesParam = "pipelineTemplates"
ResolverTasks = "resolverTasks"
ResolverStepActions = "resolverStepActions"

Expand Down Expand Up @@ -111,9 +113,11 @@ var (
}

AddonParams = map[string]ParamValue{
// Keeping ClusterTasks and CommunityClusterTasks params
// for api campatibility and will be removed in next api release
ClusterTasksParam: defaultParamValue,
PipelineTemplatesParam: defaultParamValue,
CommunityClusterTasks: defaultParamValue,
PipelineTemplatesParam: defaultParamValue,
ResolverTasks: defaultParamValue,
ResolverStepActions: defaultParamValue,
}
Expand Down
40 changes: 36 additions & 4 deletions pkg/apis/operator/v1alpha1/tektonaddon_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func Test_AddonSetDefaults_DefaultParamsWithValues(t *testing.T) {
assert.Equal(t, 5, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[ClusterTasksParam]
value, ok := params[PipelineTemplatesParam]
assert.Equal(t, true, ok)
assert.Equal(t, "true", value)
}

func Test_AddonSetDefaults_ClusterTaskIsFalse(t *testing.T) {
func Test_AddonSetDefaults_ResolverTaskIsFalse(t *testing.T) {

ta := &TektonAddon{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -61,7 +61,7 @@ func Test_AddonSetDefaults_ClusterTaskIsFalse(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "false",
},
},
Expand All @@ -73,7 +73,39 @@ func Test_AddonSetDefaults_ClusterTaskIsFalse(t *testing.T) {
assert.Equal(t, 5, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[PipelineTemplatesParam]
value, ok := params[ResolverTasks]
assert.Equal(t, true, ok)
assert.Equal(t, "false", value)
}

func Test_AddonSetDefaults_ResolverStepActions(t *testing.T) {

ta := &TektonAddon{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
},
Spec: TektonAddonSpec{
CommonSpec: CommonSpec{
TargetNamespace: "namespace",
},
Addon: Addon{
Params: []Param{
{
Name: "resolverStepActions",
Value: "false",
},
},
},
},
}

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

params := ParseParams(ta.Spec.Params)
value, ok := params[ResolverStepActions]
assert.Equal(t, true, ok)
assert.Equal(t, "false", value)
}

8 changes: 4 additions & 4 deletions pkg/apis/operator/v1alpha1/tektonaddon_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func setAddonDefaults(addon *Addon) {

paramsMap := ParseParams(addon.Params)
_, ptOk := paramsMap[PipelineTemplatesParam]
ct, ctOk := paramsMap[ClusterTasksParam]
rt, rtOk := paramsMap[ResolverTasks]

// If clusterTasks is false and pipelineTemplate is not set, then set it as false
// as pipelines templates are created using clusterTasks
if ctOk && (ct == "false" && !ptOk) {
// If ResolverTask is false and pipelineTemplate is not set, then set it as false
// as pipelines templates are created using ResolverTask
if rtOk && (rt == "false" && !ptOk) {
addon.Params = append(addon.Params, Param{
Name: PipelineTemplatesParam,
Value: "false",
Expand Down
8 changes: 0 additions & 8 deletions pkg/apis/operator/v1alpha1/tektonaddon_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,5 @@ func validateAddonParams(params []Param, pathToParams string) *apis.FieldError {
}
}

paramsMap := ParseParams(params)
if (paramsMap[ClusterTasksParam] == "false") && (paramsMap[PipelineTemplatesParam] == "true") {
errs = errs.Also(apis.ErrGeneric("pipelineTemplates cannot be true if clusterTask is false", pathToParams))
}
if (paramsMap[ClusterTasksParam] == "false") && (paramsMap[CommunityClusterTasks] == "true") {
errs = errs.Also(apis.ErrGeneric("communityClusterTasks cannot be true if clusterTask is false", pathToParams))
}

return errs
}
34 changes: 2 additions & 32 deletions pkg/apis/operator/v1alpha1/tektonaddon_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func Test_ValidateTektonAddon_InvalidParamValue(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "test",
},
},
Expand All @@ -94,35 +94,5 @@ func Test_ValidateTektonAddon_InvalidParamValue(t *testing.T) {
}

err := ta.Validate(context.TODO())
assert.Equal(t, "invalid value: test: spec.params.clusterTasks[0]", err.Error())
}

func Test_ValidateTektonAddon_ClusterTaskIsFalseAndPipelineTemplateIsTrue(t *testing.T) {

ta := &TektonAddon{
ObjectMeta: metav1.ObjectMeta{
Name: "addon",
Namespace: "namespace",
},
Spec: TektonAddonSpec{
CommonSpec: CommonSpec{
TargetNamespace: "namespace",
},
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Value: "false",
},
{
Name: "pipelineTemplates",
Value: "true",
},
},
},
},
}

err := ta.Validate(context.TODO())
assert.Equal(t, "pipelineTemplates cannot be true if clusterTask is false: spec.params", err.Error())
assert.Equal(t, "invalid value: test: spec.params.resolverTasks[0]", err.Error())
}
4 changes: 2 additions & 2 deletions pkg/apis/operator/v1alpha1/tektonconfig_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func Test_ValidateTektonConfig_InvalidAddonParamValue(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "test",
},
},
Expand All @@ -180,7 +180,7 @@ func Test_ValidateTektonConfig_InvalidAddonParamValue(t *testing.T) {
}

err := tc.Validate(context.TODO())
assert.Equal(t, "invalid value: test: spec.addon.params.clusterTasks[0]", err.Error())
assert.Equal(t, "invalid value: test: spec.addon.params.resolverTasks[0]", err.Error())
}

func Test_ValidateTektonConfig_InvalidPipelineProperties(t *testing.T) {
Expand Down
Loading

0 comments on commit 3dd935d

Please sign in to comment.