Skip to content

Commit

Permalink
Addressed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
horsmand committed Oct 28, 2020
1 parent 7628be4 commit ed9afc9
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
ThinkboxDockerRecipes,
UsageBasedLicense,
UsageBasedLicensing,
VersionQuery,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
*/

import { App, Stack } from '@aws-cdk/core';
import { VersionQuery } from 'aws-rfdk/deadline';
import {
Stage,
ThinkboxDockerRecipes,
} from 'aws-rfdk/deadline';

import { RenderStruct } from '../../../../lib/render-struct';
import { DatabaseType, StorageStruct } from '../../../../lib/storage-struct';
Expand All @@ -22,14 +25,17 @@ const integStackTag = process.env.INTEG_STACK_TAG!.toString();
// Create component stack
const componentTier = new Stack(app, 'RFDKInteg-RQ-ComponentTier' + integStackTag, {env});

// This will get the installers for the latest version of Deadline
const version = new VersionQuery(componentTier, 'VersionQuery');
const stagePath = process.env.DEADLINE_STAGING_PATH!.toString();
// Stage docker recipes, which include image used for the render queue instance
const recipes = new ThinkboxDockerRecipes(componentTier, 'DockerRecipes', {
stage: Stage.fromDirectory(stagePath),
});

// Add struct containing Deadline repository (the same repo is used for all test configurations)
const storage = new StorageStruct(componentTier, 'StorageStruct', {
integStackTag,
databaseType: DatabaseType.DocDB,
version,
version: recipes.version,
});

const structs: Array<RenderStruct> = [
Expand All @@ -38,14 +44,14 @@ const structs: Array<RenderStruct> = [
integStackTag,
repository: storage.repo,
protocol: 'http',
version,
recipes,
}),
//Create test struct for Render Queue in https mode
new RenderStruct(componentTier, 'RenderStructRQ2', {
integStackTag,
repository: storage.repo,
protocol: 'https',
version,
recipes,
}),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
*/

import { App, Stack } from '@aws-cdk/core';
import { VersionQuery } from 'aws-rfdk/deadline';
import {
Stage,
ThinkboxDockerRecipes,
} from 'aws-rfdk/deadline';

import { RenderStruct } from '../../../../lib/render-struct';
import { DatabaseType, StorageStruct } from '../../../../lib/storage-struct';
Expand Down Expand Up @@ -32,21 +35,24 @@ oss.forEach( os => {
// Create component stack for structs
const componentTier = new Stack(app, 'RFDKInteg-' + testId + '-ComponentTier' + integStackTag, {env});

// This will get the installers for the latest version of Deadline
const version = new VersionQuery(componentTier, 'VersionQuery');
const stagePath = process.env.DEADLINE_STAGING_PATH!.toString();
// Stage docker recipes, which include image used for the render queue instance
const recipes = new ThinkboxDockerRecipes(componentTier, 'DockerRecipes', {
stage: Stage.fromDirectory(stagePath),
});

// Create StorageStruct with repository
const storage = new StorageStruct(componentTier, 'StorageStruct' + testId, {
integStackTag,
databaseType: DatabaseType.DocDB,
version,
version: recipes.version,
});
// Create render queue with either HTTP or HTTPS protocol
const render = new RenderStruct(componentTier, 'RenderStruct' + testId, {
integStackTag,
repository: storage.repo,
protocol,
version,
recipes,
});
// Create worker struct containing three nodes using either Linux or Windows
structs.push(new WorkerStruct(componentTier, 'WorkerStruct' + testId, {
Expand Down
14 changes: 3 additions & 11 deletions integ/lib/render-struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import { Construct, Stack } from '@aws-cdk/core';
import { X509CertificatePem } from 'aws-rfdk';
import {
IRepository,
IVersion,
RenderQueue,
Stage,
ThinkboxDockerRecipes,
} from 'aws-rfdk/deadline';

export interface RenderStructProps {
readonly integStackTag: string;
readonly repository: IRepository;
readonly protocol: string;
readonly version: IVersion
readonly recipes: ThinkboxDockerRecipes;
}

export class RenderStruct extends Construct {
Expand All @@ -32,16 +30,10 @@ export class RenderStruct extends Construct {

// Collect environment variables
const infrastructureStackName = 'RFDKIntegInfrastructure' + props.integStackTag;
const stagePath = process.env.DEADLINE_STAGING_PATH!.toString();

// Retrieve VPC created for _infrastructure stack
const vpc = Vpc.fromLookup(this, 'Vpc', { tags: { StackName: infrastructureStackName }}) as Vpc;

// Stage docker recipes, which include image used for the render queue instance
const recipes = new ThinkboxDockerRecipes(this, 'DockerRecipes', {
stage: Stage.fromDirectory(stagePath),
});

const host = 'renderqueue';
const zoneName = Stack.of(this).stackName + '.local';

Expand Down Expand Up @@ -85,12 +77,12 @@ export class RenderStruct extends Construct {
var renderQueueProps = {
vpc,
repository: props.repository,
images: recipes.renderQueueImages,
images: props.recipes.renderQueueImages,
logGroupProps: {
logGroupPrefix: Stack.of(this).stackName + '-' + id,
},
hostname,
version: props.version,
version: props.recipes.version,
trafficEncryption,
deletionProtection: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export abstract class SimpleCustomResource {
try {
if (requestType === 'Create') {
if (!this.validateInput(resourceProperties)) {
throw Error('Input did not pass validation check');
throw Error(`Input did not pass validation check. Check log group "${context.logGroupName}" ` +
`for log stream ${context.logStreamName} for additional information.`);
}
cfnData = await this.doCreate(physicalId, resourceProperties);
console.debug(`Create data: ${JSON.stringify(cfnData)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
*/

export * from './version';
export * from './version-provider';
export * from './version-provider';
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ export interface FlatVersionedUriOutput {
*/
readonly LinuxPatchVersion: string;

/**
* The patch version of the Linux installer. For example, "d" in "a.b.c.d".
*/
readonly LinuxFullVersionString: string;

/**
* The object key of the Deadline repository installer for Linux.
*/
Expand Down Expand Up @@ -107,12 +102,6 @@ export class VersionProviderResource extends SimpleCustomResource {
MinorVersion: deadlineLinux.MinorVersion,
ReleaseVersion: deadlineLinux.ReleaseVersion,
LinuxPatchVersion: deadlineLinux.PatchVersion,
LinuxFullVersionString: Version.convertToFullVersionString(
deadlineLinux.MajorVersion,
deadlineLinux.MinorVersion,
deadlineLinux.ReleaseVersion,
deadlineLinux.PatchVersion,
),
LinuxRepositoryInstaller: linuxRepoObjectKey,
};
}
Expand All @@ -130,7 +119,10 @@ export class VersionProviderResource extends SimpleCustomResource {
if (!value || typeof(value) !== 'object') { return false; }

if (value.versionString) {
if (!Version.validateVersionString(value.versionString)) { return false; }
if (!Version.validateVersionString(value.versionString)) {
console.log(`Failed to validate the version string: ${value.versionString}`);
return false;
}
}

return true;
Expand Down
9 changes: 1 addition & 8 deletions packages/aws-rfdk/lib/deadline/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,21 +792,14 @@ export class Repository extends Construct implements IRepository {

this.databaseConnection.addInstallerDBArgs(installerGroup);

if (!version.linuxInstallers?.repository) {
throw new Error('Version given to Repository must provide a Linux Repository installer.');
}
const linuxVersionString = version.linuxFullVersionString;
if (!linuxVersionString) {
throw new Error('Version given to Repository must provide a full Linux version string.');
}
version.linuxInstallers.repository.s3Bucket.grantRead(installerGroup, version.linuxInstallers.repository.objectKey);

installerScriptAsset.executeOn({
host: installerGroup,
args: [
`"s3://${version.linuxInstallers.repository.s3Bucket.bucketName}/${version.linuxInstallers.repository.objectKey}"`,
`"${installPath}"`,
linuxVersionString,
version.linuxFullVersionString(),
],
});
}
Expand Down
2 changes: 0 additions & 2 deletions packages/aws-rfdk/lib/deadline/lib/thinkbox-docker-recipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ export class ThinkboxDockerRecipes extends Construct {

this.version = props.stage.getVersion(this, 'Version');

// this.versionQuery = props.stage.getVersion(this, 'Version');

for (const recipe of [ThinkboxManagedDeadlineDockerRecipes.RemoteConnectionServer, ThinkboxManagedDeadlineDockerRecipes.LicenseForwarder]) {
if (!props.stage.manifest.recipes[recipe]) {
throw new Error(`Could not find ${recipe} recipe`);
Expand Down
19 changes: 12 additions & 7 deletions packages/aws-rfdk/lib/deadline/lib/version-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class VersionQueryBase extends Construct implements IVersion {
/**
* @inheritdoc
*/
readonly abstract linuxFullVersionString: string;
abstract linuxFullVersionString(): string;
}

/**
Expand Down Expand Up @@ -105,11 +105,6 @@ export class VersionQuery extends VersionQueryBase {
*/
readonly releaseVersion: number;

/**
* @inheritdoc
*/
readonly linuxFullVersionString: string;

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -144,7 +139,6 @@ export class VersionQuery extends VersionQueryBase {
this.minorVersion = Token.asNumber(deadlineResource.getAtt('MinorVersion'));
this.releaseVersion = Token.asNumber(deadlineResource.getAtt('ReleaseVersion'));

this.linuxFullVersionString = Token.asString(deadlineResource.getAtt('LinuxFullVersionString'));
this.linuxInstallers = {
patchVersion: Token.asNumber(deadlineResource.getAtt('LinuxPatchVersion')),
repository: {
Expand All @@ -153,4 +147,15 @@ export class VersionQuery extends VersionQueryBase {
},
};
}

public linuxFullVersionString(): string {
const major = Token.isUnresolved(this.majorVersion) ? Token.asString(this.majorVersion) : this.majorVersion.toString();
const minor = Token.isUnresolved(this.minorVersion) ? Token.asString(this.minorVersion) : this.minorVersion.toString();
const release = Token.isUnresolved(this.releaseVersion) ? Token.asString(this.releaseVersion) : this.releaseVersion.toString();
const patch = Token.isUnresolved(this.linuxInstallers.patchVersion)
? Token.asString(this.linuxInstallers.patchVersion)
: this.linuxInstallers.patchVersion.toString();

return `${major}.${minor}.${release}.${patch}`;
}
}
2 changes: 1 addition & 1 deletion packages/aws-rfdk/lib/deadline/lib/version-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ export interface IVersion extends IReleaseVersion {
* this version object. This is constructed by joining the major, minor,
* release, and patch versions by dots.
*/
readonly linuxFullVersionString: string;
linuxFullVersionString(): string;
}
4 changes: 2 additions & 2 deletions packages/aws-rfdk/lib/deadline/test/asset-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export const RQ_CONNECTION_ASSET = {
};

export const VERSION_QUERY_ASSET = {
Bucket: stringLike('AssetParameters*S3Bucket75763B6A'),
Key: stringLike('AssetParameters*S3VersionKeyCF2C67CB'),
Bucket: stringLike('AssetParameters*S3Bucket56D7A778'),
Key: stringLike('AssetParameters*S3VersionKey35C44157'),
};
2 changes: 1 addition & 1 deletion packages/aws-rfdk/lib/deadline/test/repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ beforeEach(() => {
s3Bucket: new Bucket(stack, 'InstallerBucket'),
},
},
linuxFullVersionString: '10.1.9.2',
linuxFullVersionString: () => '10.1.9.2',
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as path from 'path';

import {
expect as expectCDK,
haveResource,
haveResourceLike,
} from '@aws-cdk/assert';
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
import {
Expand Down Expand Up @@ -138,7 +138,9 @@ describe('ThinkboxDockerRecipes', () => {
stage,
});

expectCDK(stack).to(haveResource('Custom::RFDK_DEADLINE_INSTALLERS'));
expectCDK(stack).to(haveResourceLike('Custom::RFDK_DEADLINE_INSTALLERS', {
versionString: FULL_VERSION_STRING,
}));
});

test.each([
Expand Down

0 comments on commit ed9afc9

Please sign in to comment.