@@ -422,6 +422,10 @@ func (o *oracleOps) Create(template interface{}, labels map[string]string) (inte
422422 }
423423 createVolResp , err := o .storage .CreateVolume (context .Background (), createVolReq )
424424 if err != nil {
425+ if strings .Contains (err .Error (), "vpusPerGB is invalid" ) {
426+ return nil , fmt .Errorf ("VPUs must be an integer that is multiple of 10 " +
427+ "Please refer to oracle cloud block volume documentation for valid values" )
428+ }
425429 return nil , err
426430 }
427431
@@ -610,26 +614,30 @@ func (o *oracleOps) Attach(volumeID string, options map[string]string) (string,
610614 return "" , err
611615 }
612616
617+ var devicePath string
613618 if attachVolResp .GetLifecycleState () != core .VolumeAttachmentLifecycleStateAttached {
614- err = o .waitVolumeAttachmentStatus (
619+ devicePath , err = o .waitVolumeAttachmentStatus (
615620 attachVolResp .GetId (),
616621 core .VolumeAttachmentLifecycleStateAttached ,
617622 )
618623 if err != nil {
619- return "" , err
624+ devicePath , err := o .DevicePath (volumeID )
625+ if err != nil {
626+ return "" , err
627+ }
628+ o .volumeAttachmentMapping [volumeID ] = attachVolResp .GetId ()
629+ return devicePath , err
620630 }
621- }
622- devicePath , err := o .DevicePath (volumeID )
623- if err != nil {
624- logrus .Errorf ("Error while getting device path. Error: %v" , err )
631+ } else {
632+ devicePath = * attachVolResp .GetDevice ()
625633 }
626634 o .volumeAttachmentMapping [volumeID ] = attachVolResp .GetId ()
627635 return devicePath , err
628636 }
629637 return "" , fmt .Errorf ("failed to attach any of the free devices. Attempted: %v" , devices )
630638}
631639
632- func (o * oracleOps ) waitVolumeAttachmentStatus (volumeAttachmentID * string , desiredStatus core.VolumeAttachmentLifecycleStateEnum ) error {
640+ func (o * oracleOps ) waitVolumeAttachmentStatus (volumeAttachmentID * string , desiredStatus core.VolumeAttachmentLifecycleStateEnum ) ( string , error ) {
633641 getVolAttachmentReq := core.GetVolumeAttachmentRequest {
634642 VolumeAttachmentId : volumeAttachmentID ,
635643 }
@@ -639,14 +647,21 @@ func (o *oracleOps) waitVolumeAttachmentStatus(volumeAttachmentID *string, desir
639647 return nil , true , err
640648 }
641649 if getVolAttachmentResp .GetLifecycleState () == desiredStatus {
642- return nil , false , nil
650+ return getVolAttachmentResp . GetDevice () , false , nil
643651 }
644652
645653 logrus .Debugf ("volume [%s] is still in [%s] state" , * getVolAttachmentResp .GetVolumeId (), getVolAttachmentResp .GetLifecycleState ())
646654 return nil , true , fmt .Errorf ("volume [%s] is still in [%s] state" , * getVolAttachmentResp .GetVolumeId (), getVolAttachmentResp .GetLifecycleState ())
647655 }
648- _ , err := task .DoRetryWithTimeout (f , cloudops .ProviderOpsTimeout , cloudops .ProviderOpsRetryInterval )
649- return err
656+ devicePathRaw , err := task .DoRetryWithTimeout (f , cloudops .ProviderOpsTimeout , cloudops .ProviderOpsRetryInterval )
657+ if err != nil {
658+ return "" , err
659+ }
660+ devicePath , ok := devicePathRaw .(* string )
661+ if ! ok {
662+ return "" , fmt .Errorf ("volume attachment [%s] attached successfully but could not get it's local device path" , * volumeAttachmentID )
663+ }
664+ return * devicePath , err
650665}
651666
652667// Detach volumeID.
@@ -690,7 +705,7 @@ func (o *oracleOps) detachInternal(volumeID, instanceID string) error {
690705 volumeID , instanceID , detachVolResp , err )
691706 return err
692707 }
693- err = o .waitVolumeAttachmentStatus (
708+ _ , err = o .waitVolumeAttachmentStatus (
694709 attachmentID ,
695710 core .VolumeAttachmentLifecycleStateDetached ,
696711 )
@@ -788,7 +803,6 @@ func nodePoolContainsNode(s []containerengine.Node, e string) bool {
788803 return false
789804}
790805
791-
792806func (o * oracleOps ) Expand (volumeID string , newSizeInGiB uint64 ) (uint64 , error ) {
793807 logrus .Debug ("Expand volume to size " , newSizeInGiB , " GiB" )
794808
0 commit comments