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. 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 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 diff --git a/driver/controller.go b/driver/controller.go index 89270393..b8b27c9f 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,27 @@ 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 + } + } + + 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.Warn("Volume is not attached to node given in request.") + return &csi.ControllerUnpublishVolumeResponse{}, nil + } + + ll.Info("Volume is attached to node given in request or NodeID in request is not set.") + detachRequest := &cloudscale.VolumeRequest{ ServerUUIDs: &[]string{}, } 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"