Skip to content

Commit

Permalink
Merge pull request #929 from andyzhangx/detach-failure-throttling
Browse files Browse the repository at this point in the history
fix: detach disk should return error when throttled
  • Loading branch information
k8s-ci-robot committed Dec 8, 2021
2 parents 6180951 + f549094 commit a457bc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const (
// StorageAccountNameMaxLength is the max length of a storage name
StorageAccountNameMaxLength = 24

CannotFindDiskLUN = "cannot find Lun"

// DefaultStorageAccountType is the default storage account type
DefaultStorageAccountType = string(storage.SkuNameStandardLRS)
// DefaultStorageAccountKind is the default storage account kind
Expand Down
7 changes: 4 additions & 3 deletions pkg/provider/azure_controller_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ func (c *controllerCommon) DetachDisk(ctx context.Context, diskName, diskURI str
}
}
} else {
if lun, _, err := c.GetDiskLun(diskName, diskURI, nodeName); err == nil {
return fmt.Errorf("disk(%s) is still attatched to node(%s) on lun(%d)", diskURI, nodeName, lun)
lun, _, errGetLun := c.GetDiskLun(diskName, diskURI, nodeName)
if errGetLun == nil || !strings.Contains(errGetLun.Error(), consts.CannotFindDiskLUN) {
return fmt.Errorf("disk(%s) is still attatched to node(%s) on lun(%d), error: %v", diskURI, nodeName, lun, errGetLun)
}
}

Expand Down Expand Up @@ -452,7 +453,7 @@ func (c *controllerCommon) GetDiskLun(diskName, diskURI string, nodeName types.N
}
}
}
return -1, provisioningState, fmt.Errorf("cannot find Lun for disk %s", diskName)
return -1, provisioningState, fmt.Errorf("%s for disk %s", consts.CannotFindDiskLUN, diskName)
}

// SetDiskLun find unused luns and allocate lun for every disk in diskMap.
Expand Down

0 comments on commit a457bc0

Please sign in to comment.