Merge pull request #56550 from andyzhangx/error-info-createshare
Automatic merge from submit-queue (batch tested with PRs 56337, 56546, 56550, 56633, 56635). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix incorrect error info when creating an azure file PVC failed **What this PR does / why we need it**: when creating an azure file PVC failed, it will always return following error which is totally incorrect: ``` Failed to provision volume with StorageClass "azurefile-premium": failed to find a matching storage account ``` The incorrect error info would mislead customer a lot, I would suggest return error directly if create first file share failed. By this PR, the error info would be like following, which would provide user detailed and **correct** info: ``` Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning ProvisioningFailed 13s persistentvolume-controller Failed to provision volume with StorageClass "azurefile-premium": failed to create share andy-k8s182-dynamic-pvc-cd66f4bd-d4c4-11e7-9f09-000d3a019e90 in account 00mqk6lqaouexy6agnt0: failed to create file share, err: Put https://00mqk6lqaouexy6agnt0.file.core.windows.net/andy-k8s182-dynamic-pvc-cd66f4bd-d4c4-11e7-9f09-000d3a019e90?restype=share: dial tcp: lookup 00mqk6lqaouexy6agnt0.file.core.windows.net on 168.63.129.16:53: no such host ``` **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #56548 **Special notes for your reviewer**: **Release note**: ``` none ``` /sig azure /assign @rootfs
This commit is contained in:
		@@ -42,20 +42,24 @@ func (az *Cloud) CreateFileShare(name, storageAccount, storageType, location str
 | 
				
			|||||||
			// find the access key with this account
 | 
								// find the access key with this account
 | 
				
			||||||
			key, err := az.getStorageAccesskey(account.Name)
 | 
								key, err := az.getStorageAccesskey(account.Name)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.V(2).Infof("no key found for storage account %s", account.Name)
 | 
									err = fmt.Errorf("could not get storage key for storage account %s: %v", account.Name, err)
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			err = az.createFileShare(account.Name, key, name, requestGB)
 | 
								err = az.createFileShare(account.Name, key, name, requestGB)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.V(2).Infof("failed to create share %s in account %s: %v", name, account.Name, err)
 | 
									err = fmt.Errorf("failed to create share %s in account %s: %v", name, account.Name, err)
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			glog.V(4).Infof("created share %s in account %s", name, account.Name)
 | 
								glog.V(4).Infof("created share %s in account %s", name, account.Name)
 | 
				
			||||||
			return account.Name, key, err
 | 
								return account.Name, key, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return "", "", fmt.Errorf("failed to find a matching storage account")
 | 
					
 | 
				
			||||||
 | 
						if err == nil {
 | 
				
			||||||
 | 
							err = fmt.Errorf("failed to find a matching storage account")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "", "", err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DeleteFileShare deletes a file share using storage account name and key
 | 
					// DeleteFileShare deletes a file share using storage account name and key
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user