Skip to content

Commit b9abf99

Browse files
author
Power Cloud Robot
authored
Merge pull request #43 from Madhan-SWE/waitloop
Waitloop added for volume creation
2 parents 605022b + e41f790 commit b9abf99

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pkg/cloud/cloud_interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Cloud interface {
2222
AttachDisk(volumeID string, nodeID string) (err error)
2323
DetachDisk(volumeID string, nodeID string) (err error)
2424
ResizeDisk(volumeID string, reqSize int64) (newSize int64, err error)
25-
WaitForAttachmentState(volumeID, state string) error
25+
WaitForVolumeState(volumeID, state string) error
2626
GetDiskByName(name string) (disk *Disk, err error)
2727
GetDiskByID(volumeID string) (disk *Disk, err error)
2828
GetPVMInstanceByName(instanceName string) (instance *PVMInstance, err error)

pkg/cloud/powervs.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ func (p *powerVSCloud) CreateDisk(volumeName string, diskOptions *DiskOptions) (
250250
return nil, err
251251
}
252252

253+
err = p.WaitForVolumeState(*v.VolumeID, VolumeAvailableState)
254+
if err != nil {
255+
return nil, err
256+
}
257+
253258
return &Disk{CapacityGiB: capacityGiB, VolumeID: *v.VolumeID, DiskType: v.DiskType, WWN: strings.ToLower(v.Wwn)}, nil
254259
}
255260

@@ -268,7 +273,7 @@ func (p *powerVSCloud) AttachDisk(volumeID string, nodeID string) (err error) {
268273
return err
269274
}
270275

271-
err = p.WaitForAttachmentState(volumeID, VolumeInUseState)
276+
err = p.WaitForVolumeState(volumeID, VolumeInUseState)
272277
if err != nil {
273278
return err
274279
}
@@ -280,7 +285,7 @@ func (p *powerVSCloud) DetachDisk(volumeID string, nodeID string) (err error) {
280285
if err != nil {
281286
return err
282287
}
283-
err = p.WaitForAttachmentState(volumeID, VolumeAvailableState)
288+
err = p.WaitForVolumeState(volumeID, VolumeAvailableState)
284289
if err != nil {
285290
return err
286291
}
@@ -309,7 +314,7 @@ func (p *powerVSCloud) ResizeDisk(volumeID string, reqSize int64) (newSize int64
309314
return int64(*v.Size), nil
310315
}
311316

312-
func (p *powerVSCloud) WaitForAttachmentState(volumeID, state string) error {
317+
func (p *powerVSCloud) WaitForVolumeState(volumeID, state string) error {
313318
err := wait.PollImmediate(PollInterval, PollTimeout, func() (bool, error) {
314319
v, err := p.volClient.Get(volumeID, p.cloudInstanceID, TIMEOUT)
315320
if err != nil {

tests/e2e/pre_provisioning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var _ = Describe("[powervs-csi-e2e]Pre-Provisioned", func() {
9494
AfterEach(func() {
9595
skipManuallyDeletingVolume = true
9696
if !skipManuallyDeletingVolume {
97-
err := cloud.WaitForAttachmentState(volumeID, "detached")
97+
err := cloud.WaitForVolumeState(volumeID, "detached")
9898
if err != nil {
9999
Fail(fmt.Sprintf("could not detach volume %q: %v", volumeID, err))
100100
}

0 commit comments

Comments
 (0)