diff --git a/.github/workflows/pull-request-commentor.yaml b/.github/workflows/pull-request-commentor.yaml index 7c6c6e7491e..09089baea14 100644 --- a/.github/workflows/pull-request-commentor.yaml +++ b/.github/workflows/pull-request-commentor.yaml @@ -18,24 +18,14 @@ jobs: strategy: matrix: - branch: [release-v3.9, release-v3.10, devel] - k8s: ["1.25", "1.26", "1.27", "1.28", "1.29"] + branch: [release-v3.10, release-v3.11, devel] + k8s: ["1.26", "1.27", "1.28", "1.29"] exclude: # the next Ceph-CSI version will not be tested with old Kubernetes - k8s: "1.26" branch: "devel" - - k8s: "1.25" - branch: "devel" - - k8s: "1.25" - branch: "release-v3.10" - - # Ceph-CSI <= 3.9 was released before Kubernetes 1.28 - - k8s: "1.28" - branch: "release-v3.9" # Ceph-CSI <= 3.10 was released before Kubernetes 1.29 - - k8s: "1.29" - branch: "release-v3.9" - k8s: "1.29" branch: "release-v3.10" diff --git a/.mergify.yml b/.mergify.yml index ed1bc1a3092..50c2df9cb86 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -68,22 +68,25 @@ queue_rules: - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - and: - - base=release-v3.9 + - base=release-v3.11 - "status-success=codespell" - "status-success=multi-arch-build" - "status-success=go-test" - "status-success=golangci-lint" - "status-success=mod-check" - "status-success=lint-extras" - - "status-success=ci/centos/k8s-e2e-external-storage/1.25" - "status-success=ci/centos/k8s-e2e-external-storage/1.26" - "status-success=ci/centos/k8s-e2e-external-storage/1.27" - - "status-success=ci/centos/mini-e2e-helm/k8s-1.25" + - "status-success=ci/centos/k8s-e2e-external-storage/1.28" + - "status-success=ci/centos/k8s-e2e-external-storage/1.29" - "status-success=ci/centos/mini-e2e-helm/k8s-1.26" - "status-success=ci/centos/mini-e2e-helm/k8s-1.27" - - "status-success=ci/centos/mini-e2e/k8s-1.25" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.28" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.29" - "status-success=ci/centos/mini-e2e/k8s-1.26" - "status-success=ci/centos/mini-e2e/k8s-1.27" + - "status-success=ci/centos/mini-e2e/k8s-1.28" + - "status-success=ci/centos/mini-e2e/k8s-1.29" - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - and: @@ -162,15 +165,15 @@ pull_request_rules: - "status-success=golangci-lint" - "status-success=mod-check" - "status-success=lint-extras" - - "status-success=ci/centos/k8s-e2e-external-storage/1.25" - "status-success=ci/centos/k8s-e2e-external-storage/1.26" - "status-success=ci/centos/k8s-e2e-external-storage/1.27" - - "status-success=ci/centos/mini-e2e-helm/k8s-1.25" + - "status-success=ci/centos/k8s-e2e-external-storage/1.28" - "status-success=ci/centos/mini-e2e-helm/k8s-1.26" - "status-success=ci/centos/mini-e2e-helm/k8s-1.27" - - "status-success=ci/centos/mini-e2e/k8s-1.25" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.28" - "status-success=ci/centos/mini-e2e/k8s-1.26" - "status-success=ci/centos/mini-e2e/k8s-1.27" + - "status-success=ci/centos/mini-e2e/k8s-1.28" - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - "status-success=DCO" @@ -246,7 +249,7 @@ pull_request_rules: - "status-success=ci/centos/upgrade-tests-rbd" - and: - label!=DNM - - base=release-v3.10 + - base=release-v3.11 - "#approved-reviews-by>=2" - "#changes-requested-reviews-by=0" - "approved-reviews-by=@ceph/ceph-csi-contributors" @@ -262,17 +265,20 @@ pull_request_rules: - "status-success=ci/centos/k8s-e2e-external-storage/1.26" - "status-success=ci/centos/k8s-e2e-external-storage/1.27" - "status-success=ci/centos/k8s-e2e-external-storage/1.28" + - "status-success=ci/centos/k8s-e2e-external-storage/1.29" - "status-success=ci/centos/mini-e2e-helm/k8s-1.26" - "status-success=ci/centos/mini-e2e-helm/k8s-1.27" - "status-success=ci/centos/mini-e2e-helm/k8s-1.28" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.29" - "status-success=ci/centos/mini-e2e/k8s-1.26" - "status-success=ci/centos/mini-e2e/k8s-1.27" - "status-success=ci/centos/mini-e2e/k8s-1.28" + - "status-success=ci/centos/mini-e2e/k8s-1.29" - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - and: - label!=DNM - - base=release-v3.9 + - base=release-v3.10 - "#approved-reviews-by>=2" - "#changes-requested-reviews-by=0" - "approved-reviews-by=@ceph/ceph-csi-contributors" @@ -284,15 +290,15 @@ pull_request_rules: - "status-success=commitlint" - "status-success=mod-check" - "status-success=lint-extras" - - "status-success=ci/centos/k8s-e2e-external-storage/1.25" - "status-success=ci/centos/k8s-e2e-external-storage/1.26" - "status-success=ci/centos/k8s-e2e-external-storage/1.27" - - "status-success=ci/centos/mini-e2e-helm/k8s-1.25" + - "status-success=ci/centos/k8s-e2e-external-storage/1.28" - "status-success=ci/centos/mini-e2e-helm/k8s-1.26" - "status-success=ci/centos/mini-e2e-helm/k8s-1.27" - - "status-success=ci/centos/mini-e2e/k8s-1.25" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.28" - "status-success=ci/centos/mini-e2e/k8s-1.26" - "status-success=ci/centos/mini-e2e/k8s-1.27" + - "status-success=ci/centos/mini-e2e/k8s-1.28" - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - "status-success=DCO" @@ -343,15 +349,18 @@ pull_request_rules: - "status-success=mod-check" - "status-success=lint-extras" - "#changes-requested-reviews-by=0" - - "status-success=ci/centos/k8s-e2e-external-storage/1.25" - "status-success=ci/centos/k8s-e2e-external-storage/1.26" - "status-success=ci/centos/k8s-e2e-external-storage/1.27" - - "status-success=ci/centos/mini-e2e-helm/k8s-1.25" + - "status-success=ci/centos/k8s-e2e-external-storage/1.28" + - "status-success=ci/centos/k8s-e2e-external-storage/1.29" - "status-success=ci/centos/mini-e2e-helm/k8s-1.26" - "status-success=ci/centos/mini-e2e-helm/k8s-1.27" - - "status-success=ci/centos/mini-e2e/k8s-1.25" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.28" + - "status-success=ci/centos/mini-e2e-helm/k8s-1.29" - "status-success=ci/centos/mini-e2e/k8s-1.26" - "status-success=ci/centos/mini-e2e/k8s-1.27" + - "status-success=ci/centos/mini-e2e/k8s-1.28" + - "status-success=ci/centos/mini-e2e/k8s-1.29" - "status-success=ci/centos/upgrade-tests-cephfs" - "status-success=ci/centos/upgrade-tests-rbd" - "status-success=DCO" @@ -385,23 +394,23 @@ pull_request_rules: name: default delete_head_branch: {} - - name: backport patches to release-v3.9 branch + - name: backport patches to release-v3.10 branch conditions: - base=devel - - label=backport-to-release-v3.9 + - label=backport-to-release-v3.10 actions: backport: branches: - - release-v3.9 + - release-v3.10 - - name: backport patches to release-v3.10 branch + - name: backport patches to release-v3.11 branch conditions: - base=devel - - label=backport-to-release-v3.10 + - label=backport-to-release-v3.11 actions: backport: branches: - - release-v3.10 + - release-v3.11 - name: remove outdated approvals on ci/centos conditions: diff --git a/README.md b/README.md index fe804bb416c..28e22fba912 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,10 @@ environments. | Ceph CSI Version | Container Orchestrator Name | Version Tested | | -----------------| --------------------------- | -------------------| +| v3.11.0 | Kubernetes | v1.26, v1.27, v1.28, v1.29| +| v3.10.2 | Kubernetes | v1.26, v1.27, v1.28| +| v3.10.1 | Kubernetes | v1.26, v1.27, v1.28| | v3.10.0 | Kubernetes | v1.26, v1.27, v1.28| -| v3.9.0 | Kubernetes | v1.25, v1.26, v1.27| There is work in progress to make this CO-independent and thus support other orchestration environments (Nomad, Mesos..etc). @@ -128,11 +130,14 @@ in the Kubernetes documentation. | Ceph CSI Release/Branch | Container image name | Image Tag | | ----------------------- | ---------------------------- | --------- | | devel (Branch) | quay.io/cephcsi/cephcsi | canary | +| v3.11.0 (Release) | quay.io/cephcsi/cephcsi | v3.11.0 | +| v3.10.2 (Release) | quay.io/cephcsi/cephcsi | v3.10.2 | +| v3.10.1 (Release) | quay.io/cephcsi/cephcsi | v3.10.1 | | v3.10.0 (Release) | quay.io/cephcsi/cephcsi | v3.10.0 | -| v3.9.0 (Release) | quay.io/cephcsi/cephcsi | v3.9.0 | | Deprecated Ceph CSI Release/Branch | Container image name | Image Tag | | ----------------------- | --------------------------------| --------- | +| v3.9.0 (Release) | quay.io/cephcsi/cephcsi | v3.9.0 | | v3.8.1 (Release) | quay.io/cephcsi/cephcsi | v3.8.1 | | v3.8.0 (Release) | quay.io/cephcsi/cephcsi | v3.8.0 | | v3.7.2 (Release) | quay.io/cephcsi/cephcsi | v3.7.2 | diff --git a/actions/retest/Dockerfile b/actions/retest/Dockerfile index 10c7e61e66e..f2c237af30b 100644 --- a/actions/retest/Dockerfile +++ b/actions/retest/Dockerfile @@ -1,5 +1,5 @@ ARG WORK_DIR="/home/src" -ARG BASE_IMAGE="golang:1.18" +ARG BASE_IMAGE="golang:1.21" FROM ${BASE_IMAGE} as builder diff --git a/actions/retest/main.go b/actions/retest/main.go index 26ef0b610d8..b9889536b54 100644 --- a/actions/retest/main.go +++ b/actions/retest/main.go @@ -22,6 +22,7 @@ import ( "fmt" "log" "os" + "slices" "strconv" "strings" @@ -145,7 +146,7 @@ func main() { failedTestFound := false for _, r := range statusList { log.Printf("found context %s with status %s\n", r.GetContext(), r.GetState()) - if contains([]string{"failed", "failure"}, r.GetState()) { + if slices.Contains([]string{"failed", "failure"}, r.GetState()) { log.Printf("found failed test %s\n", r.GetContext()) failedTestFound = true // rebase the pr if it is behind the devel branch. @@ -253,17 +254,6 @@ func (c *retestConfig) checkRetestLimitReached(prNumber int, msg string) (bool, return false, nil } -// containers check if slice contains string. -func contains(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - - return false -} - // filterStatusesList returns list of unique and recently updated github RepoStatuses. // Raw github RepoStatus list may contain duplicate and older statuses. func filterStatusList(rawStatusList []*github.RepoStatus) []*github.RepoStatus { diff --git a/docs/ceph-csi-upgrade.md b/docs/ceph-csi-upgrade.md index f37890e3f8a..2cc7675fd3e 100644 --- a/docs/ceph-csi-upgrade.md +++ b/docs/ceph-csi-upgrade.md @@ -4,7 +4,7 @@ - [Pre-upgrade considerations](#pre-upgrade-considerations) - [Snapshot-controller and snapshot crd](#snapshot-controller-and-snapshot-crd) - [Upgrading from previous releases](#upgrading-from-previous-releases) - - [Upgrading from v3.9 to v3.10](#upgrading-from-v39-to-v310) + - [Upgrading from v3.10 to v3.11](#upgrading-from-v310-to-v311) - [Upgrading CephFS](#upgrading-cephfs) - [1. Upgrade CephFS Provisioner resources](#1-upgrade-cephfs-provisioner-resources) - [1.1 Update the CephFS Provisioner RBAC](#11-update-the-cephfs-provisioner-rbac) @@ -49,7 +49,7 @@ To avoid this issue in future upgrades, we recommend that you do not use the fuse client as of now. This guide will walk you through the steps to upgrade the software in a cluster -from v3.9 to v3.10 +from v3.10 to v3.11 ### Snapshot-controller and snapshot crd @@ -77,8 +77,10 @@ To upgrade from previous releases, refer to the following: to upgrade from cephcsi v3.7 to v3.8 - [upgrade-from-v3.8-v3.9](https://github.com/ceph/ceph-csi/blob/v3.9.0/docs/ceph-csi-upgrade.md) to upgrade from cephcsi v3.8 to v3.9 +- [upgrade-from-v3.9-v3.10](https://github.com/ceph/ceph-csi/blob/v3.10.0/docs/ceph-csi-upgrade.md) + to upgrade from cephcsi v3.9 to v3.10 -## Upgrading from v3.9 to v3.10 +## Upgrading from v3.10 to v3.11 **Ceph-csi releases from devel are expressly unsupported.** It is strongly recommended that you use [official @@ -88,19 +90,19 @@ that will not be supported in the official releases. Builds from the devel branch can have functionality changed and even removed at any time without compatibility support and without prior notice. -**Also, we do not recommend any direct upgrades to 3.10 except from 3.9 to 3.10.** -For example, upgrading from 3.8 to 3.10 is not recommended. +**Also, we do not recommend any direct upgrades to 3.11 except from 3.10 to 3.11.** +For example, upgrading from 3.8 to 3.11 is not recommended. **Refer to the Breaking Changes Section in the -[release notes](https://github.com/ceph/ceph-csi/releases/tag/v3.10.0) before +[release notes](https://github.com/ceph/ceph-csi/releases/tag/v3.11.0) before proceeding further.** -git checkout v3.10.0 tag +git checkout v3.11.0 tag ```bash git clone https://github.com/ceph/ceph-csi.git cd ./ceph-csi -git checkout v3.10.0 +git checkout v3.11.0 ``` ```console @@ -222,7 +224,7 @@ For each node: - The pod deletion causes the pods to be restarted and updated automatically on the node. -we have successfully upgraded cephfs csi from v3.9 to v3.10 +we have successfully upgraded cephfs csi from v3.10 to v3.11 ### Upgrading RBD @@ -286,7 +288,7 @@ daemonset.apps/csi-rbdplugin configured service/csi-metrics-rbdplugin configured ``` -we have successfully upgraded RBD csi from v3.9 to v3.10 +we have successfully upgraded RBD csi from v3.10 to v3.11 ### Upgrading NFS @@ -348,7 +350,7 @@ daemonset.apps/csi-nfsplugin configured service/csi-metrics-nfsplugin configured ``` -we have successfully upgraded nfs csi from v3.9 to v3.10 +we have successfully upgraded nfs csi from v3.10 to v3.11 ### CSI Sidecar containers consideration diff --git a/e2e/deployment.go b/e2e/deployment.go index 27a831791e9..1e7de8f7be8 100644 --- a/e2e/deployment.go +++ b/e2e/deployment.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "os" + "slices" "time" appsv1 "k8s.io/api/apps/v1" @@ -349,17 +350,6 @@ func waitForDeploymentUpdate( return nil } -// contains check if slice contains string. -func contains(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - - return false -} - func waitForContainersArgsUpdate( c kubernetes.Interface, ns, @@ -398,7 +388,7 @@ func waitForContainersArgsUpdate( } cid := deployment.Spec.Template.Spec.Containers // cid: read as containers in deployment for i := range cid { - if contains(containers, cid[i].Name) { + if slices.Contains(containers, cid[i].Name) { match := false for j, ak := range cid[i].Args { if ak == key { diff --git a/e2e/rbd.go b/e2e/rbd.go index c8b71817b36..8dd577e3f24 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -2006,7 +2006,7 @@ var _ = Describe("RBD", func() { "mapOptions": nbdMapOptions, "cephLogStrategy": e2eDefaultCephLogStrategy, "encrypted": "true", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), }, deletePolicy) if err != nil { @@ -2041,7 +2041,7 @@ var _ = Describe("RBD", func() { f, defaultSCName, nil, - map[string]string{"encrypted": "true", "encryptionType": util.EncryptionTypeString(encType)}, + map[string]string{"encrypted": "true", "encryptionType": encType.String()}, deletePolicy) if err != nil { framework.Failf("failed to create storageclass: %v", err) @@ -2075,7 +2075,7 @@ var _ = Describe("RBD", func() { f, defaultSCName, nil, - map[string]string{"encrypted": "true", "encryptionType": util.EncryptionTypeString(encType)}, + map[string]string{"encrypted": "true", "encryptionType": encType.String()}, deletePolicy) if err != nil { framework.Failf("failed to create storageclass: %v", err) @@ -2120,7 +2120,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2153,7 +2153,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-tokens-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2207,7 +2207,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-tenant-sa-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2246,7 +2246,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "secrets-metadata-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2279,7 +2279,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "user-ns-secrets-metadata-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2333,7 +2333,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "user-secrets-metadata-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2460,7 +2460,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2494,7 +2494,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2504,7 +2504,7 @@ var _ = Describe("RBD", func() { scOpts = map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-tenant-sa-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, restoreSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2554,7 +2554,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2564,7 +2564,7 @@ var _ = Describe("RBD", func() { scOpts = map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-tenant-sa-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, restoreSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2617,7 +2617,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "secrets-metadata-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -2655,7 +2655,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -4202,7 +4202,7 @@ var _ = Describe("RBD", func() { scOpts := map[string]string{ "encrypted": "true", "encryptionKMSID": "vault-test", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), } err := createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) if err != nil { @@ -4264,7 +4264,7 @@ var _ = Describe("RBD", func() { ) { scOpts := map[string]string{ "encrypted": "true", - "encryptionType": util.EncryptionTypeString(encType), + "encryptionType": encType.String(), "encryptionKMSID": "vault-test", } err := createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy) diff --git a/internal/journal/voljournal.go b/internal/journal/voljournal.go index 9782159ac05..c5ba047e777 100644 --- a/internal/journal/voljournal.go +++ b/internal/journal/voljournal.go @@ -387,8 +387,8 @@ func (conn *Connection) CheckReservation(ctx context.Context, if savedImageAttributes.EncryptionType != encryptionType { return nil, fmt.Errorf("internal state inconsistent, omap encryption type"+ " mismatch, request type %q(%d) volume UUID (%s) volume omap encryption type %q (%d)", - util.EncryptionTypeString(encryptionType), encryptionType, - objUUID, util.EncryptionTypeString(savedImageAttributes.EncryptionType), + encryptionType, encryptionType, + objUUID, savedImageAttributes.EncryptionType, savedImageAttributes.EncryptionType) } } @@ -561,7 +561,7 @@ func (conn *Connection) ReserveName(ctx context.Context, imagePool string, imagePoolID int64, reqName, namePrefix, parentName, kmsConf, volUUID, owner, backingSnapshotID string, - encryptionType util.EncryptionType, + encryptionType util.EncryptionType, //nolint:interfacer // prefer util.EncryptionType over fmt.Stringer ) (string, string, error) { // TODO: Take in-arg as ImageAttributes? var ( @@ -642,7 +642,7 @@ func (conn *Connection) ReserveName(ctx context.Context, // Update UUID directory to store encryption values if kmsConf != "" { omapValues[cj.encryptKMSKey] = kmsConf - omapValues[cj.encryptionType] = util.EncryptionTypeString(encryptionType) + omapValues[cj.encryptionType] = encryptionType.String() } // if owner is passed, set it in the UUID directory too diff --git a/internal/rbd/clone.go b/internal/rbd/clone.go index c5ff1e52ff2..b2ce33ba508 100644 --- a/internal/rbd/clone.go +++ b/internal/rbd/clone.go @@ -183,6 +183,8 @@ func (rv *rbdVolume) doSnapClone(ctx context.Context, parentVol *rbdVolume) erro // generate temp cloned volume tempClone := rv.generateTempClone() + defer tempClone.Destroy() + // snapshot name is same as temporary cloned image, This helps to // flatten the temporary cloned images as we cannot have more than 510 // snapshots on an rbd image diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 4f07ce5f0d3..29e4af59933 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -669,6 +669,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot( parentVol := rbdSnap.toVolume() // as we are operating on single cluster reuse the connection parentVol.conn = rbdVol.conn.Copy() + defer parentVol.Destroy() // create clone image and delete snapshot err = rbdVol.cloneRbdImageFromSnapshot(ctx, rbdSnap, parentVol) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 31b330b4d37..c50ebedd2c9 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -1662,6 +1662,7 @@ func (ri *rbdImage) flattenParent(ctx context.Context, hardLimit, softLimit uint if parentImage == nil { return nil } + defer parentImage.Destroy() return parentImage.flattenRbdImage(ctx, false, hardLimit, softLimit) } diff --git a/internal/util/crypto.go b/internal/util/crypto.go index bae43808b0b..989788cc8b5 100644 --- a/internal/util/crypto.go +++ b/internal/util/crypto.go @@ -111,7 +111,7 @@ func ParseEncryptionType(typeStr string) EncryptionType { } } -func EncryptionTypeString(encType EncryptionType) string { +func (encType EncryptionType) String() string { switch encType { case EncryptionTypeBlock: return encryptionTypeBlockString diff --git a/internal/util/crypto_test.go b/internal/util/crypto_test.go index 4f4340ad5b8..1f2c54b3ac0 100644 --- a/internal/util/crypto_test.go +++ b/internal/util/crypto_test.go @@ -77,7 +77,7 @@ func TestEncryptionType(t *testing.T) { assert.EqualValues(t, EncryptionTypeNone, ParseEncryptionType("")) for _, s := range []string{"file", "block", ""} { - assert.EqualValues(t, s, EncryptionTypeString(ParseEncryptionType(s))) + assert.EqualValues(t, s, ParseEncryptionType(s).String()) } } diff --git a/internal/util/util.go b/internal/util/util.go index 1dbaf54eaec..76607f9db49 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -23,6 +23,7 @@ import ( "math" "os" "runtime" + "slices" "strings" "time" @@ -363,7 +364,7 @@ func MountOptionsAdd(options string, add ...string) string { } for _, opt := range add { - if opt != "" && !contains(newOpts, opt) { + if opt != "" && !slices.Contains(newOpts, opt) { newOpts = append(newOpts, opt) } } @@ -371,16 +372,6 @@ func MountOptionsAdd(options string, add ...string) string { return strings.Join(newOpts, ",") } -func contains(s []string, key string) bool { - for _, v := range s { - if v == key { - return true - } - } - - return false -} - // CallStack returns the stack of the calls in the current goroutine. Useful // for debugging or reporting errors. This is a friendly alternative to // assert() or panic().