Skip to content

Commit

Permalink
Add logging before and after calling toolrunner exec method. Replace …
Browse files Browse the repository at this point in the history
…chmod by chmodSync. (#9918)

* Add logging before and after calling toolrunner exec method.

Replace chmod by chmodSync.

* Bumping up versions of Tasks which are dependent on kubectlutility.ts - HelmDeployV0, HelmInstallerV0, KubernetesManifestV0, KubernetesV1

* Bumping up other task versions as is imposed by build policy
  • Loading branch information
ajinkya599 authored Mar 31, 2019
1 parent 9a1419b commit 40d1b95
Show file tree
Hide file tree
Showing 48 changed files with 94 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 2
"Patch": 3
},
"preview": true,
"instanceNameFormat": "Azure IoT Edge - $(action)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 2
"Patch": 3
},
"preview": true,
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMysqlDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 15
"Patch": 16
},
"demands": [],
"minimumAgentVersion": "1.100.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMysqlDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 15
"Patch": 16
},
"demands": [],
"minimumAgentVersion": "1.100.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureVmssDeploymentV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 24
"Patch": 25
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureVmssDeploymentV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 24
"Patch": 25
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/Common/utility-common/kubectlutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function downloadKubectl(version: string) : Promise<string> {
}

var kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtention());
fs.chmod(kubectlPath, "777");
fs.chmodSync(kubectlPath, "777");
return kubectlPath;
}

Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 150,
"Patch": 3
"Patch": 4
},
"demands": [],
"releaseNotes": "Simplified the task YAML by:<br/>&nbsp;- Removing the Container registry type input<br/>&nbsp;- Removing complex inputs as they can be passed as arguments to the command.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DockerV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 150,
"Patch": 3
"Patch": 4
},
"demands": [],
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 150,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet $(command)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 150,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "1.99.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "1.99.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 1,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.115.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 1,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.115.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DuffleInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 1
"Patch": 2
},
"demands": [],
"groups": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DuffleInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 1
"Patch": 2
},
"demands": [],
"groups": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/GitHubReleaseV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/GitHubReleaseV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/GradleV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 149,
"Patch": 1
"Patch": 2
},
"releaseNotes": "Configuration of the SonarQube analysis was moved to the [SonarQube](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) or [SonarCloud](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) extensions, in task `Prepare Analysis Configuration`",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/GradleV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 149,
"Patch": 1
"Patch": 2
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/HelmDeployV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 1
"Patch": 2
},
"demands": [],
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/HelmDeployV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 1
"Patch": 2
},
"demands": [],
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/HelmInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 15
"Minor": 150,
"Patch": 0
},
"demands": [],
"satisfies": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/HelmInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 15
"Minor": 150,
"Patch": 0
},
"demands": [],
"satisfies": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/KubernetesManifestV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 149,
"Minor": 150,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/KubernetesManifestV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 149,
"Minor": 150,
"Patch": 0
},
"demands": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"loc.input.help.kubectlOutput": "Name of the variable in which output of the command should be saved.",
"loc.messages.DownloadingClient": "Downloading kubernetes client.",
"loc.messages.CreatingSecret": "Executing create %s secret.",
"loc.messages.CallToolRunnerExec": "Calling Toolrunner exec() method asynchronously to execute the kubectl command and store the returned promise object.",
"loc.messages.DeleteSecret": "Executing delete %s secret",
"loc.messages.CreatingConfigMap": "Executing create %s configmap.",
"loc.messages.DeleteConfigMap": "Executing delete %s configmap",
Expand All @@ -73,6 +74,9 @@
"loc.messages.DownloadPathForStableTxt": "Download path for stable.txt: %s",
"loc.messages.DownloadKubeCtlFailed": "Can not download the kubectl client of version %s. Check if the version is correct https://github.com/kubernetes/kubernetes/releases",
"loc.messages.DownloadStableVersionFailed": "Can not download kubernetes stable version file from %s. Falling back to %s",
"loc.messages.ReturningToolRunnerExecPromise": "Called Toolrunner exec() method asynchronously. Returning the promise.",
"loc.messages.ToolRunnerExecCallFailed": "Toolrunner exec() method returned error for the kubectl command. Error: %s.",
"loc.messages.ToolRunnerExecCallSucceeded": "Toolrunner exec() method returned successfully for the kubectl command.",
"loc.messages.UsingLatestStableVersion": "Invalid version 1.7 specified in Version Spec input. Using latest stable version instead. Check for correct versions https://github.com/kubernetes/kubernetes/releases",
"loc.messages.ConfigurationFileNotFound": "No configuration file matching %s was found.",
"loc.messages.OutputVariableDataSizeExceeded": "Output variable not set as kubectl command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s",
Expand Down
13 changes: 12 additions & 1 deletion Tasks/KubernetesV0/src/clusterconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,21 @@ export default class ClusterConnection {
command.on("errline", line => {
errlines.push(line);
});
return command.exec(options).fail(error => {

tl.debug(tl.loc('CallToolRunnerExec'));

let promise = command.exec(options)
.fail(error => {
tl.debug(tl.loc('ToolRunnerExecCallFailed', error));
errlines.forEach(line => tl.error(line));
throw error;
})
.then(() => {
tl.debug(tl.loc('ToolRunnerExecCallSucceeded'));
});

tl.debug(tl.loc('ReturningToolRunnerExecPromise'));
return promise;
}

private getExecutableExtention(): string {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/KubernetesV0/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function downloadKubectl(version: string, kubectlPath: string): Pro
var kubectlPathTmp = kubectlPath+".tmp";
return downloadutility.download(kubectlURL, kubectlPathTmp, false, true).then( (res) => {
tl.cp(kubectlPathTmp, kubectlPath, "-f");
fs.chmod(kubectlPath, "777");
fs.chmodSync(kubectlPath, "777");
assertFileExists(kubectlPath);
return kubectlPath;
},
Expand Down
6 changes: 5 additions & 1 deletion Tasks/KubernetesV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 3
"Patch": 4
},
"demands": [],
"preview": "false",
Expand Down Expand Up @@ -350,6 +350,7 @@
"messages": {
"DownloadingClient": "Downloading kubernetes client.",
"CreatingSecret": "Executing create %s secret.",
"CallToolRunnerExec": "Calling Toolrunner exec() method asynchronously to execute the kubectl command and store the returned promise object.",
"DeleteSecret": "Executing delete %s secret",
"CreatingConfigMap": "Executing create %s configmap.",
"DeleteConfigMap": "Executing delete %s configmap",
Expand All @@ -361,6 +362,9 @@
"DownloadPathForStableTxt": "Download path for stable.txt: %s",
"DownloadKubeCtlFailed": "Can not download the kubectl client of version %s. Check if the version is correct https://github.com/kubernetes/kubernetes/releases",
"DownloadStableVersionFailed": "Can not download kubernetes stable version file from %s. Falling back to %s",
"ReturningToolRunnerExecPromise": "Called Toolrunner exec() method asynchronously. Returning the promise.",
"ToolRunnerExecCallFailed": "Toolrunner exec() method returned error for the kubectl command. Error: %s.",
"ToolRunnerExecCallSucceeded": "Toolrunner exec() method returned successfully for the kubectl command.",
"UsingLatestStableVersion": "Invalid version 1.7 specified in Version Spec input. Using latest stable version instead. Check for correct versions https://github.com/kubernetes/kubernetes/releases",
"ConfigurationFileNotFound": "No configuration file matching %s was found.",
"OutputVariableDataSizeExceeded": "Output variable not set as kubectl command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s",
Expand Down
6 changes: 5 additions & 1 deletion Tasks/KubernetesV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 150,
"Patch": 3
"Patch": 4
},
"demands": [],
"preview": "false",
Expand Down Expand Up @@ -350,6 +350,7 @@
"messages": {
"DownloadingClient": "ms-resource:loc.messages.DownloadingClient",
"CreatingSecret": "ms-resource:loc.messages.CreatingSecret",
"CallToolRunnerExec": "ms-resource:loc.messages.CallToolRunnerExec",
"DeleteSecret": "ms-resource:loc.messages.DeleteSecret",
"CreatingConfigMap": "ms-resource:loc.messages.CreatingConfigMap",
"DeleteConfigMap": "ms-resource:loc.messages.DeleteConfigMap",
Expand All @@ -361,6 +362,9 @@
"DownloadPathForStableTxt": "ms-resource:loc.messages.DownloadPathForStableTxt",
"DownloadKubeCtlFailed": "ms-resource:loc.messages.DownloadKubeCtlFailed",
"DownloadStableVersionFailed": "ms-resource:loc.messages.DownloadStableVersionFailed",
"ReturningToolRunnerExecPromise": "ms-resource:loc.messages.ReturningToolRunnerExecPromise",
"ToolRunnerExecCallFailed": "ms-resource:loc.messages.ToolRunnerExecCallFailed",
"ToolRunnerExecCallSucceeded": "ms-resource:loc.messages.ToolRunnerExecCallSucceeded",
"UsingLatestStableVersion": "ms-resource:loc.messages.UsingLatestStableVersion",
"ConfigurationFileNotFound": "ms-resource:loc.messages.ConfigurationFileNotFound",
"OutputVariableDataSizeExceeded": "ms-resource:loc.messages.OutputVariableDataSizeExceeded",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,9 @@
"loc.messages.KubernetesServiceConnectionNotFound": "Kubernetes service connection details not found.",
"loc.messages.OutputVariableDataSizeExceeded": "Output variable not set as kubectl command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s",
"loc.messages.InvalidConfiguration": "No Kubernetes configuration found, supply either inline configuration or configuration file path",
"loc.messages.CallToolRunnerExec": "Calling Toolrunner exec() method asynchronously to execute the kubectl command and store the returned promise object.",
"loc.messages.ReturningToolRunnerExecPromise": "Called Toolrunner exec() method asynchronously. Returning the promise.",
"loc.messages.ToolRunnerExecCallFailed": "Toolrunner exec() method returned error for the kubectl command. Error: %s.",
"loc.messages.ToolRunnerExecCallSucceeded": "Toolrunner exec() method returned successfully for the kubectl command.",
"loc.messages.WritingDockerConfigToTempFile": "Writing Docker config to temp file. File path: %s, Docker config: %s"
}
13 changes: 12 additions & 1 deletion Tasks/KubernetesV1/src/clusterconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,21 @@ export default class ClusterConnection {
command.on("errline", line => {
errlines.push(line);
});
return command.exec(options).fail(error => {

tl.debug(tl.loc('CallToolRunnerExec'));

let promise = command.exec(options)
.fail(error => {
tl.debug(tl.loc('ToolRunnerExecCallFailed', error));
errlines.forEach(line => tl.error(line));
throw error;
})
.then(() => {
tl.debug(tl.loc('ToolRunnerExecCallSucceeded'));
});

tl.debug(tl.loc('ReturningToolRunnerExecPromise'));
return promise;
}

private async getKubectl() : Promise<string> {
Expand Down
Loading

0 comments on commit 40d1b95

Please sign in to comment.