@@ -356,16 +356,16 @@ func (o *oracleOps) DevicePath(volumeID string) (string, error) {
356356 return "" , err
357357 }
358358
359- if volumeAttachmentResp .Items == nil || len (volumeAttachmentResp .Items ) == 0 {
359+ if volumeAttachmentResp .Items == nil ||
360+ len (volumeAttachmentResp .Items ) == 0 ||
361+ volumeAttachmentResp .Items [0 ].GetInstanceId () == nil ||
362+ volumeAttachmentResp .Items [0 ].GetLifecycleState () == core .VolumeAttachmentLifecycleStateDetached ||
363+ volumeAttachmentResp .Items [0 ].GetLifecycleState () == core .VolumeAttachmentLifecycleStateDetaching {
360364 return "" , cloudops .NewStorageError (cloudops .ErrVolDetached ,
361365 "Volume is detached" , volumeID )
362366 }
363367
364368 volumeAttachment := volumeAttachmentResp .Items [0 ]
365- if volumeAttachment .GetInstanceId () == nil {
366- return "" , cloudops .NewStorageError (cloudops .ErrVolInval ,
367- "Unable to determine volume instance attachment" , "" )
368- }
369369
370370 if o .instance != * volumeAttachment .GetInstanceId () {
371371 return "" , cloudops .NewStorageError (cloudops .ErrVolAttachedOnRemoteNode ,
@@ -980,7 +980,7 @@ func (o *oracleOps) Enumerate(volumeIds []*string,
980980 }
981981 // TODO: [PWX-26616] Check if SDK itself returns list of volumes
982982 // that have labels OR use volumeGroup for filtering
983- if labels != nil && containsMap (vol .FreeformTags , labels ) {
983+ if labels != nil && ! containsMap (vol .FreeformTags , labels ) {
984984 continue
985985 }
986986 if len (setIdentifier ) == 0 {
@@ -1020,7 +1020,7 @@ func (o *oracleOps) deleted(v core.Volume) bool {
10201020 v .LifecycleState == core .VolumeLifecycleStateTerminated
10211021}
10221022
1023- // ApplyTags will apply given labels/ tags on the given volume
1023+ // ApplyTags will overwrite the existing tags with newly provided tags
10241024func (o * oracleOps ) ApplyTags (volumeID string , labels map [string ]string ) error {
10251025 req := core.UpdateVolumeRequest {
10261026 VolumeId : common .String (volumeID ),
0 commit comments