Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/csi/blockstorage/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,10 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi

// we need wait for the volume to be available or InUse, it might be error_extending in some scenario
targetStatus := []string{stackit.VolumeAvailableStatus, stackit.VolumeAttachedStatus}
err = cloud.WaitVolumeTargetStatus(ctx, volumeID, targetStatus)
err = cloud.WaitVolumeTargetStatus(ctx, volumeID, targetStatus, volSizeGB)
if err != nil {
klog.Errorf("Failed to WaitVolumeTargetStatus of volume %s: %v", volumeID, err)
return nil, status.Errorf(codes.Internal, "[ControllerExpandVolume] Volume %s not in target state after resize operation: %v", volumeID, err)
return nil, status.Errorf(codes.Internal, "[ControllerExpandVolume] Volume %s not in target state or size after resize operation: %v", volumeID, err)
}

klog.V(4).Infof("ControllerExpandVolume resized volume %v to size %v", volumeID, volSizeGB)
Expand Down
2 changes: 1 addition & 1 deletion pkg/stackit/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type IaasClient interface {
WaitDiskAttached(ctx context.Context, instanceID string, volumeID string) error
DetachVolume(ctx context.Context, instanceID, volumeID string) error
WaitDiskDetached(ctx context.Context, instanceID string, volumeID string) error
WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string) error
WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string, tSize int64) error
GetVolume(ctx context.Context, volumeID string) (*iaas.Volume, error)
GetVolumesByName(ctx context.Context, name string) ([]iaas.Volume, error)
GetVolumeByName(ctx context.Context, name string) (*iaas.Volume, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/stackit/iaas_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions pkg/stackit/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,32 @@ func (os *iaasClient) GetVolumeByName(ctx context.Context, name string) (*iaas.V
return &vols[0], nil
}

func (os *iaasClient) WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string) error {
func (os *iaasClient) WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string, tSize int64) error {
backoff := wait.Backoff{
Duration: operationFinishInitDelay,
Factor: operationFinishFactor,
Steps: operationFinishSteps,
}

// volResizeSuccess checks if the volume is an "GOOD" State and the target Size has
// been met.
volResizeSuccess := func(vol *iaas.Volume, tSize int64, tStatus []string) bool {
if slices.Contains(tStatus, *vol.Status) {
if tSize == vol.GetSize() {
return true
}
return false
}
return false
}

waitErr := wait.ExponentialBackoff(backoff, func() (bool, error) {
vol, err := os.GetVolume(ctx, volumeID)
if err != nil {
return false, err
}
if slices.Contains(tStatus, *vol.Status) {
// Check status
if volResizeSuccess(vol, tSize, tStatus) {
return true, nil
}
for _, eState := range volumeErrorStates {
Expand Down