diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cafe7d7..88f84958 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,12 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + - name: Set tag run: | BRANCH="${GITHUB_REF##*/}" @@ -48,10 +54,28 @@ jobs: echo "TAG=${CI_TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/upgrade + quay.io/${{ env.IMAGE_ORG }}/upgrade + tag-latest: false + tag-custom-only: true + tag-custom: | + ${{ env.TAG }} + - name: Print Tag info run: | echo "BRANCH: ${BRANCH}" - echo "TAG: ${TAG}" + echo "${{ steps.docker_meta.outputs.tags }}" - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -70,12 +94,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.upgrade - make buildx.push.upgrade + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/upgrade/upgrade.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/upgrade + DBUILD_SITE_URL=https://openebs.io + BRANCH=${{ env.BRANCH }} migrate: runs-on: ubuntu-latest @@ -84,6 +123,12 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + - name: Set tag run: | BRANCH="${GITHUB_REF##*/}" @@ -93,11 +138,29 @@ jobs: fi echo "TAG=${CI_TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/migrate + quay.io/${{ env.IMAGE_ORG }}/migrate + tag-latest: false + tag-custom-only: true + tag-custom: | + ${{ env.TAG }} - name: Print Tag info run: | echo "BRANCH: ${BRANCH}" - echo "TAG: ${TAG}" + echo "${{ steps.docker_meta.outputs.tags }}" - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -116,12 +179,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.migrate - make buildx.push.migrate + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/migrate/migrate.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/upgrade + DBUILD_SITE_URL=https://openebs.io + BRANCH=${{ env.BRANCH }} unit-tests: name: unit tests @@ -183,7 +261,7 @@ jobs: strategy: fail-fast: true matrix: - kubernetes: [v1.18.6] + engine: [cstor, jiva] steps: - name: Checkout uses: actions/checkout@v2 @@ -192,8 +270,14 @@ jobs: uses: manusa/actions-setup-minikube@v2.3.0 with: minikube version: v1.9.2 - kubernetes version: ${{ matrix.kubernetes }} + kubernetes version: v1.18.6 github token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV - name: Set tag run: | @@ -204,6 +288,21 @@ jobs: fi echo "TAG=${CI_TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + + - name: Build image locally + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/upgrade/upgrade.Dockerfile + push: false + load: true + platforms: linux/amd64 + tags: | + ${{ env.IMAGE_ORG }}/upgrade:${{ env.TAG }} + build-args: | + DBUILD_REPO_URL=https://github.com/openebs/upgrade + DBUILD_SITE_URL=https://openebs.io + BRANCH=${{ env.BRANCH }} - name: Running tests - run: ./ci/upgrade/sanity.sh + run: ./ci/upgrade/${{ matrix.engine }}/sanity.sh diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 25ff0d62..19087ac3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -56,9 +56,14 @@ jobs: version: v0.5.1 - name: Build Image - env: - IMG_RESULT: cache - run: make docker.buildx.upgrade + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/upgrade/upgrade.Dockerfile + push: false + platforms: linux/amd64, linux/arm64 + tags: | + openebs/upgrade:ci migrate: runs-on: ubuntu-latest @@ -79,9 +84,14 @@ jobs: version: v0.5.1 - name: Build Image - env: - IMG_RESULT: cache - run: make docker.buildx.migrate + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/migrate/migrate.Dockerfile + push: false + platforms: linux/amd64, linux/arm64 + tags: | + openebs/migrate:ci unit-tests: name: unit tests @@ -140,7 +150,7 @@ jobs: strategy: fail-fast: true matrix: - kubernetes: [v1.18.6] + engine: [cstor, jiva] steps: - name: Checkout uses: actions/checkout@v2 @@ -149,8 +159,14 @@ jobs: uses: manusa/actions-setup-minikube@v2.3.0 with: minikube version: v1.9.2 - kubernetes version: ${{ matrix.kubernetes }} + kubernetes version: v1.18.6 github token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV - name: Set tag run: | @@ -159,5 +175,20 @@ jobs: echo "TAG=${CI_TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + - name: Build image locally + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/upgrade/upgrade.Dockerfile + push: false + load: true + platforms: linux/amd64 + tags: | + ${{ env.IMAGE_ORG }}/upgrade:${{ env.TAG }} + build-args: | + DBUILD_REPO_URL=https://github.com/openebs/upgrade + DBUILD_SITE_URL=https://openebs.io + BRANCH=${{ env.BRANCH }} + - name: Running tests - run: ./ci/upgrade/sanity.sh + run: ./ci/upgrade/${{ matrix.engine }}/sanity.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de3bda7f..9b4a5ac9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,20 +20,43 @@ on: jobs: upgrade: - needs: ['upgrade-e2e'] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + - name: Set Tag run: | TAG="${GITHUB_REF#refs/*/v}" echo "TAG=${TAG}" >> $GITHUB_ENV echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/upgrade + quay.io/${{ env.IMAGE_ORG }}/upgrade + tag-latest: true + tag-semver: | + {{version}} + - name: Print Tag info run: | + echo "${{ steps.docker_meta.outputs.tags }}" echo "RELEASE TAG: ${RELEASE_TAG}" - name: Set up QEMU @@ -53,28 +76,66 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.upgrade - make buildx.push.upgrade + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/upgrade/upgrade.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/upgrade + DBUILD_SITE_URL=https://openebs.io + RELEASE_TAG=${{ env.RELEASE_TAG }} migrate: - needs: ['migration-e2e'] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + - name: Set Tag run: | TAG="${GITHUB_REF#refs/*/v}" echo "TAG=${TAG}" >> $GITHUB_ENV echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/migrate + quay.io/${{ env.IMAGE_ORG }}/migrate + tag-latest: true + tag-semver: | + {{version}} + - name: Print Tag info run: | + echo "${{ steps.docker_meta.outputs.tags }}" echo "RELEASE TAG: ${RELEASE_TAG}" - name: Set up QEMU @@ -94,86 +155,25 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.migrate - make buildx.push.migrate - - unit-tests: - name: unit tests - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.14 - uses: actions/setup-go@v2 - with: - go-version: 1.14.7 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: verify license - run: make check-license - - - name: verify dependencies - run: make deps - - - name: verify tests - run: make test - - migration-e2e: - needs: ['unit-tests'] - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - kubernetes: [v1.18.6] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.3.0 + - name: Login to Quay + uses: docker/login-action@v1 with: - minikube version: v1.9.2 - kubernetes version: ${{ matrix.kubernetes }} - github token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set tag - run: | - TAG="${GITHUB_REF#refs/*/v}" - echo "TAG=${TAG}" >> $GITHUB_ENV - echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV - - - name: Running tests - run: ./ci/migrate/sanity.sh + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} - upgrade-e2e: - needs: ['unit-tests'] - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - kubernetes: [v1.18.6] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.3.0 + - name: Build & Push Image + uses: docker/build-push-action@v2 with: - minikube version: v1.9.2 - kubernetes version: ${{ matrix.kubernetes }} - github token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set tag - run: | - TAG="${GITHUB_REF#refs/*/v}" - echo "TAG=${TAG}" >> $GITHUB_ENV - echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV - - - name: Running tests - run: ./ci/upgrade/sanity.sh + context: . + file: ./build/migrate/migrate.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/migrate + DBUILD_SITE_URL=https://openebs.io + RELEASE_TAG=${{ env.RELEASE_TAG }} + diff --git a/ci/migrate/setup.sh b/ci/migrate/setup.sh index e9083eaf..7ff65073 100755 --- a/ci/migrate/setup.sh +++ b/ci/migrate/setup.sh @@ -45,7 +45,7 @@ sed -ie '/SPARSE_FILE_COUNT/{n;s/"0"/"1"/}' cstor-operator.yaml kubectl apply -f cstor-operator.yaml sleep 5 -sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/migrate/cstor-operator.yaml +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor/cstor-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/migrate/cstor-operator.yaml kubectl apply -f ./ci/migrate/cstor-operator.yaml sleep 10 diff --git a/ci/upgrade/application.tmp.yaml b/ci/upgrade/cstor/application.tmp.yaml similarity index 100% rename from ci/upgrade/application.tmp.yaml rename to ci/upgrade/cstor/application.tmp.yaml diff --git a/ci/upgrade/cstor-operator.tmp.yaml b/ci/upgrade/cstor/cstor-operator.tmp.yaml similarity index 100% rename from ci/upgrade/cstor-operator.tmp.yaml rename to ci/upgrade/cstor/cstor-operator.tmp.yaml diff --git a/ci/upgrade/ndm-operator.yaml b/ci/upgrade/cstor/ndm-operator.yaml similarity index 100% rename from ci/upgrade/ndm-operator.yaml rename to ci/upgrade/cstor/ndm-operator.yaml diff --git a/ci/upgrade/pool.tmp.yaml b/ci/upgrade/cstor/pool.tmp.yaml similarity index 100% rename from ci/upgrade/pool.tmp.yaml rename to ci/upgrade/cstor/pool.tmp.yaml diff --git a/ci/upgrade/cstor/pool.yaml b/ci/upgrade/cstor/pool.yaml new file mode 100644 index 00000000..9c9a47c2 --- /dev/null +++ b/ci/upgrade/cstor/pool.yaml @@ -0,0 +1,79 @@ +# Copyright © 2020 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is an example YAML for upgrading cstor CSPC. +# Some of the values below needs to be changed to +# match your openebs installation. The fields are +# indicated with VERIFY +--- +apiVersion: batch/v1 +kind: Job +metadata: + # VERIFY that you have provided a unique name for this upgrade job. + # The name can be any valid K8s string for name. + name: upgrade-pool + + # VERIFY the value of namespace is same as the namespace where openebs components + # are installed. You can verify using the command: + # `kubectl get pods -n -l openebs.io/component-name=maya-apiserver` + # The above command should return status of the openebs-apiserver. + namespace: openebs +spec: + backoffLimit: 0 + template: + spec: + # VERIFY the value of serviceAccountName is pointing to service account + # created within openebs namespace. Use the non-default account. + # by running `kubectl get sa -n ` + serviceAccountName: openebs-maya-operator + containers: + - name: upgrade + args: + - "cstor-cspc" + + # --from-version is the current version of the pool + - "--from-version=1.10.0" + + # --to-version is the version desired upgrade version + - "--to-version=master-dev" + # if required the image prefix of the pool deployments can be + # changed using the flag below, defaults to whatever was present on old + # deployments. + - "--to-version-image-prefix=openebs/" + # if required the image tags for pool deployments can be changed + # to a custom image tag using the flag below, + # defaults to the --to-version mentioned above. + - "--to-version-image-tag=ci" + + # VERIFY that you have provided the correct list of CSPC Names + - "cspc-stripe" + + # Following are optional parameters + # Log Level + - "--v=4" + # DO NOT CHANGE BELOW PARAMETERS + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + tty: true + + # the image version should be same as the --to-version mentioned above + # in the args of the job + image: openebs/upgrade-amd64:ci + imagePullPolicy: IfNotPresent + restartPolicy: OnFailure +--- + diff --git a/ci/upgrade/sanity.sh b/ci/upgrade/cstor/sanity.sh similarity index 88% rename from ci/upgrade/sanity.sh rename to ci/upgrade/cstor/sanity.sh index 722971c8..10de24ef 100755 --- a/ci/upgrade/sanity.sh +++ b/ci/upgrade/cstor/sanity.sh @@ -15,13 +15,10 @@ # limitations under the License. -set -ex +set -x sudo modprobe iscsi_tcp -# To enable dev upgardes in github action -make upgrade-image.amd64 - # To test the sanity in different customized # image prefixes if [[ "${IMAGE_ORG}" == "" ]]; then @@ -42,7 +39,7 @@ else fi TEST_IMAGE_TAG="${CURRENT_BRANCH}-ci" -if [ ${CURRENT_BRANCH} = "master" ]; then +if [ "${CURRENT_BRANCH}" = "master" ]; then TEST_IMAGE_TAG="ci" fi TEST_VERSION="${CURRENT_BRANCH}-dev" @@ -62,13 +59,13 @@ export TEST_VERSION="${TEST_VERSION#v}" echo "Testing upgrade for org: $IMAGE_ORG version: $TEST_VERSION imagetag: $TEST_IMAGE_TAG" # setup openebs & cstor v1 for migration -./ci/upgrade/setup.sh || exit 1 +./ci/upgrade/cstor/setup.sh || exit 1 # run migration tests -./ci/upgrade/test.sh -if [[ $? != 0 ]]; then +./ci/upgrade/cstor/test.sh +if [ $? != 0 ]; then kubectl logs --tail=50 -l job-name=upgrade-pool -n openebs kubectl logs --tail=50 -l job-name=upgrade-volume -n openebs exit 1 fi -rm ./ci/upgrade/volume.yaml ./ci/upgrade/application.yaml \ No newline at end of file +rm ./ci/upgrade/cstor/volume.yaml ./ci/upgrade/cstor/application.yaml \ No newline at end of file diff --git a/ci/upgrade/setup.sh b/ci/upgrade/cstor/setup.sh similarity index 77% rename from ci/upgrade/setup.sh rename to ci/upgrade/cstor/setup.sh index fd0bbc25..4263ed0c 100755 --- a/ci/upgrade/setup.sh +++ b/ci/upgrade/cstor/setup.sh @@ -21,7 +21,7 @@ echo "Install cstor-operators in 1.10.0" kubectl create ns openebs -kubectl apply -f ./ci/upgrade/ndm-operator.yaml \ +kubectl apply -f ./ci/upgrade/cstor/ndm-operator.yaml \ -f https://raw.githubusercontent.com/openebs/charts/master/archive/1.10.x/csi-operator-1.10.0-ubuntu-18.04.yaml \ -f https://raw.githubusercontent.com/openebs/charts/master/archive/1.10.x/cstor-operator-1.10.0.yaml sleep 100 @@ -34,17 +34,17 @@ echo "Create application with cStor volume on CSPC" nodename=$(kubectl get nodes -o jsonpath='{.items[*].metadata.name}') bdname=$(kubectl -n openebs get blockdevices -o jsonpath='{.items[?(@.spec.details.deviceType=="sparse")].metadata.name}') -sed "s|CSPCBD|$bdname|g" ./ci/upgrade/application.tmp.yaml | sed "s|NODENAME|$nodename|g" > ./ci/upgrade/application.yaml -kubectl apply -f ./ci/upgrade/application.yaml +sed "s|CSPCBD|$bdname|g" ./ci/upgrade/cstor/application.tmp.yaml | sed "s|NODENAME|$nodename|g" > ./ci/upgrade/cstor/application.yaml +kubectl apply -f ./ci/upgrade/cstor/application.yaml sleep 10 kubectl wait --for=condition=available --timeout=200s deployment/percona echo "Upgrade control plane to latest version" -sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/cstor-operator.yaml +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor/cstor-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/cstor/cstor-operator.yaml kubectl apply -f https://raw.githubusercontent.com/openebs/cstor-operators/master/deploy/csi-operator.yaml \ - -f ./ci/upgrade/cstor-operator.yaml + -f ./ci/upgrade/cstor/cstor-operator.yaml sleep 10 kubectl wait --for=condition=available --timeout=300s deployment/cspc-operator -n openebs diff --git a/ci/upgrade/test.sh b/ci/upgrade/cstor/test.sh similarity index 68% rename from ci/upgrade/test.sh rename to ci/upgrade/cstor/test.sh index 97d05512..36bc6069 100755 --- a/ci/upgrade/test.sh +++ b/ci/upgrade/cstor/test.sh @@ -14,11 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -ex echo "Upgrading CSPC pool" -sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/pool.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/pool.yaml -kubectl apply -f ./ci/upgrade/pool.yaml +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor/pool.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/cstor/pool.yaml +kubectl apply -f ./ci/upgrade/cstor/pool.yaml sleep 5 kubectl wait --for=condition=complete job/upgrade-pool -n openebs --timeout=550s kubectl logs --tail=50 -l job-name=upgrade-pool -n openebs @@ -26,8 +27,8 @@ kubectl logs --tail=50 -l job-name=upgrade-pool -n openebs echo "Upgrading CSI volume" pvname=$(kubectl get pvc demo-csi-vol-claim -o jsonpath="{.spec.volumeName}") -sed "s|PVNAME|$pvname|g" ./ci/upgrade/volume.tmp.yaml | sed "s|testimage|$TEST_IMAGE_TAG|g" | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/volume.yaml -kubectl apply -f ./ci/upgrade/volume.yaml +sed "s|PVNAME|$pvname|g" ./ci/upgrade/cstor/volume.tmp.yaml | sed "s|testimage|$TEST_IMAGE_TAG|g" | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/cstor/volume.yaml +kubectl apply -f ./ci/upgrade/cstor/volume.yaml sleep 5 kubectl wait --for=condition=complete job/upgrade-volume -n openebs --timeout=550s kubectl logs --tail=50 -l job-name=upgrade-volume -n openebs diff --git a/ci/upgrade/volume.tmp.yaml b/ci/upgrade/cstor/volume.tmp.yaml similarity index 98% rename from ci/upgrade/volume.tmp.yaml rename to ci/upgrade/cstor/volume.tmp.yaml index 9a4094a3..33e5254f 100644 --- a/ci/upgrade/volume.tmp.yaml +++ b/ci/upgrade/cstor/volume.tmp.yaml @@ -72,7 +72,7 @@ spec: # the image version should be same as the --to-version mentioned above # in the args of the job - image: imageorg/upgrade-amd64:ci + image: imageorg/upgrade:ci imagePullPolicy: IfNotPresent restartPolicy: OnFailure --- diff --git a/ci/upgrade/jiva/application.yaml b/ci/upgrade/jiva/application.yaml new file mode 100644 index 00000000..9d7c0f2d --- /dev/null +++ b/ci/upgrade/jiva/application.yaml @@ -0,0 +1,80 @@ +# Copyright © 2020 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +apiVersion: openebs.io/v1alpha1 +kind: JivaVolumePolicy +metadata: + name: example-jivavolumepolicy + namespace: openebs +spec: + replicaSC: openebs-hostpath + enableBufio: false + autoScaling: false + target: + monitor: true + replicationFactor: 1 +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: openebs-jiva-csi-sc +provisioner: jiva.csi.openebs.io +allowVolumeExpansion: true +parameters: + cas-type: "jiva" + policy: "example-jivavolumepolicy" +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: jiva-csi-demo +spec: + storageClassName: openebs-jiva-csi-sc + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fio +spec: + selector: + matchLabels: + name: fio + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + template: + metadata: + labels: + name: fio + spec: + #nodeName: gke-utkarsh-csi-default-pool-953ba289-rt9l + containers: + - name: perfrunner + image: openebs/tests-fio + command: ["/bin/bash"] + args: ["-c", "while true ;do sleep 50; done"] + volumeMounts: + - mountPath: /datadir + name: fio-vol + volumes: + - name: fio-vol + persistentVolumeClaim: + claimName: jiva-csi-demo \ No newline at end of file diff --git a/ci/upgrade/jiva/jiva-operator.tmp.yaml b/ci/upgrade/jiva/jiva-operator.tmp.yaml new file mode 100644 index 00000000..77073a08 --- /dev/null +++ b/ci/upgrade/jiva/jiva-operator.tmp.yaml @@ -0,0 +1,79 @@ +# Copyright © 2020 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jiva-operator + namespace: openebs + labels: + openebs.io/component-name: jiva-operator + openebs.io/version: testversion + name: jiva-operator +spec: + replicas: 1 + selector: + matchLabels: + name: jiva-operator + template: + metadata: + labels: + name: jiva-operator + openebs.io/component-name: jiva-operator + openebs.io/version: testversion + spec: + serviceAccountName: jiva-operator + containers: + - name: jiva-operator + # Replace this with the built image name + image: imageorg/jiva-operator:testimage + command: + - jiva-operator + imagePullPolicy: IfNotPresent + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: "jiva-operator" + - name: OPENEBS_IO_JIVA_CONTROLLER_IMAGE + value: "imageorg/jiva:testimage" + - name: OPENEBS_IO_JIVA_REPLICA_IMAGE + value: "imageorg/jiva:testimage" + livenessProbe: + httpGet: + path: /healthz + port: 8282 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /readyz + port: 8282 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + limits: + cpu: 100m + memory: 30Mi + requests: + cpu: 100m + memory: 20Mi + terminationGracePeriodSeconds: 10 diff --git a/ci/upgrade/jiva/sanity.sh b/ci/upgrade/jiva/sanity.sh new file mode 100755 index 00000000..7d66cd2c --- /dev/null +++ b/ci/upgrade/jiva/sanity.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright © 2021 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -x + +sudo modprobe iscsi_tcp + +# To test the sanity in different customized +# image prefixes +if [[ "${IMAGE_ORG}" == "" ]]; then + IMAGE_ORG="openebs"; + export IMAGE_ORG; +fi + +# To test the sanity in different versioned branches +# and release tags, get the release version and corresponding +# image tags +# Determine the current branch +CURRENT_BRANCH="" +if [ -z "${BRANCH}" ]; +then + CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) +else + CURRENT_BRANCH="${BRANCH}" +fi + +TEST_IMAGE_TAG="${CURRENT_BRANCH}-ci" +if [ "${CURRENT_BRANCH}" = "master" ]; then + TEST_IMAGE_TAG="ci" +fi +TEST_VERSION="${CURRENT_BRANCH}-dev" + +if [ -n "$RELEASE_TAG" ]; then + # Trim the `v` from the RELEASE_TAG if it exists + # Example: v1.10.0 maps to 1.10.0 + # Example: 1.10.0 maps to 1.10.0 + # Example: v1.10.0-custom maps to 1.10.0-custom + TEST_IMAGE_TAG="${RELEASE_TAG#v}" + TEST_VERSION="${RELEASE_TAG#v}" +fi + +export TEST_IMAGE_TAG="${TEST_IMAGE_TAG#v}" +export TEST_VERSION="${TEST_VERSION#v}" + +echo "Testing upgrade for org: $IMAGE_ORG version: $TEST_VERSION imagetag: $TEST_IMAGE_TAG" + +# setup openebs & cstor v1 for migration +./ci/upgrade/jiva/setup.sh || exit 1 +# run migration tests +./ci/upgrade/jiva/test.sh +if [ $? != 0 ]; then + kubectl logs --tail=50 -l job-name=upgrade-volume -n openebs + exit 1 +fi + +rm ./ci/upgrade/jiva/volume.yaml \ No newline at end of file diff --git a/ci/upgrade/jiva/setup.sh b/ci/upgrade/jiva/setup.sh new file mode 100755 index 00000000..5c2810b9 --- /dev/null +++ b/ci/upgrade/jiva/setup.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Copyright © 2021 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -ex + +echo "Install jiva-operator in 2.7.0" + +kubectl create ns openebs + +kubectl apply -f https://raw.githubusercontent.com/openebs/charts/gh-pages/2.7.0/jiva-operator.yaml \ + -f https://raw.githubusercontent.com/openebs/charts/gh-pages/2.7.0/openebs-operator.yaml +sleep 100 + +echo "Wait for jiva-operator to start" + +kubectl wait --for=condition=available --timeout=550s deployment/jiva-operator -n openebs + +echo "Create application with jiva volume on openebs-hostpath" + +kubectl apply -f ./ci/upgrade/jiva/application.yaml +sleep 10 +kubectl wait --for=condition=available --timeout=200s deployment/fio + +echo "Upgrade control plane to latest version" + +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/jiva/jiva-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/jiva/jiva-operator.yaml + +kubectl apply -f https://raw.githubusercontent.com/openebs/jiva-operator/master/deploy/jiva-csi.yaml \ + -f https://raw.githubusercontent.com/openebs/jiva-operator/master/deploy/operator.yaml \ + -f ./ci/upgrade/jiva/jiva-operator.yaml + +sleep 50 +kubectl wait --for=condition=available --timeout=300s deployment/jiva-operator -n openebs + +kubectl apply -f ./ci/upgrade/upgradetaskCRD.yaml diff --git a/ci/upgrade/jiva/test.sh b/ci/upgrade/jiva/test.sh new file mode 100755 index 00000000..e683004f --- /dev/null +++ b/ci/upgrade/jiva/test.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Copyright © 2021 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +echo "Upgrading jiva volume" + +pvname=$(kubectl get pvc jiva-csi-demo -o jsonpath="{.spec.volumeName}") +sed "s|PVNAME|$pvname|g" ./ci/upgrade/jiva/volume.tmp.yaml | sed "s|testimage|$TEST_IMAGE_TAG|g" | sed "s|testversion|$TEST_VERSION|g" | sed "s|imageorg|$IMAGE_ORG|g" > ./ci/upgrade/jiva/volume.yaml +kubectl apply -f ./ci/upgrade/jiva/volume.yaml +sleep 5 +kubectl wait --for=condition=complete job/upgrade-volume -n openebs --timeout=550s +kubectl logs --tail=50 -l job-name=upgrade-volume -n openebs diff --git a/ci/upgrade/jiva/volume.tmp.yaml b/ci/upgrade/jiva/volume.tmp.yaml new file mode 100644 index 00000000..36118be5 --- /dev/null +++ b/ci/upgrade/jiva/volume.tmp.yaml @@ -0,0 +1,79 @@ +# Copyright © 2020 The OpenEBS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is an example YAML for upgrading cstor volume. +# Some of the values below needs to be changed to +# match your openebs installation. The fields are +# indicated with VERIFY +--- +apiVersion: batch/v1 +kind: Job +metadata: + # VERIFY that you have provided a unique name for this upgrade job. + # The name can be any valid K8s string for name. + name: upgrade-volume + + # VERIFY the value of namespace is same as the namespace where openebs components + # are installed. You can verify using the command: + # `kubectl get pods -n -l openebs.io/component-name=maya-apiserver` + # The above command should return status of the openebs-apiserver. + namespace: openebs +spec: + backoffLimit: 0 + template: + spec: + # VERIFY the value of serviceAccountName is pointing to service account + # created within openebs namespace. Use the non-default account. + # by running `kubectl get sa -n ` + serviceAccountName: jiva-operator + containers: + - name: upgrade + args: + - "jiva-volume" + + # --from-version is the current version of the volume + - "--from-version=2.7.0" + + # --to-version is the version desired upgrade version + - "--to-version=testversion" + # if required the image prefix of the volume deployments can be + # changed using the flag below, defaults to whatever was present on old + # deployments. + - "--to-version-image-prefix=imageorg/" + # if required the image tags for volume deployments can be changed + # to a custom image tag using the flag below, + # defaults to the --to-version mentioned above. + - "--to-version-image-tag=testimage" + + # VERIFY that you have provided the correct list of volume Names + - "PVNAME" + + # Following are optional parameters + # Log Level + - "--v=4" + # DO NOT CHANGE BELOW PARAMETERS + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + tty: true + + # the image version should be same as the --to-version mentioned above + # in the args of the job + image: imageorg/upgrade:ci + imagePullPolicy: IfNotPresent + restartPolicy: Never +--- +