Skip to content

Commit

Permalink
feat: replace clusterTask with tasks
Browse files Browse the repository at this point in the history
clusterTasks are deprecated
https://tekton.dev/docs/pipelines/tasks/#task-vs-clustertask.
This PR changes all clusterTasks to tasks and do all necessary
modifications.
Signed-off-by: Karel Šimon <[email protected]>
  • Loading branch information
ksimon1 committed Apr 10, 2023
1 parent 4e7d80e commit 8a561a3
Show file tree
Hide file tree
Showing 68 changed files with 153 additions and 223 deletions.
4 changes: 2 additions & 2 deletions automation/e2e-deploy-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ kubectl apply -f "https://github.com/kubevirt/containerized-data-importer/releas
# wait for tekton pipelines
kubectl rollout status -n openshift-operators deployment/openshift-pipelines-operator --timeout 10m

# wait until clustertasks tekton CRD is properly deployed
# wait until tasks tekton CRD is properly deployed
timeout 10m bash <<- EOF
until kubectl get crd clustertasks.tekton.dev; do
until kubectl get crd tasks.tekton.dev; do
sleep 5
done
EOF
Expand Down
1 change: 0 additions & 1 deletion automation/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -ex

export SCOPE="${SCOPE:-cluster}"
export DEV_MODE="${DEV_MODE:-false}"
export STORAGE_CLASS="${STORAGE_CLASS:-}"
export DEPLOY_NAMESPACE="${DEPLOY_NAMESPACE:-e2e-tests-$(shuf -i10000-99999 -n1)}"
Expand Down
8 changes: 0 additions & 8 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ make cluster-sync
./scripts/cluster-sync.sh execute-in-vm
```

You can also change the scope of the tasks to be single namespace only:

```bash
SCOPE=namespace make cluster-sync
```

## Testing

### Running Unit Tests
Expand All @@ -55,8 +49,6 @@ make test
### Running E2E Tests
```bash
NUM_NODES=4 make cluster-test
# for namespace scope use
SCOPE=namespace NUM_NODES=4 make cluster-test
# clean all used resources, namespaces and images
make cluster-clean
Expand Down
10 changes: 5 additions & 5 deletions examples/pipelines/server-deployer/server-deployer-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
- name: waitForSuccess
value: 'true'
taskRef:
kind: ClusterTask
kind: Task
name: modify-data-object
- name: generate-ssh-keys
params:
Expand All @@ -36,7 +36,7 @@ spec:
- 'user:fedora'
- 'disable-strict-host-key-checking:true'
taskRef:
kind: ClusterTask
kind: Task
name: generate-ssh-keys
- name: disk-virt-customize
params:
Expand All @@ -47,7 +47,7 @@ spec:
install git,vim,pip
run-command pip install flask
taskRef:
kind: ClusterTask
kind: Task
name: disk-virt-customize
runAfter:
- modify-data-object
Expand Down Expand Up @@ -118,7 +118,7 @@ spec:
- disk-virt-customize
- generate-ssh-keys
taskRef:
kind: ClusterTask
kind: Task
name: create-vm-from-manifest
- name: execute-in-vm
params:
Expand All @@ -138,5 +138,5 @@ spec:
runAfter:
- create-vm-from-manifest
taskRef:
kind: ClusterTask
kind: Task
name: execute-in-vm
8 changes: 4 additions & 4 deletions examples/pipelines/unit-tester/unit-tester-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- 'user:fedora'
- 'disable-strict-host-key-checking:true'
taskRef:
kind: ClusterTask
kind: Task
name: generate-ssh-keys
- name: create-vm-from-manifest
params:
Expand Down Expand Up @@ -87,7 +87,7 @@ spec:
runAfter:
- generate-ssh-keys
taskRef:
kind: ClusterTask
kind: Task
name: create-vm-from-manifest
- name: execute-in-vm
params:
Expand All @@ -110,7 +110,7 @@ spec:
runAfter:
- create-vm-from-manifest
taskRef:
kind: ClusterTask
kind: Task
name: execute-in-vm
finally:
- name: cleanup-vm
Expand All @@ -135,5 +135,5 @@ spec:
cat ${RESULT_FILES}
fi
taskRef:
kind: ClusterTask
kind: Task
name: cleanup-vm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
- name: waitForSuccess
value: 'true'
taskRef:
kind: ClusterTask
kind: Task
name: modify-data-object
- name: disk-virt-sysprep
params:
Expand All @@ -39,7 +39,7 @@ spec:
- name: additionalOptions
value: "--network"
taskRef:
kind: ClusterTask
kind: Task
name: disk-virt-sysprep
runAfter:
- modify-data-object
Expand Down Expand Up @@ -102,5 +102,5 @@ spec:
runAfter:
- disk-virt-sysprep
taskRef:
kind: ClusterTask
kind: Task
name: create-vm-from-manifest
10 changes: 2 additions & 8 deletions modules/tests/test/constants/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package constants

import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/sharedtest/testconstants"
"strings"
"time"

"github.com/kubevirt/kubevirt-tekton-tasks/modules/sharedtest/testconstants"
)

const e2eNamespacePrefix = "e2e-tests"
Expand All @@ -22,13 +23,6 @@ const (
EmptyTargetNS TargetNamespace = "empty"
)

type TestScope string

const (
ClusterTestScope TestScope = "cluster"
NamespaceTestScope TestScope = "namespace"
)

type EnvScope string

const (
Expand Down
9 changes: 5 additions & 4 deletions modules/tests/test/constants/copy-template.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package constants

const (
CopyTemplateClusterTaskName = "copy-template"
CopyTemplateServiceAccountName = "copy-template-task"
CopyTemplateTaskRunName = "taskrun-copy-template"
NewTemplateName = "test-template"
CopyTemplateTaskName = "copy-template"
CopyTemplateServiceAccountName = "copy-template-task"
CopyTemplateServiceAccountNameNamespaced = "copy-template-test"
CopyTemplateTaskRunName = "taskrun-copy-template"
NewTemplateName = "test-template"

SourceTemplateNameOptionName = "sourceTemplateName"
SourceTemplateNamespaceOptionName = "sourceTemplateNamespace"
Expand Down
7 changes: 4 additions & 3 deletions modules/tests/test/constants/create-data-object.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package constants

const (
ModifyDataObjectClusterTaskName = "modify-data-object"
ModifyDataObjectServiceAccountName = "modify-data-object-task"
ModifyDataObjectTaskrunName = "taskrun-modify-data-object"
ModifyDataObjectTaskName = "modify-data-object"
ModifyDataObjectServiceAccountName = "modify-data-object-task"
ModifyDataObjectServiceAccountNameNamespaced = "modify-data-object-test"
ModifyDataObjectTaskrunName = "taskrun-modify-data-object"

UnusualRestartCountThreshold = 3
ReasonError = "Error"
Expand Down
6 changes: 4 additions & 2 deletions modules/tests/test/constants/create-vm.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package constants

const CreateVMFromTemplateClusterTaskName = "create-vm-from-template"
const CreateVMFromTemplateTaskName = "create-vm-from-template"
const CreateVMFromTemplateServiceAccountName = "create-vm-from-template-task"
const CreateVMFromTemplateServiceAccountNameNamespaced = "create-vm-from-template-test"

const CreateVMFromManifestClusterTaskName = "create-vm-from-manifest"
const CreateVMFromManifestTaskName = "create-vm-from-manifest"
const CreateVMFromManifestServiceAccountName = "create-vm-from-manifest-task"
const CreateVMFromManifestServiceAccountNameNamespaced = "create-vm-from-manifest-test"

type createVMParams struct {
DataVolumes string
Expand Down
4 changes: 2 additions & 2 deletions modules/tests/test/constants/disk-virt-libguestfs-tasks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package constants

const DiskVirtCustomizeClusterTaskName = "disk-virt-customize"
const DiskVirtSysprepClusterTaskName = "disk-virt-sysprep"
const DiskVirtCustomizeTaskName = "disk-virt-customize"
const DiskVirtSysprepTaskName = "disk-virt-sysprep"

type diskVirtLibguestfsTasksParams struct {
PVCName string
Expand Down
4 changes: 2 additions & 2 deletions modules/tests/test/constants/execute-in-vm.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package constants

const ExecuteInVMClusterTaskName = "execute-in-vm"
const ExecuteInVMTaskName = "execute-in-vm"
const ExecuteInVMServiceAccountName = "execute-in-vm-task"

const CleanupVMClusterTaskName = "cleanup-vm"
const CleanupVMTaskName = "cleanup-vm"
const CleanupVMServiceAccountName = "cleanup-vm-task"

type executeOrCleanupVMParams struct {
Expand Down
5 changes: 3 additions & 2 deletions modules/tests/test/constants/generate-ssh-keys.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package constants

const (
GenerateSshKeysClusterTaskName = "generate-ssh-keys"
GenerateSshKeysServiceAccountName = "generate-ssh-keys-task"
GenerateSshKeysTaskName = "generate-ssh-keys"
GenerateSshKeysServiceAccountName = "generate-ssh-keys-task"
GenerateSshKeysServiceAccountNameNamespaced = "generate-ssh-keys-test"
)

type generateSshKeysParams struct {
Expand Down
7 changes: 4 additions & 3 deletions modules/tests/test/constants/modify-vm-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
)

const (
ModifyTemplateClusterTaskName = "modify-vm-template"
ModifyTemplateServiceAccountName = "modify-vm-template-task"
ModifyTemplateTaskRunName = "taskrun-modify-vm-template"
ModifyTemplateTaskName = "modify-vm-template"
ModifyTemplateServiceAccountName = "modify-vm-template-task"
ModifyTemplateServiceAccountNameNamespaced = "modify-vm-template-test"
ModifyTemplateTaskRunName = "taskrun-modify-vm-template"

TemplateNameOptionName = "templateName"
TemplateNamespaceOptionName = "templateNamespace"
Expand Down
5 changes: 3 additions & 2 deletions modules/tests/test/constants/wait-for-vmi-status.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package constants

const (
WaitForVMIStatusClusterTaskName = "wait-for-vmi-status"
WaitForVMIStatusServiceAccountName = "wait-for-vmi-status-task"
WaitForVMIStatusTaskName = "wait-for-vmi-status"
WaitForVMIStatusServiceAccountName = "wait-for-vmi-status-task"
WaitForVMIStatusServiceAccountNameNamespaced = "wait-for-vmi-status-test"
)

type waitForVMIStatusTasksParams struct {
Expand Down
11 changes: 3 additions & 8 deletions modules/tests/test/copy_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ var _ = Describe("Copy template task", func() {
SourceTemplateName: testtemplate.CirrosTemplateName,
},
}),
Entry("[NAMESPACE SCOPED] cannot copy template in different namespace", &testconfigs.CopyTemplateTestConfig{
Entry("cannot copy template in different namespace", &testconfigs.CopyTemplateTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CopyTemplateServiceAccountName,
ExpectedLogs: "templates.template.openshift.io is forbidden",
LimitTestScope: NamespaceTestScope,
ServiceAccount: CopyTemplateServiceAccountNameNamespaced,
ExpectedLogs: "cannot get resource \"templates\"",
},
TaskData: testconfigs.CopyTemplateTaskData{
SourceTemplateName: testtemplate.CirrosTemplateName,
Expand Down Expand Up @@ -107,7 +106,6 @@ var _ = Describe("Copy template task", func() {
Entry("should create template in different namespace", &testconfigs.CopyTemplateTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CopyTemplateServiceAccountName,
LimitTestScope: ClusterTestScope,
},
TaskData: testconfigs.CopyTemplateTaskData{
SourceTemplateName: testtemplate.CirrosTemplateName,
Expand Down Expand Up @@ -166,7 +164,6 @@ var _ = Describe("Copy template task", func() {
config := &testconfigs.CopyTemplateTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CopyTemplateServiceAccountName,
LimitTestScope: ClusterTestScope,
},
TaskData: testconfigs.CopyTemplateTaskData{
SourceTemplateName: testtemplate.RhelTemplateName,
Expand Down Expand Up @@ -214,7 +211,6 @@ var _ = Describe("Copy template task", func() {
config := &testconfigs.CopyTemplateTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CopyTemplateServiceAccountName,
LimitTestScope: ClusterTestScope,
ExpectedLogs: "templates.template.openshift.io \"test-template\" already exists",
},
TaskData: testconfigs.CopyTemplateTaskData{
Expand Down Expand Up @@ -247,7 +243,6 @@ var _ = Describe("Copy template task", func() {
config := &testconfigs.CopyTemplateTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CopyTemplateServiceAccountName,
LimitTestScope: ClusterTestScope,
},
TaskData: testconfigs.CopyTemplateTaskData{
SourceTemplateName: testtemplate.CirrosTemplateName,
Expand Down
10 changes: 4 additions & 6 deletions modules/tests/test/create_vm_from_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,20 @@ var _ = Describe("Create VM from manifest", func() {
VM: testobjects.NewTestAlpineVM("vm-with-non-existent-pvc").WithNonMatchingDisk().Build(),
},
}),
Entry("[NAMESPACE SCOPED] cannot create a VM in different namespace", &testconfigs.CreateVMTestConfig{
Entry("cannot create a VM in different namespace", &testconfigs.CreateVMTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CreateVMFromManifestServiceAccountName,
ServiceAccount: CreateVMFromManifestServiceAccountNameNamespaced,
ExpectedLogs: "cannot create resource \"virtualmachines\" in API group \"kubevirt.io\"",
LimitTestScope: NamespaceTestScope,
},
TaskData: testconfigs.CreateVMTaskData{
VM: testobjects.NewTestAlpineVM("different-ns-namespace-scope").Build(),
VMTargetNamespace: SystemTargetNS,
},
}),
Entry("[NAMESPACE SCOPED] cannot create a VM in different namespace in manifest", &testconfigs.CreateVMTestConfig{
Entry("cannot create a VM in different namespace in manifest", &testconfigs.CreateVMTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CreateVMFromManifestServiceAccountName,
ServiceAccount: CreateVMFromManifestServiceAccountNameNamespaced,
ExpectedLogs: "cannot create resource \"virtualmachines\" in API group \"kubevirt.io\"",
LimitTestScope: NamespaceTestScope,
},
TaskData: testconfigs.CreateVMTaskData{
VM: testobjects.NewTestAlpineVM("different-ns-namespace-scope-in-manifest").Build(),
Expand Down
17 changes: 7 additions & 10 deletions modules/tests/test/create_vm_from_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ var _ = Describe("Create VM from template", func() {
},
},
}),
Entry("[NAMESPACE SCOPED] cannot create a VM in different namespace", &testconfigs.CreateVMTestConfig{
Entry("cannot create a VM in different namespace", &testconfigs.CreateVMTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CreateVMFromTemplateServiceAccountName,
ExpectedLogs: "processedtemplates.template.openshift.io is forbidden",
LimitTestScope: NamespaceTestScope,
ServiceAccount: CreateVMFromTemplateServiceAccountNameNamespaced,
ExpectedLogs: "cannot get resource \"templates\"",
},
TaskData: testconfigs.CreateVMTaskData{
Template: testtemplate.NewCirrosServerTinyTemplate().Build(),
Expand All @@ -190,11 +189,10 @@ var _ = Describe("Create VM from template", func() {
VMTargetNamespace: SystemTargetNS,
},
}),
Entry("[NAMESPACE SCOPED] cannot use template from a different namespace", &testconfigs.CreateVMTestConfig{
Entry("cannot use template from a different namespace", &testconfigs.CreateVMTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CreateVMFromTemplateServiceAccountName,
ServiceAccount: CreateVMFromTemplateServiceAccountNameNamespaced,
ExpectedLogs: "templates.template.openshift.io \"unreachable-template\" is forbidden",
LimitTestScope: NamespaceTestScope,
},
TaskData: testconfigs.CreateVMTaskData{
TemplateTargetNamespace: SystemTargetNS,
Expand Down Expand Up @@ -301,18 +299,17 @@ var _ = Describe("Create VM from template", func() {
},
},
}),
Entry("[CLUSTER SCOPED] works also in the same namespace as deploy", &testconfigs.CreateVMTestConfig{
Entry("works also in the same namespace as deploy", &testconfigs.CreateVMTestConfig{
TaskRunTestConfig: testconfigs.TaskRunTestConfig{
ServiceAccount: CreateVMFromTemplateServiceAccountName,
LimitTestScope: ClusterTestScope,
ExpectedLogs: ExpectedSuccessfulVMCreation,
},
TaskData: testconfigs.CreateVMTaskData{
Template: testtemplate.NewCirrosServerTinyTemplate().Build(),
TemplateTargetNamespace: DeployTargetNS,
VMTargetNamespace: DeployTargetNS,
TemplateParams: []string{
testtemplate.TemplateParam(testtemplate.NameParam, E2ETestsRandomName("same-ns-cluster-scope")),
testtemplate.TemplateParam(testtemplate.NameParam, E2ETestsRandomName("same-ns")),
},
},
}),
Expand Down
Loading

0 comments on commit 8a561a3

Please sign in to comment.