From 593108f8d24d78e039c751890f43e223397c43e5 Mon Sep 17 00:00:00 2001 From: Vikranth Thati Date: Fri, 30 Nov 2018 19:32:11 +0530 Subject: [PATCH] Don't set output variable and Log warning if docker command output length more than 32k (#8968) --- .../Strings/resources.resjson/en-US/resources.resjson | 3 ++- Tasks/DockerV0/container.ts | 9 ++++++++- Tasks/DockerV0/task.json | 5 +++-- Tasks/DockerV0/task.loc.json | 5 +++-- .../Strings/resources.resjson/en-US/resources.resjson | 3 ++- Tasks/DockerV1/container.ts | 9 ++++++++- Tasks/DockerV1/task.json | 5 +++-- Tasks/DockerV1/task.loc.json | 5 +++-- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Tasks/DockerV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/DockerV0/Strings/resources.resjson/en-US/resources.resjson index db6f71809042..925c767ce14b 100644 --- a/Tasks/DockerV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/DockerV0/Strings/resources.resjson/en-US/resources.resjson @@ -72,5 +72,6 @@ "loc.messages.NoImagesInImageNamesFile": "At least one image name is expected in file '%s'.", "loc.messages.CantWriteDataToFile": "Can not write data to the file %s. Error: %s", "loc.messages.NoDataWrittenOnFile": "No data was written into the file %s", - "loc.messages.FileContentSynced": "Synced the file content to the disk. The content is %s." + "loc.messages.FileContentSynced": "Synced the file content to the disk. The content is %s.", + "loc.messages.OutputVariableDataSizeExceeded": "Output variable not set as Docker command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s" } \ No newline at end of file diff --git a/Tasks/DockerV0/container.ts b/Tasks/DockerV0/container.ts index fdd3ec227b1f..359884e2b4f4 100644 --- a/Tasks/DockerV0/container.ts +++ b/Tasks/DockerV0/container.ts @@ -16,6 +16,7 @@ tl.cd(tl.getInput("cwd")); // get the registry server authentication provider var registryType = tl.getInput("containerregistrytype", true); var authenticationProvider : AuthenticationTokenProvider; +const environmentVariableMaximumSize = 32766; if(registryType == "Azure Container Registry"){ authenticationProvider = new ACRAuthenticationTokenProvider(tl.getInput("azureSubscriptionEndpoint"), tl.getInput("azureContainerRegistry")); @@ -84,7 +85,13 @@ require({ connection.close(); }) .then(function success() { - tl.setVariable("DockerOutput", result); + var commandOutputLength = result.length; + if (commandOutputLength > environmentVariableMaximumSize) { + tl.warning(tl.loc('OutputVariableDataSizeExceeded', commandOutputLength, environmentVariableMaximumSize)); + } else { + tl.setVariable("DockerOutput", result); + } + tl.setResult(tl.TaskResult.Succeeded, ""); }, function failure(err) { tl.setResult(tl.TaskResult.Failed, err.message); diff --git a/Tasks/DockerV0/task.json b/Tasks/DockerV0/task.json index 5a3f4a6500d0..859374e219e7 100644 --- a/Tasks/DockerV0/task.json +++ b/Tasks/DockerV0/task.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 3, - "Patch": 23 + "Patch": 26 }, "demands": [], "preview": "false", @@ -339,6 +339,7 @@ "NoImagesInImageNamesFile": "At least one image name is expected in file '%s'.", "CantWriteDataToFile": "Can not write data to the file %s. Error: %s", "NoDataWrittenOnFile": "No data was written into the file %s", - "FileContentSynced": "Synced the file content to the disk. The content is %s." + "FileContentSynced": "Synced the file content to the disk. The content is %s.", + "OutputVariableDataSizeExceeded": "Output variable not set as Docker command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s" } } \ No newline at end of file diff --git a/Tasks/DockerV0/task.loc.json b/Tasks/DockerV0/task.loc.json index 1662406fb6c3..eae89055d44b 100644 --- a/Tasks/DockerV0/task.loc.json +++ b/Tasks/DockerV0/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 3, - "Patch": 22 + "Patch": 26 }, "demands": [], "preview": "false", @@ -339,6 +339,7 @@ "NoImagesInImageNamesFile": "ms-resource:loc.messages.NoImagesInImageNamesFile", "CantWriteDataToFile": "ms-resource:loc.messages.CantWriteDataToFile", "NoDataWrittenOnFile": "ms-resource:loc.messages.NoDataWrittenOnFile", - "FileContentSynced": "ms-resource:loc.messages.FileContentSynced" + "FileContentSynced": "ms-resource:loc.messages.FileContentSynced", + "OutputVariableDataSizeExceeded": "ms-resource:loc.messages.OutputVariableDataSizeExceeded" } } \ No newline at end of file diff --git a/Tasks/DockerV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/DockerV1/Strings/resources.resjson/en-US/resources.resjson index 8c4117f079bf..4d33cf729667 100644 --- a/Tasks/DockerV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/DockerV1/Strings/resources.resjson/en-US/resources.resjson @@ -76,5 +76,6 @@ "loc.messages.CantWriteDataToFile": "Can not write data to the file %s. Error: %s", "loc.messages.NoDataWrittenOnFile": "No data was written into the file %s", "loc.messages.FileContentSynced": "Synced the file content to the disk. The content is %s.", - "loc.messages.DockerRegistryNotFound": "Docker registry service connection not specified." + "loc.messages.DockerRegistryNotFound": "Docker registry service connection not specified.", + "loc.messages.OutputVariableDataSizeExceeded": "Output variable not set as Docker command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s" } \ No newline at end of file diff --git a/Tasks/DockerV1/container.ts b/Tasks/DockerV1/container.ts index 61513abf8b3c..67a7f0d85de1 100644 --- a/Tasks/DockerV1/container.ts +++ b/Tasks/DockerV1/container.ts @@ -13,6 +13,7 @@ tl.setResourcePath(path.join(__dirname, 'task.json')); // get the registry server authentication provider var registryType = tl.getInput("containerregistrytype", true); var authenticationProvider : AuthenticationTokenProvider; +const environmentVariableMaximumSize = 32766; if(registryType == "Azure Container Registry"){ authenticationProvider = new ACRAuthenticationTokenProvider(tl.getInput("azureSubscriptionEndpoint"), tl.getInput("azureContainerRegistry")); @@ -68,7 +69,13 @@ commandImplementation.run(connection, (data) => result += data) } }) .then(function success() { - tl.setVariable("DockerOutput", result); + var commandOutputLength = result.length; + if (commandOutputLength > environmentVariableMaximumSize) { + tl.warning(tl.loc('OutputVariableDataSizeExceeded', commandOutputLength, environmentVariableMaximumSize)); + } else { + tl.setVariable("DockerOutput", result); + } + tl.setResult(tl.TaskResult.Succeeded, ""); }, function failure(err) { tl.setResult(tl.TaskResult.Failed, err.message); diff --git a/Tasks/DockerV1/task.json b/Tasks/DockerV1/task.json index fac4593d9223..4e6c883242d8 100644 --- a/Tasks/DockerV1/task.json +++ b/Tasks/DockerV1/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 1, - "Patch": 21 + "Patch": 23 }, "demands": [], "releaseNotes": "Simplified the task by:
 - Providing an option to simply select or type a command.
 - Retaining the useful input fields and providing an option to pass the rest as an argument to the command.", @@ -372,6 +372,7 @@ "CantWriteDataToFile": "Can not write data to the file %s. Error: %s", "NoDataWrittenOnFile": "No data was written into the file %s", "FileContentSynced": "Synced the file content to the disk. The content is %s.", - "DockerRegistryNotFound": "Docker registry service connection not specified." + "DockerRegistryNotFound": "Docker registry service connection not specified.", + "OutputVariableDataSizeExceeded": "Output variable not set as Docker command output exceeded the maximum supported length. Output length: %s, Maximum supported length: %s" } } \ No newline at end of file diff --git a/Tasks/DockerV1/task.loc.json b/Tasks/DockerV1/task.loc.json index 39a16bd51414..54ad3a1e5b29 100644 --- a/Tasks/DockerV1/task.loc.json +++ b/Tasks/DockerV1/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 1, - "Patch": 21 + "Patch": 23 }, "demands": [], "releaseNotes": "ms-resource:loc.releaseNotes", @@ -372,6 +372,7 @@ "CantWriteDataToFile": "ms-resource:loc.messages.CantWriteDataToFile", "NoDataWrittenOnFile": "ms-resource:loc.messages.NoDataWrittenOnFile", "FileContentSynced": "ms-resource:loc.messages.FileContentSynced", - "DockerRegistryNotFound": "ms-resource:loc.messages.DockerRegistryNotFound" + "DockerRegistryNotFound": "ms-resource:loc.messages.DockerRegistryNotFound", + "OutputVariableDataSizeExceeded": "ms-resource:loc.messages.OutputVariableDataSizeExceeded" } } \ No newline at end of file