From d54e551bb756737fbca5c48e88e45f9550e1abec Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Tue, 19 Mar 2024 15:22:21 +0530 Subject: [PATCH 1/5] feat(yaml): make csi-controller a deployment and disable hostNetwork Signed-off-by: Niladri Halder --- deploy/lvm-operator.yaml | 4 +--- deploy/yamls/lvm-driver.yaml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/deploy/lvm-operator.yaml b/deploy/lvm-operator.yaml index ed3012f1..98743970 100644 --- a/deploy/lvm-operator.yaml +++ b/deploy/lvm-operator.yaml @@ -1376,7 +1376,7 @@ description: "This priority class should be used for the OpenEBS LVM localPV CSI --- -kind: StatefulSet +kind: Deployment apiVersion: apps/v1 metadata: name: openebs-lvm-controller @@ -1389,7 +1389,6 @@ spec: matchLabels: app: openebs-lvm-controller role: openebs-lvm - serviceName: "openebs-lvm" replicas: 1 template: metadata: @@ -1633,7 +1632,6 @@ spec: spec: priorityClassName: openebs-lvm-localpv-csi-node-critical serviceAccountName: openebs-lvm-node-sa - hostNetwork: true containers: - name: csi-node-driver-registrar image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.8.0 diff --git a/deploy/yamls/lvm-driver.yaml b/deploy/yamls/lvm-driver.yaml index 96e817b5..0385df6c 100644 --- a/deploy/yamls/lvm-driver.yaml +++ b/deploy/yamls/lvm-driver.yaml @@ -940,7 +940,7 @@ description: "This priority class should be used for the OpenEBS LVM localPV CSI --- -kind: StatefulSet +kind: Deployment apiVersion: apps/v1 metadata: name: openebs-lvm-controller @@ -953,7 +953,6 @@ spec: matchLabels: app: openebs-lvm-controller role: openebs-lvm - serviceName: "openebs-lvm" replicas: 1 template: metadata: @@ -1197,7 +1196,6 @@ spec: spec: priorityClassName: openebs-lvm-localpv-csi-node-critical serviceAccountName: openebs-lvm-node-sa - hostNetwork: true containers: - name: csi-node-driver-registrar image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.8.0 From efb53ced5597847b38948ea7fb6c5455dd807de9 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Tue, 19 Mar 2024 20:09:44 +0530 Subject: [PATCH 2/5] refactor(tests): replace StatefulSet with Deployment Signed-off-by: Niladri Halder --- tests/suite_test.go | 2 +- tests/utils.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/suite_test.go b/tests/suite_test.go index 92ed1f04..56a493e2 100644 --- a/tests/suite_test.go +++ b/tests/suite_test.go @@ -63,7 +63,7 @@ var ( appName = "busybox-lvmpv" nodeDaemonSet = "openebs-lvm-node" - controllerStatefulSet = "openebs-lvm-controller" + controllerDeployment = "openebs-lvm-controller" nsObj *corev1.Namespace scObj *storagev1.StorageClass diff --git a/tests/utils.go b/tests/utils.go index 57e328fc..62d14b66 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -612,34 +612,34 @@ func WaitForLVMVolumeReady() { } func scaleControllerPlugin(num int32) int32 { - ginkgo.By(fmt.Sprintf("scaling controller plugin statefulset %v to size %v", controllerStatefulSet, num)) + ginkgo.By(fmt.Sprintf("scaling controller plugin deployment %v to size %v", controllerDeployment, num)) - scale, err := K8sClient.AppsV1().StatefulSets(metav1.NamespaceSystem). - GetScale(context.Background(), controllerStatefulSet, metav1.GetOptions{}) + scale, err := K8sClient.AppsV1().Deployments(metav1.NamespaceSystem). + GetScale(context.Background(), controllerDeployment, metav1.GetOptions{}) gomega.Expect(err).To( gomega.BeNil(), - "fetch current replica of stateful set %v", controllerStatefulSet) + "fetch current replica of deployment %v", controllerDeployment) existingReplicas := scale.Spec.Replicas if scale.Spec.Replicas == num { return existingReplicas } scale.Spec.Replicas = num - scale, err = K8sClient.AppsV1().StatefulSets(metav1.NamespaceSystem). - UpdateScale(context.Background(), controllerStatefulSet, scale, metav1.UpdateOptions{}) + scale, err = K8sClient.AppsV1().Deployments(metav1.NamespaceSystem). + UpdateScale(context.Background(), controllerDeployment, scale, metav1.UpdateOptions{}) gomega.Expect(err).To( gomega.BeNil(), - "update replicas of stateful set %v to %v", controllerStatefulSet, num) + "update replicas of deployment %v to %v", controllerDeployment, num) scaled := gomega.Eventually(func() bool { - scale, err = K8sClient.AppsV1().StatefulSets(metav1.NamespaceSystem). - GetScale(context.Background(), controllerStatefulSet, metav1.GetOptions{}) + scale, err = K8sClient.AppsV1().Deployments(metav1.NamespaceSystem). + GetScale(context.Background(), controllerDeployment, metav1.GetOptions{}) gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) return scale.Spec.Replicas == num }, 120, 10). Should(gomega.BeTrue()) gomega.Expect(scaled).To(gomega.BeTrue(), - "failed to scale up stateful set %v to size %v", controllerStatefulSet, num) + "failed to scale up deployment %v to size %v", controllerDeployment, num) return existingReplicas } From f3828e96c29e79c5a3e853f9b80cfd1f861aea3a Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Tue, 19 Mar 2024 20:26:41 +0530 Subject: [PATCH 3/5] ci: update GitHub Actions workflows Signed-off-by: Niladri Halder --- .github/workflows/build.yml | 39 +++++++++++++++--------------- .github/workflows/pull_request.yml | 16 ++++++------ .github/workflows/release.yml | 25 +++++++++---------- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7a174b1..1420d407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Shellcheck uses: reviewdog/action-shellcheck@v1 @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go 1.19 uses: actions/setup-go@v4 @@ -86,7 +86,7 @@ jobs: kubernetes: [v1.27.3] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go 1.19 uses: actions/setup-go@v4 @@ -126,7 +126,7 @@ jobs: needs: ['lint', 'unit-test', 'bdd-test'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -135,13 +135,13 @@ jobs: echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push the ansible image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: file: ./e2e-tests/Dockerfile push: true @@ -155,7 +155,7 @@ jobs: needs: ['lint', 'unit-test', 'bdd-test'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -166,7 +166,7 @@ jobs: - name: Set Build Date id: date run: | - echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" >> $GITHUB_OUTPUT - name: Set Tag run: | @@ -180,17 +180,16 @@ jobs: - name: Docker meta id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v4 with: # add each registry to which the image needs to be pushed here images: | ${{ env.IMAGE_ORG }}/lvm-driver quay.io/${{ env.IMAGE_ORG }}/lvm-driver ghcr.io/${{ env.IMAGE_ORG }}/lvm-driver - tag-latest: false - tag-custom-only: true - tag-custom: | - ${{ env.TAG }} + tags: | + type=raw,value=latest,enable=false + type=raw,value=${{ env.TAG }} - name: Print Tag info run: | @@ -198,38 +197,38 @@ jobs: echo "${{ steps.docker_meta.outputs.tags }}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 with: - version: v0.5.1 + version: v0.13.1 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to Quay - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} - name: Login to GHCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push Image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./buildscripts/lvm-driver/Dockerfile.buildx diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ed2dfac8..9e43d9b8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go 1.19 uses: actions/setup-go@v4 @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go 1.19 uses: actions/setup-go@v4 @@ -94,7 +94,7 @@ jobs: kubernetes: [v1.27.3] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go 1.19 uses: actions/setup-go@v4 @@ -134,21 +134,21 @@ jobs: needs: ['lint', 'unit-test', 'bdd-test'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 with: - version: v0.5.1 + version: v0.13.1 - name: Build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./buildscripts/lvm-driver/Dockerfile.buildx diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3608643..64bfc281 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -35,7 +35,7 @@ jobs: - name: Set Build Date id: date run: | - echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" >> $GITHUB_OUTPUT - name: Set Tag run: | @@ -45,16 +45,15 @@ jobs: - name: Docker meta id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v4 with: # add each registry to which the image needs to be pushed here images: | ${{ env.IMAGE_ORG }}/lvm-driver quay.io/${{ env.IMAGE_ORG }}/lvm-driver ghcr.io/${{ env.IMAGE_ORG }}/lvm-driver - tag-latest: true - tag-semver: | - {{version}} + tags: | + type=semver,pattern={{version}} - name: Print Tag info run: | @@ -62,38 +61,38 @@ jobs: echo "RELEASE TAG: ${RELEASE_TAG}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 with: - version: v0.5.1 + version: v0.13.1 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to Quay - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} - name: Login to GHCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push Image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./buildscripts/lvm-driver/Dockerfile.buildx From e4b6b5b22b6427dbb3f3a52771807cce4c52bc47 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Tue, 19 Mar 2024 20:37:38 +0530 Subject: [PATCH 4/5] ci: update golang-ci to v1.56.2 Signed-off-by: Niladri Halder --- .github/workflows/build.yml | 18 ++++++++++++------ .github/workflows/pull_request.yml | 11 +++++++---- Makefile | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1420d407..10900569 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,11 +46,17 @@ jobs: pattern: '*.sh' exclude: './.git/*' - - name: install golangci-lint - run: make install-golangci-lint + - name: Set up Go 1.19 + uses: actions/setup-go@v5 + with: + go-version: 1.19.9 + cache: false - - name: Lint checks - run: make golint + - name: Lint Check + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56.2 + args: -E exportloopref,dupl,revive,bodyclose,goconst,misspell -D structcheck --timeout 5m0s unit-test: # to ignore builds on release @@ -61,7 +67,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.19.9 cache: false @@ -89,7 +95,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.19.9 cache: false diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9e43d9b8..b9ca10b4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -37,7 +37,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.19.9 cache: false @@ -52,7 +52,10 @@ jobs: run: make bootstrap - name: Lint Check - run: make golint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56.2 + args: -E exportloopref,dupl,revive,bodyclose,goconst,misspell -D structcheck --timeout 5m0s - name: Shellcheck uses: reviewdog/action-shellcheck@v1 @@ -69,7 +72,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.19.9 cache: false @@ -97,7 +100,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.19.9 cache: false diff --git a/Makefile b/Makefile index 6366d610..3fe72c29 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ bootstrap: controller-gen install-golangci-lint ## Install golangci-lint only if tool doesn't exist in system .PHONY: install-golangci-lint install-golangci-lint: - $(if $(shell which golangci-lint), echo "golangci-lint already exist in system", (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b "${GOPATH}/bin" v1.52.2)) + $(if $(shell which golangci-lint), echo "golangci-lint already exist in system", (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b "${GOPATH}/bin" v1.56.2)) .PHONY: controller-gen controller-gen: From d289c4666c96ed59f516d930a2b96632faceb813 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Tue, 19 Mar 2024 20:42:06 +0530 Subject: [PATCH 5/5] ci: update codecov action Signed-off-by: Niladri Halder --- .github/workflows/build.yml | 4 ++-- .github/workflows/pull_request.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10900569..5c9dc2c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,7 @@ jobs: run: make test - name: Upload Coverage Report - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt @@ -120,7 +120,7 @@ jobs: run: ./ci/ci-test.sh - name: Upload Coverage Report - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./tests/bdd_coverage.txt diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b9ca10b4..981ea740 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -81,7 +81,7 @@ jobs: run: make test - name: Upload Coverage Report - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt @@ -125,7 +125,7 @@ jobs: run: ./ci/ci-test.sh - name: Upload Coverage Report - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./tests/bdd_coverage.txt