-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing #1015539 #4628
Fixing #1015539 #4628
Conversation
…users/aydey/AzureRG/CustomScriptExtensionBugFixes
…licy while executing the powershell script on vm
@@ -397,6 +397,11 @@ export class WinRMExtensionHelper { | |||
reject(tl.loc("ARG_SetExtensionFailedForVm", this.resourceGroupName, vmName, result)); | |||
return; | |||
} | |||
if (!this.ValidateExtensionExecutionStatus(vmName, dnsName, extensionName, location, _fileUris)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await here
@@ -345,7 +345,7 @@ export class WinRMExtensionHelper { | |||
if (result["properties"]["instanceView"] && result["properties"]["instanceView"]["extensions"]) { | |||
var extensions = result["properties"]["instanceView"]["extensions"]; | |||
for (var extension of extensions) { | |||
if (result["name"] === extensionName) { | |||
if (extension["name"] === extensionName) { | |||
for (var substatus of extension["substatuses"]) { | |||
if (substatus["code"] && substatus["code"].indexOf("ComponentStatus/StdErr") >= 0 && !!substatus["message"] && substatus["message"] != "") { | |||
invalidExecutionStatus = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider returning success only if you find the matching extension
return; | ||
} | ||
var validStatus = await this.ValidateExtensionExecutionStatus(vmName, dnsName, extensionName, location, _fileUris); | ||
if (!validStatus) { | ||
tl.debug("WinRMCustomScriptExtension is not valid on vm " + vmName); | ||
reject(tl.loc("ARG_SetExtensionFailedForVm", this.resourceGroupName, vmName, result)); | ||
reject(tl.loc("ARG_SetExtensionFailedForVm", this.resourceGroupName, vmName, JSON.stringify(result))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it make sense here. I think we should attempt to print the stderr result message
…users/aydey/AzureRG/CustomScriptExtensionBugFixes
…users/aydey/AzureRG/CustomScriptExtensionBugFixes
…stomScript Extension fails
} | ||
} | ||
try { | ||
await this.ValidateExtensionExecutionStatus(vmName, dnsName, extensionName, location, _fileUris); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might return success in some cases.
if (result["properties"]["instanceView"] && result["properties"]["instanceView"]["extensions"]) { | ||
var extensions = result["properties"]["instanceView"]["extensions"]; | ||
for (var extension of extensions) { | ||
if (result["name"] === extensionName) { | ||
if (extension["name"] === extensionName) { | ||
for (var substatus of extension["substatuses"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the extension is not found, you should fail with the message.
@@ -345,7 +345,7 @@ | |||
"SecurityRuleNameCannotBeNull": "securityRuleName cannot be null or undefined and it must be of type string.", | |||
"SecurityRuleParametersCannotBeNull": "securityRuleParameters cannot be null or undefined.", | |||
"OutputVariableShouldNotBeEmpty": "Output variable should not be empty.", | |||
"ARG_SetExtensionFailedForVm": "Failed to set extension on Virtual Machine %s of Resource Group %s with result: %s", | |||
"ARG_SetExtensionFailedForVm": "StdErr Message: Failed to set extension on Virtual Machine %s of Resource Group %s with error: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard Error:
@@ -321,49 +328,63 @@ export class WinRMExtensionHelper { | |||
|
|||
private GetExtension(vmName: string, extensionName: string): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to getCustomScriptExtension and remove the extensionName param
break; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
if(!extensionPresent){ | ||
reject("Extension not found on the vm: " + vmName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this can show without debug; then it needs to be in task.json
@@ -388,13 +409,21 @@ export class WinRMExtensionHelper { | |||
return new Promise<any>((resolve, reject) => { | |||
this.computeClient.virtualMachineExtensions.createOrUpdate(this.resourceGroupName, vmName, az.ComputeResourceType.VirtualMachine, extensionName, parameters, async (error, result, request, response) => { | |||
if (error) { | |||
reject(tl.loc("CreationOfExtensionFailed", utils.getError(error))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if you should add the VM name to the message.
No description provided.