Skip to content

Commit 8b51076

Browse files
committed
Better Offline resize handling
+ podman build files
1 parent fa6a3ae commit 8b51076

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Improvements
6+
7+
* Volume Expansion: Set capability to OFFLINE for proper offline expansion behavior and provide error message
8+
39
## v0.31.2
410

511
### Improvements

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ include go.mk/public.mk
4646
# Docker
4747
go.mk/init.mk:
4848
include Makefile.docker
49+
50+
# Podman
51+
go.mk/init.mk:
52+
include Makefile.podman

Makefile.podman

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
go.mk/version.mk:
2+
include go.mk/version.mk
3+
4+
# Default to same image as docker, but allow override with CSI_IMAGE env var
5+
CSI_IMAGE ?= exoscale/csi-driver
6+
# Allow overriding the latest tag behavior
7+
CSI_TAG ?= latest
8+
9+
.PHONY: podman
10+
podman:
11+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(MAKE) build
12+
podman build --platform linux/amd64 --rm \
13+
-t ${CSI_IMAGE}:${CSI_TAG} \
14+
--build-arg VERSION="${VERSION}" \
15+
--build-arg VCS_REF="${GIT_REVISION}" \
16+
--build-arg BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")" \
17+
-f ./Dockerfile \
18+
bin/
19+
podman tag ${CSI_IMAGE}:${CSI_TAG} ${CSI_IMAGE}:${VERSION}
20+
21+
.PHONY: podman-push
22+
podman-push:
23+
podman push ${CSI_IMAGE}:${CSI_TAG} \
24+
&& podman push ${CSI_IMAGE}:${VERSION}
25+

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,20 @@ make build
7070
```
7171

7272
Or you can build a container image
73+
74+
### Using Docker
7375
```Bash
7476
make docker
7577
```
7678

79+
### Using Podman
80+
```Bash
81+
gmake podman
82+
# Override: CSI_IMAGE=myregistry/image CSI_TAG=v1.0.0 gmake podman
83+
```
84+
85+
**Note**: Podman explicitly targets `linux/amd64` for compatibility when building on ARM64 Macs for Intel Kubernetes nodes. The CSI driver works without this targeting, but some filesystem features like volume expansion require proper architecture matching.
86+
7787
## Versioning and compatibility policy
7888

7989
The Exoscale CSI adheres to [Semantic Versioning](https://semver.org/).

driver/controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi
691691
return nil, err
692692
}
693693

694-
_, err = client.GetBlockStorageVolume(ctx, volumeID)
694+
volume, err := client.GetBlockStorageVolume(ctx, volumeID)
695695
if err != nil {
696696
if errors.Is(err, v3.ErrNotFound) {
697697
return nil, status.Errorf(codes.NotFound, "volume %s not found", volumeID)
@@ -718,6 +718,13 @@ func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi
718718
return nil, status.Errorf(codes.OutOfRange, "invalid capacity range: %v", err)
719719
}
720720

721+
// Check if volume is attached to any instance
722+
if volume.Instance != nil && volume.Instance.ID != "" {
723+
instanceInfo := fmt.Sprintf(" (attached to instance %s)", volume.Instance.ID)
724+
return nil, status.Error(codes.FailedPrecondition,
725+
"Volume must be detached before expanding"+instanceInfo+". Scale down workloads using this PVC, then resize will complete automatically once Kubernetes retries.")
726+
}
727+
721728
if newSizeInBytes%GiB != 0 {
722729
msg := "requested size in bytes cannot be exactly converted to GiB: %d"
723730

driver/identity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
4242
{
4343
Type: &csi.PluginCapability_VolumeExpansion_{
4444
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
45-
Type: csi.PluginCapability_VolumeExpansion_ONLINE,
45+
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
4646
},
4747
},
4848
},

0 commit comments

Comments
 (0)