From 502133e4603464565693e77cf5a44669f0c94925 Mon Sep 17 00:00:00 2001 From: Alain Kaeslin Date: Wed, 20 Mar 2024 14:35:22 +0100 Subject: [PATCH 1/6] Only send API request if NodeID is set in request and volume is attached to that node. --- driver/controller.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/driver/controller.go b/driver/controller.go index 89270393..1fcbee18 100644 --- a/driver/controller.go +++ b/driver/controller.go @@ -296,7 +296,7 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control ll.Info("controller unpublish volume called") // check if volume exist before trying to detach it - _, err := d.cloudscaleClient.Volumes.Get(ctx, req.VolumeId) + volume, err := d.cloudscaleClient.Volumes.Get(ctx, req.VolumeId) if err != nil { errorResponse, ok := err.(*cloudscale.ErrorResponse) if ok { @@ -308,6 +308,20 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control return nil, err } + isAttachedToNode := false + for _, serverUUID := range *volume.ServerUUIDs { + if serverUUID == req.NodeId { + isAttachedToNode = true + } + } + + if req.NodeId != "" && !isAttachedToNode { + ll.WithField("volume", volume).Warn("Volume is not attached to node given in request.") + return &csi.ControllerUnpublishVolumeResponse{}, nil + } + + ll.WithField("volume", volume).Warn("Volume is attached to node given in request or NodeID in request is not set.") + detachRequest := &cloudscale.VolumeRequest{ ServerUUIDs: &[]string{}, } From f0aa1a9a0e7bb33567b15e814c39e5128caa1831 Mon Sep 17 00:00:00 2001 From: Alain Kaeslin Date: Wed, 20 Mar 2024 15:24:29 +0100 Subject: [PATCH 2/6] Improve logging. --- driver/controller.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/driver/controller.go b/driver/controller.go index 1fcbee18..b8b27c9f 100644 --- a/driver/controller.go +++ b/driver/controller.go @@ -315,12 +315,19 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control } } + ll = ll.WithFields(logrus.Fields{ + "volume_api_uuid": volume.UUID, + "volume_api_name": volume.Name, + "volume_api_server": volume.ServerUUIDs, + "is_attached_to_node": isAttachedToNode, + }) + if req.NodeId != "" && !isAttachedToNode { - ll.WithField("volume", volume).Warn("Volume is not attached to node given in request.") + ll.Warn("Volume is not attached to node given in request.") return &csi.ControllerUnpublishVolumeResponse{}, nil } - ll.WithField("volume", volume).Warn("Volume is attached to node given in request or NodeID in request is not set.") + ll.Info("Volume is attached to node given in request or NodeID in request is not set.") detachRequest := &cloudscale.VolumeRequest{ ServerUUIDs: &[]string{}, From bbbf7dfad96754f2f61e48301e3e695cf3280513 Mon Sep 17 00:00:00 2001 From: Alain Kaeslin Date: Wed, 20 Mar 2024 15:24:39 +0100 Subject: [PATCH 3/6] Pin latest k8test. --- helpers/bootstrap-cluster | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/bootstrap-cluster b/helpers/bootstrap-cluster index 82ea131c..11bcdb4f 100755 --- a/helpers/bootstrap-cluster +++ b/helpers/bootstrap-cluster @@ -6,7 +6,7 @@ set -euo pipefail # Default values RANDOM_NUMBER=$((RANDOM % 8193)) -K8TEST_SHA="da91af6" +K8TEST_SHA="1190654" ZONE="lpg1" CLUSTER_PREFIX="csi-test-$RANDOM_NUMBER" KUBERNETES="latest" From b903e1be4b2c55a2ed5ad73b08b4772c199e0369 Mon Sep 17 00:00:00 2001 From: Julian Bigler Date: Thu, 21 Mar 2024 11:23:25 +0100 Subject: [PATCH 4/6] update alpine base image --- cmd/cloudscale-csi-plugin/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cloudscale-csi-plugin/Dockerfile b/cmd/cloudscale-csi-plugin/Dockerfile index e07866cd..17c42f74 100644 --- a/cmd/cloudscale-csi-plugin/Dockerfile +++ b/cmd/cloudscale-csi-plugin/Dockerfile @@ -11,7 +11,7 @@ # 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. -FROM alpine:3.17.6 +FROM alpine:3.17.7 # e2fsprogs-extra is required for resize2fs used for the resize operation # blkid: block device identification tool from util-linux From 1debaab0b155e00cc06d29f203db6ec1ec4f2ba0 Mon Sep 17 00:00:00 2001 From: Julian Bigler Date: Thu, 21 Mar 2024 11:49:36 +0100 Subject: [PATCH 5/6] add instructions how to verify csi installation --- deploy/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deploy/README.md b/deploy/README.md index 92d3699d..91da844f 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -35,6 +35,10 @@ You can **either** install the driver from your working directory # Install a specific Chart version or latest if --version is omitted helm install -n kube-system -g csi-cloudscale/csi-cloudscale [ --version v1.0.0 ] +You can verify that the csi-driver has been installed by running the following command and checking if the csi-cloudscale pods are running: + + kubectl get pods -n kube-system + Then execute the test suite: make test-integration From 63ccfe9b852b859e2016fbe8f04ad61bce750573 Mon Sep 17 00:00:00 2001 From: Julian Bigler Date: Thu, 21 Mar 2024 13:25:24 +0100 Subject: [PATCH 6/6] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 752c3974..52963b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## unreleased +* Take into account `ControllerUnpublishVolumeRequest.NodeId` in `ControllerUnpublishVolume` to prevent undesired detach operations during overlapping CSI calls. +* Update base image to newer alpine minor version. ## v3.5.4 - 2024.01.05 * Update base image to newer alpine minor version.