From 291f9033389157b745a0a812b4cb5584ea5fe05c Mon Sep 17 00:00:00 2001 From: Yash Datre <61063871+yashda@users.noreply.github.com> Date: Fri, 18 Sep 2020 11:27:45 -0500 Subject: [PATCH] fix(deadline): adding deadline version check for workers (#100) fix(deadline): adding deadline version check for workers While configuring deadline workers if the installed deadline client version is less than the minimum supported deadline version then we now fail during deployment. Also updating the deadline readme. Verified by installing a higher and lower versions for both windows and linux. --- packages/aws-rfdk/lib/deadline/README.md | 6 ++++++ .../aws-rfdk/lib/deadline/lib/worker-fleet.ts | 8 +++++++- .../deadline/scripts/bash/configureWorker.sh | 17 +++++++++++++++++ .../scripts/powershell/configureWorker.ps1 | 15 ++++++++++++++- .../lib/deadline/test/asset-constants.ts | 4 ++-- .../lib/deadline/test/worker-fleet.test.ts | 5 +++-- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/packages/aws-rfdk/lib/deadline/README.md b/packages/aws-rfdk/lib/deadline/README.md index e1f17eab8..36156da9d 100644 --- a/packages/aws-rfdk/lib/deadline/README.md +++ b/packages/aws-rfdk/lib/deadline/README.md @@ -6,6 +6,12 @@ The `aws-rfdk/deadline` sub-module contains Deadline-specific constructs that ca import * as deadline from 'aws-rfdk/deadline'; ``` +--- + +_**Note:** RFDK constructs currently support Deadline 10.1.9 and later._ + +--- + - [Render Queue](#render-queue) - [Docker Container Images](#render-queue-docker-container-images) - [Encryption](#render-queue-encryption) diff --git a/packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts b/packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts index fd8628965..4e64dac9c 100644 --- a/packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts +++ b/packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts @@ -56,6 +56,7 @@ import { import { IRenderQueue, } from './render-queue'; +import { Version } from './version'; /** * Interface for Deadline Worker Fleet. @@ -181,12 +182,16 @@ export interface WorkerInstanceFleetProps { /** * Health Monitor component to monitor the health of instances. * + * Note: The health-check feature is supported with Deadline Client v10.1.9 and later. + * * @default - Health Monitoring is turned-off */ readonly healthMonitor?: IHealthMonitor; /** - * Properties for configuring a health check + * Properties for configuring a health check. + * + * Note: The health-check feature is supported with Deadline Client v10.1.9 and later. * * @default properties of HealthCheckConfig applies */ @@ -548,6 +553,7 @@ export class WorkerInstanceFleet extends WorkerInstanceFleetBase { `'${groups}'`, `'${pools}'`, `'${props.region || ''}'`, + `'${Version.MINIMUM_SUPPORTED_DEADLINE_VERSION.toString()}'`, ], }); } diff --git a/packages/aws-rfdk/lib/deadline/scripts/bash/configureWorker.sh b/packages/aws-rfdk/lib/deadline/scripts/bash/configureWorker.sh index a53813983..ddd39e717 100644 --- a/packages/aws-rfdk/lib/deadline/scripts/bash/configureWorker.sh +++ b/packages/aws-rfdk/lib/deadline/scripts/bash/configureWorker.sh @@ -9,6 +9,7 @@ # $2: comma separated groups # $3: comma separated pools # $4: region +# $5: minimum supported deadline version # exit when any command fails set -xeuo pipefail @@ -17,6 +18,7 @@ HEALTH_CHECK_PORT="$1" WORKER_GROUPS=(${2//,/ }) WORKER_POOLS=(${3//,/ }) WORKER_REGION="$4" +MINIMUM_SUPPORTED_DEADLINE_VERSION=$5 # Cloud-init does not load system environment variables. Cherry-pick the # environment variable installed by the Deadline Client installer. @@ -36,6 +38,21 @@ if [ ! -f "$DEADLINE_COMMAND" ]; then exit 1 fi +isVersionLessThan() { + python -c "import sys;sys.exit(0 if tuple(map(int, sys.argv[-2].split('.'))) < tuple(map(int, sys.argv[-1].split('.'))) else 1)" "$1" "$2" +} + +DEADLINE_VERSION=$("$DEADLINE_COMMAND" -Version | grep -oP '[v]\K\d+\.\d+\.\d+\.\d+\b') +if [ -z "$DEADLINE_VERSION" ]; then + echo "ERROR: Unable to identify the version of installed Deadline Client. Exiting..." + exit 1 +fi + +if isVersionLessThan $DEADLINE_VERSION $MINIMUM_SUPPORTED_DEADLINE_VERSION; then + echo "ERROR: Installed Deadline Version ($DEADLINE_VERSION) is less than the minimum supported version ($MINIMUM_SUPPORTED_DEADLINE_VERSION). Exiting..." + exit 1 +fi + # launch worker at launcher startup "$DEADLINE_COMMAND" -SetIniFileSetting LaunchSlaveAtStartup True # keep worker running diff --git a/packages/aws-rfdk/lib/deadline/scripts/powershell/configureWorker.ps1 b/packages/aws-rfdk/lib/deadline/scripts/powershell/configureWorker.ps1 index 1746cbe20..9f342ca17 100644 --- a/packages/aws-rfdk/lib/deadline/scripts/powershell/configureWorker.ps1 +++ b/packages/aws-rfdk/lib/deadline/scripts/powershell/configureWorker.ps1 @@ -9,7 +9,9 @@ param ( [Parameter(Mandatory=$True)] $workerPools, [Parameter(Mandatory=$True)] - $workerRegion + $workerRegion, + [Parameter(Mandatory=$True)] + $minimumSupportedDeadlineVersion ) Set-PSDebug -Trace 1 @@ -28,6 +30,17 @@ if (!(Test-Path $DEADLINE_COMMAND)) { exit 1 } +$DeadlineVersion = (& $DEADLINE_COMMAND -Version | Out-String) | Select-String -Pattern '[v](\d+\.\d+\.\d+\.\d+)\b' | % {$_.Matches.Groups[1].Value} +if ([string]::IsNullOrEmpty($DeadlineVersion)) { + Write-Host "ERROR: Unable to identify the version of installed Deadline Client. Exiting..." + exit 1 +} + +if([System.Version]$DeadlineVersion -lt [System.Version]$minimumSupportedDeadlineVersion) { + Write-Host "ERROR: Installed Deadline Version ($($DeadlineVersion)) is less than the minimum supported version ($($minimumSupportedDeadlineVersion)). Exiting..." + exit 1 +} + # launch worker at launcher startup & $DEADLINE_COMMAND -SetIniFileSetting LaunchSlaveAtStartup True | Out-Default # keep worker running diff --git a/packages/aws-rfdk/lib/deadline/test/asset-constants.ts b/packages/aws-rfdk/lib/deadline/test/asset-constants.ts index 83104a163..94ddd73d8 100644 --- a/packages/aws-rfdk/lib/deadline/test/asset-constants.ts +++ b/packages/aws-rfdk/lib/deadline/test/asset-constants.ts @@ -11,8 +11,8 @@ export {CWA_ASSET_LINUX}; // configureWorker.sh export const CONFIG_WORKER_ASSET_LINUX = { - Bucket: 'AssetParameters2435996be08703cd3819e249890abb41cc0860324e5cfe1b5945704934db7101S3BucketB40BB072', - Key: 'AssetParameters2435996be08703cd3819e249890abb41cc0860324e5cfe1b5945704934db7101S3VersionKey4F3F9A7F', + Bucket: 'AssetParameters3915f098ad4813270754c05c4e236d137da778773dfb13912fa54f387cc5929aS3BucketE7DA333E', + Key: 'AssetParameters3915f098ad4813270754c05c4e236d137da778773dfb13912fa54f387cc5929aS3VersionKey1C0D482D', }; // configureWorker.ps1 diff --git a/packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts b/packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts index 08494476e..a538ec83d 100644 --- a/packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts +++ b/packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts @@ -44,6 +44,7 @@ import { IRenderQueue, RenderQueue, Repository, + Version, VersionQuery, WorkerInstanceFleet, } from '../lib'; @@ -685,7 +686,7 @@ test('default worker fleet is created correctly custom subnet values', () => { }, ], }, - "' '6161' '' '' ''", + `' '6161' '' '' '' '${Version.MINIMUM_SUPPORTED_DEADLINE_VERSION}'`, ], ], }); @@ -1085,7 +1086,7 @@ test('default worker fleet is created correctly with groups, pools and region', }, ], }, - "' '63415' 'a,b' 'c,d' 'E'", + `' '63415' 'a,b' 'c,d' 'E' '${Version.MINIMUM_SUPPORTED_DEADLINE_VERSION}'`, ]], }); });