Skip to content

Commit e16e28c

Browse files
authored
Users/vinca/pdfix m140 (#8287)
* resolved merge conflicts * addressed review comments * resolved merge conflicts 2 * remove log files * L0 test fix * Update task.json * Update task.loc.json * Post Deployment script - addressed review comments * addressed review comment * removed v3
1 parent 34e57f4 commit e16e28c

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

Tasks/AzureRmWebAppDeploymentV4/operations/KuduServiceUtility.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ export class KuduServiceUtility {
5555
await this._appServiceKuduService.uploadFile(vstsPostDeploymentFolderPath, 'kuduPostDeploymentScript' + fileExtension, scriptFile.filePath);
5656
console.log(tl.loc('ExecuteScriptOnKudu'));
5757
var cmdFilePath = '%Home%\\site\\VSTS_PostDeployment_' + uniqueID + '\\mainCmdFile' + fileExtension;
58-
var scriprResultPath = '%Home%\\site\\VSTS_PostDeployment_' + uniqueID + '\\script_result.txt';
58+
var scriprResultPath = '/site/VSTS_PostDeployment_' + uniqueID;
5959
if (taskParams.isLinuxApp){
60-
cmdFilePath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/mainCmdFile' + fileExtension
61-
scriprResultPath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/script_result.txt';
60+
cmdFilePath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/mainCmdFile' + fileExtension;
6261
}
63-
await this.runCommand(rootDirectoryPath, cmdFilePath + ' ' + uniqueID, 30, scriprResultPath);
62+
await this.runCommand(rootDirectoryPath, cmdFilePath + ' ' + uniqueID, 30, scriprResultPath, 'script_result.txt');
6463
await this._printPostDeploymentLogs(vstsPostDeploymentFolderPath);
6564

6665
}
@@ -78,8 +77,13 @@ export class KuduServiceUtility {
7877
}
7978
finally {
8079
try {
80+
let deleteFilePath = '%Home%\\site\\VSTS_PostDeployment_' + uniqueID + '\\delete_log_file' + fileExtension;
81+
if(taskParams.isLinuxApp) {
82+
deleteFilePath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/delete_log_file' + fileExtension;
83+
}
84+
8185
await this._appServiceKuduService.uploadFile(vstsPostDeploymentFolderPath, 'delete_log_file' + fileExtension, path.join(__dirname, '..', 'postDeploymentScript', 'deleteLogFile' + fileExtension));
82-
await this.runCommand(vstsPostDeploymentFolderPath, 'delete_log_file' + fileExtension, 0, null);
86+
await this.runCommand(vstsPostDeploymentFolderPath, deleteFilePath);
8387
await this._appServiceKuduService.deleteFolder(vstsPostDeploymentFolderPath);
8488
}
8589
catch(error) {
@@ -313,14 +317,14 @@ export class KuduServiceUtility {
313317
}
314318
}
315319

316-
private async runCommand(physicalPath: string, command: string, timeOutInMinutes: number, pollFile: string): Promise<void> {
320+
private async runCommand(physicalPath: string, command: string, timeOutInMinutes?: number, pollFolderPath?: string, pollFile?: string): Promise<void> {
317321
try {
318322
await this._appServiceKuduService.runCommand(physicalPath, command);
319323
}
320324
catch(error) {
321-
if(timeOutInMinutes > 0 && error.toString().indexOf('Request timeout: /api/command') != -1) {
325+
if(!!pollFolderPath && !!pollFile && timeOutInMinutes > 0 && error.toString().indexOf('Request timeout: /api/command') != -1) {
322326
tl.debug('Request timeout occurs. Trying to poll for file: ' + pollFile);
323-
await this._pollForFile(physicalPath, pollFile, timeOutInMinutes);
327+
await this._pollForFile(pollFolderPath, pollFile, timeOutInMinutes);
324328
}
325329
else {
326330
if(typeof error.valueOf() == 'string') {

Tasks/AzureRmWebAppDeploymentV4/operations/TaskParameters.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ export class TaskParametersUtility {
9898
taskParameters.AdditionalArguments = '-retryAttempts:6 -retryInterval:10000';
9999
}
100100

101+
if(taskParameters.isLinuxApp && taskParameters.ScriptType) {
102+
this.UpdateLinuxAppTypeScriptParameters(taskParameters);
103+
}
104+
101105
return taskParameters;
102106
}
103107

@@ -107,6 +111,19 @@ export class TaskParametersUtility {
107111
taskParameters.Package = new Package(tl.getPathInput('Package', true));
108112
taskParameters.AdditionalArguments = "-retryAttempts:6 -retryInterval:10000";
109113
}
114+
115+
private static UpdateLinuxAppTypeScriptParameters(taskParameters: TaskParameters) {
116+
let retryTimeoutValue = tl.getVariable('appservicedeploy.retrytimeout');
117+
let timeoutAppSettings = retryTimeoutValue ? Number(retryTimeoutValue) * 60 : 1800;
118+
119+
tl.debug(`setting app setting SCM_COMMAND_IDLE_TIMEOUT to ${timeoutAppSettings}`);
120+
if(taskParameters.AppSettings) {
121+
taskParameters.AppSettings = `-SCM_COMMAND_IDLE_TIMEOUT ${timeoutAppSettings} ` + taskParameters.AppSettings;
122+
}
123+
else {
124+
taskParameters.AppSettings = `-SCM_COMMAND_IDLE_TIMEOUT ${timeoutAppSettings}`;
125+
}
126+
}
110127

111128
private static getDeploymentType(type): DeploymentType {
112129
switch(type) {

Tasks/AzureRmWebAppDeploymentV4/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 4,
2020
"Minor": 3,
21-
"Patch": 5
21+
"Patch": 6
2222
},
2323
"releaseNotes": "What's new in version 4.* (preview)<br />Supports Kudu Zip Deploy<br />Supports App Service Environments<br />Improved UI for discovering different App service types supported by the task<br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
2424
"minimumAgentVersion": "2.104.1",

Tasks/AzureRmWebAppDeploymentV4/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 4,
2020
"Minor": 3,
21-
"Patch": 5
21+
"Patch": 6
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"minimumAgentVersion": "2.104.1",
@@ -620,4 +620,4 @@
620620
"JarPathNotPresent": "ms-resource:loc.messages.JarPathNotPresent",
621621
"FailedToUpdateApplicationInsightsResource": "ms-resource:loc.messages.FailedToUpdateApplicationInsightsResource"
622622
}
623-
}
623+
}

Tasks/Common/azure-arm-rest/azure-arm-app-service-kudu.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class KuduServiceManagementClient {
2222
request.headers["Authorization"] = "Basic " + this._accesssToken;
2323
request.headers['Content-Type'] = 'application/json; charset=utf-8';
2424

25-
let retryCount = reqOptions && reqOptions.retryCount ? reqOptions.retryCount : 5;
25+
let retryCount = reqOptions && util.isNumber(reqOptions.retryCount) ? reqOptions.retryCount : 5;
26+
2627
while(retryCount >= 0) {
2728
try {
2829
let httpResponse = await webClient.sendRequest(request, reqOptions);
@@ -36,7 +37,7 @@ export class KuduServiceManagementClient {
3637
tl.warning(tl.loc('ASE_SSLIssueRecommendation'));
3738
}
3839

39-
if(retryCount > 0 && exceptionString.indexOf('Request timeout') != -1) {
40+
if(retryCount > 0 && exceptionString.indexOf('Request timeout') != -1 && reqOptions.retryRequestTimedout) {
4041
tl.debug('encountered request timedou issue in Kudu. Retrying again');
4142
retryCount -= 1;
4243
continue;
@@ -395,7 +396,8 @@ export class Kudu {
395396

396397
try {
397398
tl.debug('Executing Script on Kudu. Command: ' + command);
398-
var response = await this._client.beginRequest(httpRequest);
399+
let webRequestOptions: webClient.WebRequestOptions = {retriableErrorCodes: null, retriableStatusCodes: null, retryCount: 5, retryIntervalInSeconds: 5, retryRequestTimedout: false};
400+
var response = await this._client.beginRequest(httpRequest, webRequestOptions);
399401
tl.debug(`runCommand. Data: ${JSON.stringify(response)}`);
400402
if(response.statusCode == 200) {
401403
return ;

Tasks/Common/azure-arm-rest/webClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class WebRequestOptions {
3838
public retryCount: number;
3939
public retryIntervalInSeconds: number;
4040
public retriableStatusCodes: number[];
41+
public retryRequestTimedout?: boolean = true;
4142
}
4243

4344
export async function sendRequest(request: WebRequest, options?: WebRequestOptions): Promise<WebResponse> {

0 commit comments

Comments
 (0)