From d1f9d76efdbe4505b8071c323eb266872e54e51e Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 23 Nov 2023 06:26:14 +0000 Subject: [PATCH 1/2] chore(github-actions): bump up github action workflow step dependency Signed-off-by: Abhinandan Purkait --- .github/workflows/build.yml | 51 ++++++++++--------- .github/workflows/chart-lint-test.yml | 15 +++--- .github/workflows/pull_request.yml | 31 +++++++----- .github/workflows/release-charts.yml | 10 ++-- .github/workflows/release.yml | 16 +++--- go.mod | 73 +++++++++++++++++++++++++-- go.sum | 2 - 7 files changed, 134 insertions(+), 64 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81359b5..9693a1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: License Check run: make license-check @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Unit test run: make test @@ -62,12 +62,12 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Go 1.15 + - name: Set up Go 1.19 uses: actions/setup-go@v3 with: - go-version: 1.15.15 + go-version: 1.19.13 - name: Build provisioner-nfs image run: make provisioner-nfs-image @@ -80,11 +80,14 @@ jobs: sudo apt-get update && sudo apt-get install -y nfs-common - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.7.2 + uses: medyagh/setup-minikube@latest with: - minikube version: v1.29.0 - kubernetes version: v1.23.16 - start args: '--install-addons=false' + cache: false + minikube-version: 1.31.1 + driver: none + kubernetes-version: ${{ matrix.kubernetes }} + cni: calico + start-args: '--install-addons=false' - name: Installation run: | @@ -99,12 +102,12 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Go 1.15 + - name: Set up Go 1.19 uses: actions/setup-go@v3 with: - go-version: 1.15.15 + go-version: 1.19.13 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -124,21 +127,20 @@ 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: 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 }}/provisioner-nfs quay.io/${{ env.IMAGE_ORG }}/provisioner-nfs ghcr.io/${{ env.IMAGE_ORG }}/provisioner-nfs - 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 Tags run: | @@ -194,7 +196,7 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -213,17 +215,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 }}/nfs-server-alpine quay.io/${{ env.IMAGE_ORG }}/nfs-server-alpine ghcr.io/${{ env.IMAGE_ORG }}/nfs-server-alpine - 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 Tags run: | @@ -274,7 +275,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs diff --git a/.github/workflows/chart-lint-test.yml b/.github/workflows/chart-lint-test.yml index 3bada06..d97de06 100644 --- a/.github/workflows/chart-lint-test.yml +++ b/.github/workflows/chart-lint-test.yml @@ -17,21 +17,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Helm - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v3 with: - version: v3.5.0 + version: v3.12.1 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: '3.10' + check-latest: true - name: Set up chart-testing - uses: helm/chart-testing-action@v2.0.1 + uses: helm/chart-testing-action@v2.6.0 - name: Run chart-testing (list-changed) id: list-changed @@ -45,7 +46,7 @@ jobs: run: ct lint --config ct.yml - name: Create kind cluster - uses: helm/kind-action@v1.2.0 + uses: helm/kind-action@v1.8.0 if: steps.list-changed.outputs.changed == 'true' - name: Run chart-testing (install) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4f8ff7b..1146f7a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: License Check run: make license-check @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Unit test run: make test @@ -59,12 +59,12 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Go 1.15 + - name: Set up Go 1.19 uses: actions/setup-go@v3 with: - go-version: 1.15.15 + go-version: 1.19.13 - name: Build provisioner-nfs image run: make provisioner-nfs-image @@ -77,11 +77,14 @@ jobs: sudo apt-get update && sudo apt-get install -y nfs-common - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.7.2 + uses: medyagh/setup-minikube@latest with: - minikube version: v1.29.0 - kubernetes version: v1.23.16 - start args: '--install-addons=false' + cache: false + minikube-version: 1.31.1 + driver: none + kubernetes-version: ${{ matrix.kubernetes }} + cni: calico + start-args: '--install-addons=false' - name: Installation run: | @@ -96,12 +99,12 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Go 1.15 + - name: Set up Go 1.19 uses: actions/setup-go@v3 with: - go-version: 1.15.15 + go-version: 1.19.13 - name: Setup QEMU uses: docker/setup-qemu-action@v2 @@ -129,7 +132,7 @@ jobs: needs: ['lint', 'unit-test'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup QEMU uses: docker/setup-qemu-action@v2 @@ -156,7 +159,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build the nfs-e2e image uses: docker/build-push-action@v4 diff --git a/.github/workflows/release-charts.yml b/.github/workflows/release-charts.yml index 1c941d1..8c9f95a 100644 --- a/.github/workflows/release-charts.yml +++ b/.github/workflows/release-charts.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -21,13 +21,13 @@ jobs: git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - name: Install Helm - uses: azure/setup-helm@v1 + - name: Install Helm + uses: azure/setup-helm@v3 with: - version: v3.5.0 + version: v3.12.1 - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.2.1 + uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.CR_TOKEN }}" with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70ec01e..6944472 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -41,20 +41,20 @@ 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: 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 }}/provisioner-nfs quay.io/${{ env.IMAGE_ORG }}/provisioner-nfs ghcr.io/${{ env.IMAGE_ORG }}/provisioner-nfs - tag-latest: true - tag-semver: | - {{version}} + tags: | + type=raw,value=latest,enable=true + type=raw,value={{version}} - name: Print Tags run: | @@ -112,7 +112,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -128,7 +128,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: Docker meta id: docker_meta diff --git a/go.mod b/go.mod index 922a2a5..2d21449 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openebs/dynamic-nfs-provisioner -go 1.15 +go 1.19 replace ( k8s.io/api => k8s.io/api v0.20.2 @@ -40,8 +40,6 @@ require ( github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.6.1 - golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect - google.golang.org/appengine v1.6.6 // indirect k8s.io/api v0.20.2 k8s.io/apimachinery v0.20.2 k8s.io/client-go v11.0.0+incompatible @@ -49,3 +47,72 @@ require ( k8s.io/kubernetes v1.17.3 sigs.k8s.io/sig-storage-lib-external-provisioner/v7 v7.0.1 ) + +require ( + cloud.google.com/go v0.54.0 // indirect + github.com/BurntSushi/toml v0.3.1 // indirect + github.com/Masterminds/goutils v1.1.0 // indirect + github.com/Masterminds/semver v1.5.0 // indirect + github.com/Masterminds/sprig v2.22.0+incompatible // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/go-units v0.4.0 // indirect + github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 // indirect + github.com/evanphx/json-patch v4.9.0+incompatible // indirect + github.com/go-logr/logr v0.4.0 // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.4.3 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.1.2 // indirect + github.com/googleapis/gnostic v0.4.1 // indirect + github.com/hashicorp/golang-lru v0.5.1 // indirect + github.com/hpcloud/tail v1.0.0 // indirect + github.com/huandu/xstrings v1.3.1 // indirect + github.com/imdario/mergo v0.3.8 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef // indirect + github.com/json-iterator/go v1.1.10 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/miekg/dns v1.1.29 // indirect + github.com/mitchellh/copystructure v1.0.0 // indirect + github.com/mitchellh/reflectwalk v1.0.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.15.0 // indirect + github.com/prometheus/procfs v0.2.0 // indirect + github.com/ryanuber/columnize v2.1.0+incompatible // indirect + go.uber.org/atomic v1.5.0 // indirect + go.uber.org/multierr v1.3.0 // indirect + go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect + go.uber.org/zap v1.13.0 // indirect + golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect + golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect + golang.org/x/mod v0.3.0 // indirect + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect + golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 // indirect + golang.org/x/text v0.3.4 // indirect + golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect + golang.org/x/tools v0.0.0-20200616133436-c1934b75d054 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect + google.golang.org/grpc v1.27.1 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + honnef.co/go/tools v0.0.1-2020.1.3 // indirect + k8s.io/klog v1.0.0 // indirect + k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd // indirect + k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.0.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/go.sum b/go.sum index 0f72bf2..a92c29a 100644 --- a/go.sum +++ b/go.sum @@ -122,7 +122,6 @@ github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QH github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/prettybench v0.0.0-20150116022406-03b8cfe5406c/go.mod h1:Xe6ZsFhtM8HrDku0pxJ3/Lr51rwykrzgFwpmTzleatY= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -1204,7 +1203,6 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyz sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/sig-storage-lib-external-provisioner/v7 v7.0.1 h1:V7VpIENtPECffT1exDwS4IvxnsaZGpXByzJwIwA6wRM= sigs.k8s.io/sig-storage-lib-external-provisioner/v7 v7.0.1/go.mod h1:kWYdKvf1O/T6AunX35p5KulJQd3tLpCXpBGevfNpoV8= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff/v4 v4.0.2 h1:YHQV7Dajm86OuqnIR6zAelnDWBRjo+YhYV9PmGrh1s8= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= From 9b767a1daf0860a0c9ae267a4b35ba1891470816 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 23 Nov 2023 06:31:29 +0000 Subject: [PATCH 2/2] chore(code formatting): format the code with 1.19 version Signed-off-by: Abhinandan Purkait --- .github/workflows/build.yml | 2 +- .github/workflows/release-charts.yml | 2 +- .../api/apps/v1/deployment/deployment.go | 6 +- .../v1/persistentvolume/persistentvolume.go | 16 +-- .../v1/podtemplatespec/podtemplatespec.go | 9 +- pkg/kubernetes/api/core/v1/volume/build.go | 4 +- pkg/kubernetes/client/client.go | 22 ++-- provisioner/config.go | 74 +++++++------ provisioner/config_test.go | 2 +- provisioner/node_affinity.go | 87 +++++++-------- provisioner/provisioner.go | 16 +-- provisioner/provisioner_kernel_nfs_server.go | 8 +- provisioner/signal_handler.go | 2 +- provisioner/types.go | 101 +++++++++--------- 14 files changed, 190 insertions(+), 161 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9693a1a..f31827f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,7 +65,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Go 1.19 - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: 1.19.13 diff --git a/.github/workflows/release-charts.yml b/.github/workflows/release-charts.yml index 8c9f95a..1bcdc7e 100644 --- a/.github/workflows/release-charts.yml +++ b/.github/workflows/release-charts.yml @@ -21,7 +21,7 @@ jobs: git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - name: Install Helm + - name: Install Helm uses: azure/setup-helm@v3 with: version: v3.12.1 diff --git a/pkg/kubernetes/api/apps/v1/deployment/deployment.go b/pkg/kubernetes/api/apps/v1/deployment/deployment.go index b96bc78..70a6b93 100644 --- a/pkg/kubernetes/api/apps/v1/deployment/deployment.go +++ b/pkg/kubernetes/api/apps/v1/deployment/deployment.go @@ -307,7 +307,7 @@ func (b *Builder) WithReplicas(replicas *int32) *Builder { return b } -//WithStrategyType sets the strategy field of the deployment +// WithStrategyType sets the strategy field of the deployment func (b *Builder) WithStrategyType( strategytype appsv1.DeploymentStrategyType, ) *Builder { @@ -323,7 +323,7 @@ func (b *Builder) WithStrategyType( return b } -//WithStrategyTypeRecreate sets the strategy field of the deployment as Recreate +// WithStrategyTypeRecreate sets the strategy field of the deployment as Recreate func (b *Builder) WithStrategyTypeRecreate() *Builder { return b.WithStrategyType(appsv1.RecreateDeploymentStrategyType) } @@ -519,7 +519,7 @@ func (d *Deploy) IsTerminationInProgress() bool { // IsUpdateInProgress Checks if all the replicas are updated or not. // If Status.AvailableReplicas < Status.UpdatedReplicas then all the -//older replicas are not there but there are less number of availableReplicas +// older replicas are not there but there are less number of availableReplicas func IsUpdateInProgress() Predicate { return func(d *Deploy) bool { return d.IsUpdateInProgress() diff --git a/pkg/kubernetes/api/core/v1/persistentvolume/persistentvolume.go b/pkg/kubernetes/api/core/v1/persistentvolume/persistentvolume.go index 89aeefe..592112a 100644 --- a/pkg/kubernetes/api/core/v1/persistentvolume/persistentvolume.go +++ b/pkg/kubernetes/api/core/v1/persistentvolume/persistentvolume.go @@ -91,15 +91,15 @@ func (p *PV) GetPath() string { // This method expects only a single hostname to be set. // // The PV object will have the node's hostname specified as follows: -// nodeAffinity: -// required: -// nodeSelectorTerms: -// - matchExpressions: -// - key: kubernetes.io/hostname -// operator: In -// values: -// - hostname // +// nodeAffinity: +// required: +// nodeSelectorTerms: +// - matchExpressions: +// - key: kubernetes.io/hostname +// operator: In +// values: +// - hostname func (p *PV) GetAffinitedNodeHostname() string { nodeAffinity := p.object.Spec.NodeAffinity if nodeAffinity == nil { diff --git a/pkg/kubernetes/api/core/v1/podtemplatespec/podtemplatespec.go b/pkg/kubernetes/api/core/v1/podtemplatespec/podtemplatespec.go index 647c378..d657d8c 100644 --- a/pkg/kubernetes/api/core/v1/podtemplatespec/podtemplatespec.go +++ b/pkg/kubernetes/api/core/v1/podtemplatespec/podtemplatespec.go @@ -225,7 +225,7 @@ func (b *Builder) WithNodeSelectorNew(nodeselectors map[string]string) *Builder return b } -//WithNodeSelectorByValue overrides the NodeSelector with new values +// WithNodeSelectorByValue overrides the NodeSelector with new values func (b *Builder) WithNodeSelectorByValue(nodeselectors map[string]string) *Builder { // copy of original map newnodeselectors := map[string]string{} @@ -290,9 +290,12 @@ func (b *Builder) WithAffinity(affinity *corev1.Affinity) *Builder { // WithNodeAffinityMatchExpressions sets matchexpressions under // nodeAffinity // NOTE: If nil is passed then match expressions will not be -// propogated to node affinity. +// +// propogated to node affinity. +// // CAUTION: Don't invoke WithAffinity func after calling this function -// It will overwrite MatchExpression +// +// It will overwrite MatchExpression func (b *Builder) WithNodeAffinityMatchExpressions( mExpressions []corev1.NodeSelectorRequirement) *Builder { if len(mExpressions) == 0 { diff --git a/pkg/kubernetes/api/core/v1/volume/build.go b/pkg/kubernetes/api/core/v1/volume/build.go index becfc7c..60173be 100644 --- a/pkg/kubernetes/api/core/v1/volume/build.go +++ b/pkg/kubernetes/api/core/v1/volume/build.go @@ -65,7 +65,7 @@ func (b *Builder) WithHostDirectory(path string) *Builder { return b } -//WithSecret sets the VolumeSource field of Volume with provided Secret +// WithSecret sets the VolumeSource field of Volume with provided Secret func (b *Builder) WithSecret(secret *corev1.Secret, defaultMode int32) *Builder { dM := defaultMode if secret == nil { @@ -92,7 +92,7 @@ func (b *Builder) WithSecret(secret *corev1.Secret, defaultMode int32) *Builder return b } -//WithConfigMap sets the VolumeSource field of Volume with provided ConfigMap +// WithConfigMap sets the VolumeSource field of Volume with provided ConfigMap func (b *Builder) WithConfigMap(configMap *corev1.ConfigMap, defaultMode int32) *Builder { dM := defaultMode if configMap == nil { diff --git a/pkg/kubernetes/client/client.go b/pkg/kubernetes/client/client.go index 48ead57..f6feacd 100644 --- a/pkg/kubernetes/client/client.go +++ b/pkg/kubernetes/client/client.go @@ -42,7 +42,8 @@ const ( // to abstract getting kubernetes incluster config // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type getInClusterConfigFn func() (*rest.Config, error) // buildConfigFromFlagsFn is a typed function @@ -50,7 +51,8 @@ type getInClusterConfigFn func() (*rest.Config, error) // provided flags // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type buildConfigFromFlagsFn func(string, string) (*rest.Config, error) // getKubeMasterIPFromENVFn is a typed function @@ -58,7 +60,8 @@ type buildConfigFromFlagsFn func(string, string) (*rest.Config, error) // address from environment variable // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type getKubeMasterIPFromENVFn func(env.ENVKey) string // getKubeConfigPathFromENVFn is a typed function to @@ -66,21 +69,24 @@ type getKubeMasterIPFromENVFn func(env.ENVKey) string // environment variable // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type getKubeConfigPathFromENVFn func(env.ENVKey) string // getKubeDynamicClientFn is a typed function to // abstract getting dynamic kubernetes clientset // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type getKubeDynamicClientFn func(*rest.Config) (dynamic.Interface, error) // getKubeClientsetFn is a typed function // to abstract getting kubernetes clientset // // NOTE: -// typed function makes it simple to mock +// +// typed function makes it simple to mock type getKubeClientsetFn func(*rest.Config) (*kubernetes.Clientset, error) // Client provides Kubernetes client operations @@ -119,7 +125,9 @@ type Client struct { // instance // // NOTE: -// This is the basic building block to create +// +// This is the basic building block to create +// // functional operations against the client // instance type OptionFn func(*Client) diff --git a/provisioner/config.go b/provisioner/config.go index 5142ab9..e2cc5fc 100644 --- a/provisioner/config.go +++ b/provisioner/config.go @@ -107,7 +107,7 @@ const ( betaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" ) -//GetVolumeConfig creates a new VolumeConfig struct by +// GetVolumeConfig creates a new VolumeConfig struct by // parsing and merging the configuration provided in the PVC // annotation - cas.openebs.io/config with the // default configuration of the provisioner. @@ -177,7 +177,7 @@ func (p *Provisioner) GetVolumeConfig(pvName string, pvc *v1.PersistentVolumeCla return c, nil } -//GetNFSServerTypeFromConfig returns the NFSServerType value configured +// GetNFSServerTypeFromConfig returns the NFSServerType value configured // in StorageClass. Default is kernel func (c *VolumeConfig) GetNFSServerTypeFromConfig() string { serverType := c.getValue(KeyPVNFSServerType) @@ -187,7 +187,7 @@ func (c *VolumeConfig) GetNFSServerTypeFromConfig() string { return serverType } -//GetBackendStorageClassFromConfig returns the Storage Class +// GetBackendStorageClassFromConfig returns the Storage Class // value configured in StorageClass. Default is "" func (c *VolumeConfig) GetBackendStorageClassFromConfig() string { backingSC := c.getValue(KeyPVBackendStorageClass) @@ -241,14 +241,16 @@ func (c *VolumeConfig) GetNFServerGraceTime() (int, error) { // StorageClass if specified // ----------------------------------------------------- // NOTE: This feature has been deprecated -// Alternative: Use FilePermission 'cas.openebs.io/config' annotation -// key on the backend volume PVC. Sample FilePermissions -// for FSGID-like configuration -- // -// name: FilePermissions -// data: -// GID: -// mode: "g+s" +// Alternative: Use FilePermission 'cas.openebs.io/config' annotation +// key on the backend volume PVC. Sample FilePermissions +// for FSGID-like configuration -- +// +// name: FilePermissions +// data: +// GID: +// mode: "g+s" +// // ----------------------------------------------------- func (c *VolumeConfig) GetFSGroupID() (*int64, error) { fsGroupIDStr := c.getValue(FSGroupID) @@ -371,18 +373,21 @@ func (c *VolumeConfig) getResourceList(key string) (v1.ResourceList, error) { return resourceList, nil } -//getValue is a utility function to extract the value +// getValue is a utility function to extract the value // of the `key` from the ConfigMap object - which is // map[string]interface{map[string][string]} // Example: -// { -// key1: { -// value: value1 -// enabled: true -// } -// } +// +// { +// key1: { +// value: value1 +// enabled: true +// } +// } +// // In the above example, if `key1` is passed as input, -// `value1` will be returned. +// +// `value1` will be returned. func (c *VolumeConfig) getValue(key string) string { if configObj, ok := util.GetNestedField(c.options, key).(map[string]string); ok { if val, p := configObj[string(mconfig.ValuePTP)]; p { @@ -392,20 +397,23 @@ func (c *VolumeConfig) getValue(key string) string { return "" } -//getData is a utility function to extract the value +// getData is a utility function to extract the value // of the `key` from the ConfigMap object - which is // map[string]interface{map[string]interface{map[string]string}} // Example: -// { -// key1: { -// value: value1 -// data: { -// dataKey1: dataValue1 -// } -// } -// } +// +// { +// key1: { +// value: value1 +// data: { +// dataKey1: dataValue1 +// } +// } +// } +// // In the above example, if `key1` and `dataKey1` are passed as input, -// `dataValue1` will be returned. +// +// `dataValue1` will be returned. func (c *VolumeConfig) getData(key string, dataKey string) string { if configData, ok := util.GetNestedField(c.configData, key).(map[string]string); ok { if val, p := configData[dataKey]; p { @@ -449,11 +457,11 @@ func hookConfigFileExist() (bool, error) { // initializeHook read the hook config file and update the given hook variable // return value: -// - nil -// - If hook config file doesn't exists -// - If hook config file is parsed and given hook variable is updated -// - error -// - If hook config is invalid +// - nil +// - If hook config file doesn't exists +// - If hook config file is parsed and given hook variable is updated +// - error +// - If hook config is invalid func initializeHook(hook **nfshook.Hook) error { hookFileExists, err := hookConfigFileExist() if err != nil { diff --git a/provisioner/config_test.go b/provisioner/config_test.go index 9739bf2..d5f7f43 100644 --- a/provisioner/config_test.go +++ b/provisioner/config_test.go @@ -5,7 +5,7 @@ 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 + 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, diff --git a/provisioner/node_affinity.go b/provisioner/node_affinity.go index 46b20d5..37ee9af 100644 --- a/provisioner/node_affinity.go +++ b/provisioner/node_affinity.go @@ -44,38 +44,39 @@ func getNodeAffinityRules() NodeAffinity { // getOneOrMoreNodeSelectorRequirements can take one or more node affinity requirements // as string and convert them to structured form of Requirements // Ex: -// Case1 - Input argument: kubernetes.io/storage-node,kubernetes.io/nfs-node,kubernetes.io/zone:[zone-1,zone-2,zone-3] // -// Return value: -// - key: kubernetes.io/storage-node -// operator: Exists -// - key: kubernetes.io/nfs-node -// operator: Exists -// - key: kubernetes.io/zone -// operator: In -// values: -// - zone-1 -// - zone-2 -// - zone-3 +// Case1 - Input argument: kubernetes.io/storage-node,kubernetes.io/nfs-node,kubernetes.io/zone:[zone-1,zone-2,zone-3] // -// Case2 - Input argument: kubernetes.io/storage-node,kubernetes.io/nfs-node,kubernetes.io/linux-amd64 +// Return value: +// - key: kubernetes.io/storage-node +// operator: Exists +// - key: kubernetes.io/nfs-node +// operator: Exists +// - key: kubernetes.io/zone +// operator: In +// values: +// - zone-1 +// - zone-2 +// - zone-3 // -// Return value: -// - key: kubernetes.io/storage-node -// operator: Exists -// - key: kubernetes.io/nfs-node -// operator: Exists -// - key: kubernetes.io/linux-amd64 -// operator: Exists +// Case2 - Input argument: kubernetes.io/storage-node,kubernetes.io/nfs-node,kubernetes.io/linux-amd64 // -// Case3 - Input argument: kubernetes.io/zone:[zone-1,zone-2] +// Return value: +// - key: kubernetes.io/storage-node +// operator: Exists +// - key: kubernetes.io/nfs-node +// operator: Exists +// - key: kubernetes.io/linux-amd64 +// operator: Exists // -// Return value: -// - key: kubernetes.io/zone -// operator: In -// values: -// - zone-1 -// - zone-2 +// Case3 - Input argument: kubernetes.io/zone:[zone-1,zone-2] +// +// Return value: +// - key: kubernetes.io/zone +// operator: In +// values: +// - zone-1 +// - zone-2 func getOneOrMoreNodeSelectorRequirements( requirementsAsValue string) []corev1.NodeSelectorRequirement { var nodeRequirements []corev1.NodeSelectorRequirement @@ -120,25 +121,25 @@ func getOneOrMoreNodeSelectorRequirements( // // Example: kubernetes.io/hostName:[z1-host1,z2-host1,z3-host1] value convert as below // -// key: kubernetes.io/hostName -// operator: "In" -// values: -// - z1-host1 -// - z2-host1 -// - z3-host1 +// key: kubernetes.io/hostName +// operator: "In" +// values: +// - z1-host1 +// - z2-host1 +// - z3-host1 // // Example: kubernetes.io/hostName:[region-1,region-2 value convert as below // -// key: kubernetes.io/hostName -// operator: "In" -// values: -// - region-1 -// - region-2 +// key: kubernetes.io/hostName +// operator: "In" +// values: +// - region-1 +// - region-2 // // Example: kubernetes.io/storage-node // -// key: kubernetes.io/storage-node -// operator: "Exists" +// key: kubernetes.io/storage-node +// operator: "Exists" func getNodeSelectorRequirement(reqAsValue string) corev1.NodeSelectorRequirement { var nsRequirement corev1.NodeSelectorRequirement keyValues := strings.Split(reqAsValue, ":") @@ -169,9 +170,9 @@ func getNodeSelectorRequirement(reqAsValue string) corev1.NodeSelectorRequiremen // getRightMostMatchingString will return right must matching string // which satisfies given pattern // Example: -// - Fetch last pattern matching on string -// Pattern: {,.*:\[.*} string: "key1,key2,key3:[v1, v2, v3]" -// Return value: key3:[v1, v2, v3] +// - Fetch last pattern matching on string +// Pattern: {,.*:\[.*} string: "key1,key2,key3:[v1, v2, v3]" +// Return value: key3:[v1, v2, v3] func getRightMostMatchingString(regex *regexp.Regexp, value string) string { loc := regex.FindStringIndex(value) if len(loc) == 0 { diff --git a/provisioner/provisioner.go b/provisioner/provisioner.go index b2dcd52..a93b966 100644 --- a/provisioner/provisioner.go +++ b/provisioner/provisioner.go @@ -63,7 +63,8 @@ var ( ) // NewProvisioner will create a new Provisioner object and initialize -// it with global information used across PV create and delete operations. +// +// it with global information used across PV create and delete operations. func NewProvisioner(ctx context.Context, kubeClient *clientset.Clientset) (*Provisioner, error) { namespace := getOpenEBSNamespace() @@ -123,13 +124,15 @@ func NewProvisioner(ctx context.Context, kubeClient *clientset.Clientset) (*Prov } // SupportsBlock will be used by controller to determine if block mode is -// supported by the host path provisioner. +// +// supported by the host path provisioner. func (p *Provisioner) SupportsBlock() bool { return false } // Provision is invoked by the PVC controller which expect the PV -// to be provisioned and a valid PV spec returned. +// +// to be provisioned and a valid PV spec returned. func (p *Provisioner) Provision(ctx context.Context, opts pvController.ProvisionOptions) (*v1.PersistentVolume, pvController.ProvisioningState, error) { pvc := opts.PVC @@ -191,9 +194,10 @@ func (p *Provisioner) Provision(ctx context.Context, opts pvController.Provision } // Delete is invoked by the PVC controller to perform clean-up -// activities before deleteing the PV object. If reclaim policy is -// set to not-retain, then this function will create a helper pod -// to delete the host path from the node. +// +// activities before deleteing the PV object. If reclaim policy is +// set to not-retain, then this function will create a helper pod +// to delete the host path from the node. func (p *Provisioner) Delete(ctx context.Context, pv *v1.PersistentVolume) (err error) { p.pvTracker.Add(pv.Name) defer p.pvTracker.Delete(pv.Name) diff --git a/provisioner/provisioner_kernel_nfs_server.go b/provisioner/provisioner_kernel_nfs_server.go index ba8a235..7b2a591 100644 --- a/provisioner/provisioner_kernel_nfs_server.go +++ b/provisioner/provisioner_kernel_nfs_server.go @@ -31,7 +31,8 @@ import ( ) // ProvisionKernalNFSServer is invoked by the Provisioner to create a NFS -// with kernel NFS server +// +// with kernel NFS server func (p *Provisioner) ProvisionKernalNFSServer(ctx context.Context, opts pvController.ProvisionOptions, volumeConfig *VolumeConfig) (*v1.PersistentVolume, error) { var leaseTime, graceTime int var leaseErr, graceErr error @@ -174,8 +175,9 @@ func (p *Provisioner) ProvisionKernalNFSServer(ctx context.Context, opts pvContr } // DeleteKernalNFSServer is invoked by the PVC controller to perform clean-up -// activities before deleteing the PV object. If reclaim policy is -// set to not-retain, then this function will delete the associated BDC +// +// activities before deleteing the PV object. If reclaim policy is +// set to not-retain, then this function will delete the associated BDC func (p *Provisioner) DeleteKernalNFSServer(ctx context.Context, pv *v1.PersistentVolume) (err error) { defer func() { err = errors.Wrapf(err, "failed to delete volume %v", pv.Name) diff --git a/provisioner/signal_handler.go b/provisioner/signal_handler.go index a26c02d..a33483b 100644 --- a/provisioner/signal_handler.go +++ b/provisioner/signal_handler.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog/v2" ) -//RegisterShutdownChannel closes the channel when signaled for termination +// RegisterShutdownChannel closes the channel when signaled for termination func RegisterShutdownChannel(cancelFn context.CancelFunc) { sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) diff --git a/provisioner/types.go b/provisioner/types.go index e5c1c88..c804dcd 100644 --- a/provisioner/types.go +++ b/provisioner/types.go @@ -27,7 +27,7 @@ import ( listerv1 "k8s.io/client-go/listers/core/v1" ) -//Provisioner struct has the configuration and utilities required +// Provisioner struct has the configuration and utilities required // across the different work-flows. type Provisioner struct { stopCh <-chan struct{} @@ -68,20 +68,21 @@ type Provisioner struct { hook *nfshook.Hook } -//VolumeConfig struct contains the merged configuration of the PVC +// VolumeConfig struct contains the merged configuration of the PVC // and the associated SC. The configuration is derived from the // annotation `cas.openebs.io/config`. The configuration will be // in the following json format: -// { -// Key1:{ -// enabled: true -// value: "string value" -// }, -// Key2:{ -// enabled: true -// value: "string value" -// }, -// } +// +// { +// Key1:{ +// enabled: true +// value: "string value" +// }, +// Key2:{ +// enabled: true +// value: "string value" +// }, +// } type VolumeConfig struct { pvName string pvcName string @@ -91,7 +92,8 @@ type VolumeConfig struct { } // GetVolumeConfigFn allows to plugin a custom function -// and makes it easy to unit test provisioner +// +// and makes it easy to unit test provisioner type GetVolumeConfigFn func(pvName string, pvc *corev1.PersistentVolumeClaim) (*VolumeConfig, error) // NodeAffinity represents group of node affinity scheduling @@ -99,53 +101,54 @@ type GetVolumeConfigFn func(pvName string, pvc *corev1.PersistentVolumeClaim) (* // not configured then matches to no object i.e NFS Server can // schedule on any node in a cluster. Configured values will be // propogated to deployment.spec.template.spec.affinity.nodeAffinity. -// requiredDuringSchedulingIgnoredDuringExecution +// +// requiredDuringSchedulingIgnoredDuringExecution // // Values are propagated via ENV(NodeAffinity) on NFS Provisioner. // Example: Following can be various options to specify NodeAffinity rules // -// Config 1: Configure across zones and also storage should be available -// Env Value: "kubernetes.io/hostName:[z1-host1,z2-host1,z3-host1],kubernetes.io/storage:[available]" +// Config 1: Configure across zones and also storage should be available +// Env Value: "kubernetes.io/hostName:[z1-host1,z2-host1,z3-host1],kubernetes.io/storage:[available]" // -// Config 1 will be propogated as shown below on NFS-Server deployment -// nodeSelectorTerms: -// - matchExpressions: -// - key: kubernetes.io/hostName -// operator: "In" -// values: -// - z1-host1 -// - z2-host2 -// - z3-host3 -// - key: kubernetes.io/storage -// operator: "In" -// values: -// - available +// Config 1 will be propogated as shown below on NFS-Server deployment +// nodeSelectorTerms: +// - matchExpressions: +// - key: kubernetes.io/hostName +// operator: "In" +// values: +// - z1-host1 +// - z2-host2 +// - z3-host3 +// - key: kubernetes.io/storage +// operator: "In" +// values: +// - available // -// Config2: Configure on storage nodes in zone1 -// Env Value: "kubernetes.io/storage:[],kubernetes.io/zone:[zone1]" +// Config2: Configure on storage nodes in zone1 +// Env Value: "kubernetes.io/storage:[],kubernetes.io/zone:[zone1]" // -// Config2 will be propogated as shown below on NFS-Server deployment -// nodeSelectorTerms: -// - matchExpressions: -// - key: kubernetes.io/storage -// operator: "Exists" -// - key: kubernetes.io/zone -// operator: "In" -// values: -// - zone1 +// Config2 will be propogated as shown below on NFS-Server deployment +// nodeSelectorTerms: +// - matchExpressions: +// - key: kubernetes.io/storage +// operator: "Exists" +// - key: kubernetes.io/zone +// operator: "In" +// values: +// - zone1 // // -// Configi3: Configure on any storage node -// Env Value: "kubernetes.io/storage:[]" +// Configi3: Configure on any storage node +// Env Value: "kubernetes.io/storage:[]" // -// Config3 will be propogated as below on NFS-Server deployment -// nodeSelectorTerms: -// - matchExpressions: -// - key: kubernetes.io/storage -// operator: "Exists" +// Config3 will be propogated as below on NFS-Server deployment +// nodeSelectorTerms: +// - matchExpressions: +// - key: kubernetes.io/storage +// operator: "Exists" // -// Like shown above various combinations can be specified and before -// provisioning configuration will be validated +// Like shown above various combinations can be specified and before +// provisioning configuration will be validated // // NOTE: All the comma separated specification will be ANDed type NodeAffinity struct {