Skip to content

Commit 3b49f9e

Browse files
committed
fixes
1 parent 2c001ee commit 3b49f9e

9 files changed

Lines changed: 38 additions & 38 deletions

File tree

aws/aws.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
awsDevicePrefixWithH = "/dev/hd"
3535
awsDevicePrefixNvme = "/dev/nvme"
3636
contextTimeout = 30 * time.Second
37+
awsErrorModificationNotFound = "InvalidVolumeModification.NotFound"
3738
)
3839

3940
type awsOps struct {
@@ -942,37 +943,37 @@ func (s *awsOps) detachInternal(volumeID, instanceName string, options map[strin
942943
return err
943944
}
944945

945-
func (s *awsOps) getVolumeModificationState(volumeID string) (string, error) {
946+
func isErrorModificationNotFound(err error) bool {
947+
return strings.HasPrefix(err.Error(), awsErrorModificationNotFound)
948+
}
949+
950+
func (s *awsOps) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
946951
modificationStateRequest := &ec2.DescribeVolumesModificationsInput{
947-
VolumeIds: []*string{&volumeID},
952+
VolumeIds: volumeIDs,
948953
}
949954
describeOutput, err := s.ec2.DescribeVolumesModifications(modificationStateRequest)
955+
states := describeOutput.VolumesModifications
950956
if err != nil {
951-
return "", err
952-
}
953-
volumeModifications := describeOutput.VolumesModifications
954-
if len(volumeModifications) == 0 {
955-
return "", nil
957+
// modification state not found, this indicates no change has occurred before.
958+
if isErrorModificationNotFound(err) {
959+
return true, nil
960+
}
961+
return false, fmt.Errorf("unable to get volumes' modification states: %v", err)
956962
}
957963

958-
volumeModification := volumeModifications[len(volumeModifications)-1]
959-
state := *volumeModification.ModificationState
960-
return state, nil
961-
}
962-
963-
func (s *awsOps) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
964-
for i := 0; i < len(volumeIDs); i++ {
965-
state, err := s.getVolumeModificationState(volumeIDs[i])
966-
if err != nil {
967-
return false, fmt.Errorf("unable to get modification state: #{err}. ")
968-
}
969-
// Empty string indicates there was no volume change
970-
if state == "" {
971-
return true, nil
964+
var state string
965+
for i := 0; i < len(states); i++ {
966+
if states[i] == nil || states[i].ModificationState == nil {
967+
logrus.Infof("volume modification state is nil for volume id: %s", state, *volumeIDs[i])
968+
continue
972969
}
970+
971+
state = *states[i].ModificationState
972+
logrus.Infof("retrived volume modification state: %s for volume id: %s", state, *volumeIDs[i])
973973
if state == ec2.VolumeModificationStateModifying ||
974974
state == ec2.VolumeModificationStateOptimizing {
975-
return false, fmt.Errorf("the last modification has not fully completed. ")
975+
return false, fmt.Errorf("aws has not fully completed the last modification: " +
976+
"volume %s is in %s state. please retry later", *volumeIDs[i], state)
976977
}
977978
}
978979
return true, nil

azure/azure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ func (a *azureOps) DeleteFrom(diskName, _ string) error {
580580
return a.Delete(diskName, nil)
581581
}
582582

583-
func (a *azureOps) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
583+
func (a *azureOps) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
584584
return true, &cloudops.ErrNotSupported{
585-
Operation: "IsVolumesReadyToExpand",
585+
Operation: "azureOps.IsVolumesReadyToExpand",
586586
}
587587
}
588588

backoff/exponential.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,11 @@ func (e *exponentialBackoff) DevicePath(volumeID string) (string, error) {
436436
return devicePath, origErr
437437
}
438438

439-
func (e *exponentialBackoff) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
440-
return true, &cloudops.ErrNotSupported{
441-
Operation: "IsVolumesReadyToExpand",
442-
}
439+
func (e *exponentialBackoff) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
440+
return e.cloudOps.IsVolumesReadyToExpand(volumeIDs)
443441
}
444442

443+
445444
func (e *exponentialBackoff) Expand(volumeID string, targetSize uint64, options map[string]string) (uint64, error) {
446445
var (
447446
actualSize uint64

cloudops.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Storage interface {
131131
Attach(volumeID string, options map[string]string) (string, error)
132132
// IsVolumeReadyToExpand pre-checks if the volume is in a state that can be modified. Should be called
133133
// before issue an expand request to the cloud provider
134-
IsVolumesReadyToExpand(volumeIDs []string) (bool, error)
134+
IsVolumesReadyToExpand(volumeIDs []*string) (bool, error)
135135
// Expand expands the provided device from the existing size to the new size
136136
// It returns the new size of the device. It is a blocking API where it will
137137
// only return once the requested size is validated with the cloud provider or

gce/gce.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,9 @@ func (s *gceOps) GetDeviceID(disk interface{}) (string, error) {
664664
}
665665
}
666666

667-
func (s *gceOps) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
667+
func (s *gceOps) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
668668
return true, &cloudops.ErrNotSupported{
669-
Operation: "IsVolumesReadyToExpand",
669+
Operation: "gceOps:IsVolumesReadyToExpand",
670670
}
671671
}
672672
func (s *gceOps) Expand(

mock/cloudops.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oracle/oracle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,9 @@ func nodePoolContainsNode(s []containerengine.Node, e string) bool {
829829
return false
830830
}
831831

832-
func (o *oracleOps) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
832+
func (o *oracleOps) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
833833
return true, &cloudops.ErrNotSupported{
834-
Operation: "IsVolumesReadyToExpand",
834+
Operation: "oracleOps:IsVolumesReadyToExpand",
835835
}
836836
}
837837

unsupported/unsupported.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (u *unsupportedStorage) Attach(volumeID string, options map[string]string)
100100
}
101101
}
102102

103-
func (u *unsupportedStorage) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
103+
func (u *unsupportedStorage) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
104104
return true, &cloudops.ErrNotSupported{
105-
Operation: "IsVolumesReadyToExpand",
105+
Operation: "unsupportedStorage:IsVolumesReadyToExpand",
106106
}
107107
}
108108

vsphere/vsphere.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ func (ops *vsphereOps) Enumerate(volumeIds []*string,
533533
}
534534
}
535535

536-
func (ops *vsphereOps) IsVolumesReadyToExpand(volumeIDs []string) (bool, error) {
536+
func (ops *vsphereOps) IsVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
537537
return true, &cloudops.ErrNotSupported{
538-
Operation: "IsVolumesReadyToExpand",
538+
Operation: "vsphereOps:IsVolumesReadyToExpand",
539539
}
540540
}
541541

0 commit comments

Comments
 (0)