From 91b3bed58aedf9f6aa31101c3d28ac7d0a1f0ae8 Mon Sep 17 00:00:00 2001 From: Steve Roberts Date: Mon, 22 Oct 2018 18:43:56 -0700 Subject: [PATCH 1/2] Fix issue #112, shell script task not initialized correctly when role-based credentials used --- CHANGELOG.md | 4 ++++ Tasks/AWSShellScript/helpers/AWSShellScriptTaskOperations.ts | 1 + _versioninfo.json | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99e1ed69..5354e035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.1.7 (TBD) + +* Fixed issue #112, shell task not initialized correctly when a role-based credential endpoint was used. + ### 1.1.6 (2018-10-01) * Bug fix to remove duplicate webpacked copy of the AWS SDK for Node.js which was causing issues with the user agent string set by the tools. diff --git a/Tasks/AWSShellScript/helpers/AWSShellScriptTaskOperations.ts b/Tasks/AWSShellScript/helpers/AWSShellScriptTaskOperations.ts index 1d6c83d7..e09fd816 100644 --- a/Tasks/AWSShellScript/helpers/AWSShellScriptTaskOperations.ts +++ b/Tasks/AWSShellScript/helpers/AWSShellScriptTaskOperations.ts @@ -81,6 +81,7 @@ export class TaskOperations { const credentials = await this.taskParameters.getCredentials(); if (credentials) { + await credentials.getPromise(); tl.debug('configure credentials into environment variables'); env.AWS_ACCESS_KEY_ID = credentials.accessKeyId; env.AWS_SECRET_ACCESS_KEY = credentials.secretAccessKey; diff --git a/_versioninfo.json b/_versioninfo.json index f2138132..9089363d 100644 --- a/_versioninfo.json +++ b/_versioninfo.json @@ -1,5 +1,5 @@ { "Major": "1", "Minor": "1", - "Patch": "6" + "Patch": "7" } From cdba47270ba6b134a5c3b8ea10c41819769d87ae Mon Sep 17 00:00:00 2001 From: Steve Roberts Date: Tue, 23 Oct 2018 08:28:01 -0700 Subject: [PATCH 2/2] Issue #115, make poll delay configurable in Beanstalk deployment task --- CHANGELOG.md | 3 ++- .../DeployApplicationTaskOperations.ts | 13 +++++++++--- .../DeployApplicationTaskParameters.ts | 21 +++++++++++++++++++ Tasks/BeanstalkDeployApplication/task.json | 12 ++++++++++- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5354e035..fbaff4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -### 1.1.7 (TBD) +### 1.1.7 (2018-10-24) * Fixed issue #112, shell task not initialized correctly when a role-based credential endpoint was used. +* Issue #115, added option to the Elastic Beanstalk deployment task allowing configuration of event polling frequency during deployment. The default (and minimum) delay is 5 seconds. Users can now specify a custom delay of up to 5 minutes (300 seconds) to help avoid throttling errors from the service when multiple deployments are in progress, all polling for events. ### 1.1.6 (2018-10-01) diff --git a/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskOperations.ts b/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskOperations.ts index d55dd178..144b40ee 100644 --- a/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskOperations.ts +++ b/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskOperations.ts @@ -69,7 +69,10 @@ export class TaskOperations { this.taskParameters.description, this.taskParameters.applicationType === TaskParameters.applicationTypeExistingVersion); - await this.waitForDeploymentCompletion(this.taskParameters.applicationName, this.taskParameters.environmentName, startingEventDate); + await this.waitForDeploymentCompletion(this.taskParameters.applicationName, + this.taskParameters.environmentName, + startingEventDate, + this.taskParameters.eventPollingDelay); if (this.taskParameters.outputVariable) { console.log(tl.loc('SettingOutputVariable', this.taskParameters.outputVariable, versionLabel)); @@ -137,7 +140,8 @@ export class TaskOperations { private async waitForDeploymentCompletion(applicationName: string, environmentName: string, - startingEventDate: Date): Promise { + startingEventDate: Date, + eventPollDelay: number): Promise { const requestEnvironment: Beanstalk.DescribeEnvironmentsMessage = { ApplicationName: applicationName, @@ -153,12 +157,15 @@ export class TaskOperations { let lastPrintedEventDate = startingEventDate; console.log(tl.loc('WaitingForDeployment')); + console.log(tl.loc('ConfiguredEventPollDelay', eventPollDelay)); + console.log(tl.loc('EventsComing')); let success = true; let environment: Beanstalk.EnvironmentDescription; do { - await this.sleep(5000); + tl.debug(`...event poll sleep for ${eventPollDelay}s`); + await this.sleep(eventPollDelay * 1000); const responseEnvironments = await this.beanstalkClient.describeEnvironments(requestEnvironment).promise(); if (responseEnvironments.Environments.length === 0) { diff --git a/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskParameters.ts b/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskParameters.ts index 2c2a06b4..e224c3ce 100644 --- a/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskParameters.ts +++ b/Tasks/BeanstalkDeployApplication/helpers/DeployApplicationTaskParameters.ts @@ -14,9 +14,13 @@ export class TaskParameters extends AWSTaskParametersBase { // options for applicationType public static readonly applicationTypeAspNet: string = 'aspnet'; public static readonly applicationTypeAspNetCoreForWindows: string = 'aspnetCoreWindows'; + public static readonly applicationTypeS3Archive: string = 's3'; public static readonly applicationTypeExistingVersion: string = 'version'; + public static readonly defaultEventPollingDelay: number = 5; // seconds + public static readonly maxEventPollingDelay: number = 300; // seconds, 5 mins + public applicationName: string; public environmentName: string; public applicationType: string; @@ -28,6 +32,7 @@ export class TaskParameters extends AWSTaskParametersBase { public description: string; public outputVariable: string; + public eventPollingDelay: number = TaskParameters.defaultEventPollingDelay; constructor() { super(); @@ -62,6 +67,22 @@ export class TaskParameters extends AWSTaskParametersBase { this.versionLabel = tl.getInput('versionLabel', this.applicationType === TaskParameters.applicationTypeExistingVersion); this.description = tl.getInput('description', false); this.outputVariable = tl.getInput('outputVariable', false); + const pollDelay = tl.getInput('eventPollingDelay', false); + if (pollDelay) { + try { + const pollDelayValue = parseInt(pollDelay, 10); + if (pollDelayValue >= TaskParameters.defaultEventPollingDelay && pollDelayValue <= TaskParameters.maxEventPollingDelay) { + this.eventPollingDelay = pollDelayValue; + } else { + throw new Error(); + } + } catch { + console.log(tl.loc('InvalidEventPollDelay', + pollDelay, + TaskParameters.defaultEventPollingDelay, + TaskParameters.maxEventPollingDelay)); + } + } } catch (error) { throw new Error(error.message); } diff --git a/Tasks/BeanstalkDeployApplication/task.json b/Tasks/BeanstalkDeployApplication/task.json index 8b5ce301..11dbb3be 100644 --- a/Tasks/BeanstalkDeployApplication/task.json +++ b/Tasks/BeanstalkDeployApplication/task.json @@ -126,7 +126,7 @@ "type": "string", "required": false, "defaultValue": "", - "helpMarkDown": "Optional description of the version" + "helpMarkDown": "Optional description of the version." }, { "name": "outputVariable", @@ -136,6 +136,14 @@ "helpMarkDown": "The name of the variable that will contain the version label of the new application revision.", "required": false }, + { + "name": "eventPollingDelay", + "type": "string", + "label": "Event poll delay (seconds)", + "defaultValue": "5", + "helpMarkDown": "The time, in seconds, to wait between calls to retrieve the latest events from the deployment to the environment.", + "required": false + }, { "name": "logRequest", "type": "boolean", @@ -188,6 +196,8 @@ "SettingOutputVariable": "Setting output variable %s with the version label %s", "ApplicationExistsQueryError": "DescribeApplications: error %s returned querying for existence of application %s", "EnvironmentExistsQueryError": "DescribeEnvironments: error %s thrown querying for existence of environment %s for application %s", + "InvalidEventPollDelay": "Event polling delay setting of %s is invalid (minimum %s seconds, maximum %s seconds) - task will use minimum poll delay by default", + "ConfiguredEventPollDelay": "Task configured to wait %s seconds between queries for deployment events", "TaskCompleted": "Deployment to application %s completed" } }