@@ -409,7 +409,7 @@ func (ad *DiskAttachDetach) detachMultiAttachDisk(ctx context.Context, ecsClient
409409 return true , nil
410410}
411411
412- func (ad * DiskAttachDetach ) detachDisk (ctx context.Context , ecsClient * ecs.Client , diskID , nodeID string ) (err error ) {
412+ func (ad * DiskAttachDetach ) detachDisk (ctx context.Context , ecsClient * ecs.Client , diskID , nodeID string , fromNode bool ) (err error ) {
413413 disk , err := ad .findDiskByID (ctx , diskID )
414414 if err != nil {
415415 klog .Errorf ("DetachDisk: Describe volume: %s from node: %s, with error: %s" , diskID , nodeID , err .Error ())
@@ -419,6 +419,10 @@ func (ad *DiskAttachDetach) detachDisk(ctx context.Context, ecsClient *ecs.Clien
419419 klog .Infof ("DetachDisk: Detach Disk %s from node %s describe and find disk not exist" , diskID , nodeID )
420420 return nil
421421 }
422+ if fromNode && disk .MultiAttach == "Enabled" {
423+ klog .Infof ("DetachDisk: Skip detach multi-attach disk %s from node, it will be detached by controller" , diskID )
424+ return nil
425+ }
422426
423427 defer func () {
424428 if err == nil {
@@ -447,7 +451,7 @@ func (ad *DiskAttachDetach) detachDisk(ctx context.Context, ecsClient *ecs.Clien
447451 ad .detaching .Store (diskID , nodeID )
448452 detachDiskRequest := ecs .CreateDetachDiskRequest ()
449453 detachDiskRequest .DiskId = disk .DiskId
450- detachDiskRequest .InstanceId = disk . InstanceId
454+ detachDiskRequest .InstanceId = nodeID
451455 if AllCategories [Category (disk .Category )].SingleInstance {
452456 detachDiskRequest .DeleteWithInstance = requests .NewBoolean (true )
453457 }
0 commit comments