diff --git a/ci-operator/step-registry/storage/conf/storageclass/OWNERS b/ci-operator/step-registry/storage/conf/storageclass/OWNERS new file mode 100644 index 0000000000000..b4499320bacd0 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/OWNERS @@ -0,0 +1,8 @@ +approvers: +- storage-approvers +- duanwei33 +- Phaow +reviewers: +- storage-reviewers +- duanwei33 +- Phaow diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/OWNERS b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/OWNERS new file mode 100644 index 0000000000000..b4499320bacd0 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/OWNERS @@ -0,0 +1,8 @@ +approvers: +- storage-approvers +- duanwei33 +- Phaow +reviewers: +- storage-reviewers +- duanwei33 +- Phaow diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-commands.sh b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-commands.sh new file mode 100644 index 0000000000000..f94d9fe29736a --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-commands.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + +function set_proxy () { + if test -s "${SHARED_DIR}/proxy-conf.sh" ; then + echo "setting the proxy" + echo "source ${SHARED_DIR}/proxy-conf.sh" + source "${SHARED_DIR}/proxy-conf.sh" + else + echo "no proxy setting." + fi +} + +function run_command() { + local CMD="$1" + echo "Running Command: ${CMD}" + eval "${CMD}" +} + +function get_current_sc() { + run_command "oc get sc" +} + +function get_default_sc() { + CURRENT_DEFAULT_SC=$(oc get sc -ojsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io/is-default-class=="true")].metadata.name}') + echo "Current default storageclass is:" "${CURRENT_DEFAULT_SC}" +} + +function remove_all_default_sc_annotations () { + run_command "oc annotate sc storageclass.kubernetes.io/is-default-class=false --all --overwrite" +} + +function set_required_sc_as_default () { + run_command "oc annotate sc ${REQUIRED_DEFAULT_STORAGECLASS} storageclass.kubernetes.io/is-default-class=true --overwrite" +} + +set_proxy +get_default_sc +remove_all_default_sc_annotations +set_required_sc_as_default +# For debugging +get_current_sc diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.metadata.json b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.metadata.json new file mode 100644 index 0000000000000..e4026f07b29b8 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.yaml", + "owners": { + "approvers": [ + "storage-approvers", + "duanwei33", + "Phaow" + ], + "reviewers": [ + "storage-reviewers", + "duanwei33", + "Phaow" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.yaml b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.yaml new file mode 100644 index 0000000000000..22ed0f578ce8b --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-default-storageclass/storage-conf-storageclass-set-default-storageclass-ref.yaml @@ -0,0 +1,16 @@ +ref: + as: storage-conf-storageclass-set-default-storageclass + from: cli + # inject oc binary + cli: latest + commands: storage-conf-storageclass-set-default-storageclass-commands.sh + resources: + requests: + cpu: 10m + memory: 100Mi + env: + - name: REQUIRED_DEFAULT_STORAGECLASS + documentation: |- + Name of the storage class to set as the new default. The storage class must already exist. + documentation: |- + The storage-conf-storageclass-set-default-storageclass step changes the cluster default storageclass to the specified one. diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/OWNERS b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/OWNERS new file mode 100644 index 0000000000000..b4499320bacd0 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/OWNERS @@ -0,0 +1,8 @@ +approvers: +- storage-approvers +- duanwei33 +- Phaow +reviewers: +- storage-reviewers +- duanwei33 +- Phaow diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-commands.sh b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-commands.sh new file mode 100644 index 0000000000000..a11470784d78f --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-commands.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + +function set_proxy () { + if test -s "${SHARED_DIR}/proxy-conf.sh" ; then + echo "setting the proxy" + echo "source ${SHARED_DIR}/proxy-conf.sh" + source "${SHARED_DIR}/proxy-conf.sh" + else + echo "no proxy setting." + fi +} + +function run_command() { + local CMD="$1" + echo "Running Command: ${CMD}" + eval "${CMD}" +} + +function set_sc_state_unmanaged () { + run_command "oc patch clustercsidriver $(oc get sc "${REQUIRED_UNMANAGED_STORAGECLASS}" -ojsonpath='{.provisioner}') -p '[{\"op\":\"replace\",\"path\":\"/spec/storageClassState\",\"value\":\"Unmanaged\"}]' --type json" +} + +set_proxy +set_sc_state_unmanaged diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.metadata.json b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.metadata.json new file mode 100644 index 0000000000000..d8b823d9f39a1 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.yaml", + "owners": { + "approvers": [ + "storage-approvers", + "duanwei33", + "Phaow" + ], + "reviewers": [ + "storage-reviewers", + "duanwei33", + "Phaow" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.yaml b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.yaml new file mode 100644 index 0000000000000..c67f110437256 --- /dev/null +++ b/ci-operator/step-registry/storage/conf/storageclass/set-storageclass-unmanaged/storage-conf-storageclass-set-storageclass-unmanaged-ref.yaml @@ -0,0 +1,16 @@ +ref: + as: storage-conf-storageclass-set-storageclass-unmanaged + from: cli + # inject oc binary + cli: latest + commands: storage-conf-storageclass-set-storageclass-unmanaged-commands.sh + resources: + requests: + cpu: 10m + memory: 100Mi + env: + - name: REQUIRED_UNMANAGED_STORAGECLASS + documentation: |- + Name of the storage class to set as unmanaged. The storage class must already exist and it should managed by cluster storage operator. + documentation: |- + The storage-conf-storageclass-set-storageclass-unmanaged step changes specified managed storageclass to unmanaged. The step only available for OCP 4.13 above versions.