Skip to content

Commit

Permalink
fix(deadline): use new repository installer log path for Deadline 10.…
Browse files Browse the repository at this point in the history
…2.* (#895)
  • Loading branch information
AWS-Samuel authored Dec 2, 2022
1 parent 19603ed commit c6db7c0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/aws-rfdk/lib/deadline/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ export class Repository extends Construct implements IRepository {
'/var/log/cloud-init-output.log');
cloudWatchConfigurationBuilder.addLogsCollectList(logGroup.logGroupName,
'deadlineRepositoryInstallationLogs',
'/tmp/bitrock_installer.log');
this.version.isLessThan(Version.MINIMUM_VERSION_USING_NEW_INSTALLBUILDER_LOG) ? '/tmp/bitrock_installer.log' : '/tmp/installbuilder_installer.log');

new CloudWatchAgent(this, 'RepositoryInstallerLogsConfig', {
cloudWatchConfig: cloudWatchConfigurationBuilder.generateCloudWatchConfiguration(),
Expand Down
5 changes: 5 additions & 0 deletions packages/aws-rfdk/lib/deadline/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export class Version implements IPatchVersion {
*/
public static readonly MINIMUM_SECRETS_MANAGEMENT_VERSION = new Version([10, 1, 19, 0]);

/**
* The minimum Deadline version which uses Install Builder instead of Bitrock Installer.
*/
public static readonly MINIMUM_VERSION_USING_NEW_INSTALLBUILDER_LOG = new Version([10, 2, 0, 0]);

/**
* This method parses the input string and returns the version object.
*
Expand Down
59 changes: 36 additions & 23 deletions packages/aws-rfdk/lib/deadline/test/repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ let app: App;
let stack: Stack;
let vpc: IVpc;
let version: IVersion;
let installers: PlatformInstallers;

function escapeTokenRegex(s: string): string {
// A CDK Token looks like: ${Token[TOKEN.12]}
Expand All @@ -80,6 +81,18 @@ function escapeTokenRegex(s: string): string {
return s.replace(/[.${}[\]]/g, '\\$&');
}

function create_version(version_array: number[]): IVersion {
class MockVersion extends Version implements IVersion {
readonly linuxInstallers: PlatformInstallers = installers;

public linuxFullVersionString() {
return this.toString();
}
}

return new MockVersion(version_array);
}

beforeEach(() => {
app = new App();
stack = new Stack(app, 'Stack');
Expand All @@ -99,26 +112,18 @@ beforeEach(() => {
},
],
});

class MockVersion extends Version implements IVersion {
readonly linuxInstallers: PlatformInstallers = {
patchVersion: 0,
repository: {
objectKey: 'testInstaller',
s3Bucket: new Bucket(stack, 'LinuxInstallerBucket'),
},
client: {
objectKey: 'testClientInstaller',
s3Bucket: new Bucket(stack, 'LinuxClientInstallerBucket'),
},
};

public linuxFullVersionString() {
return this.toString();
}
}

version = new MockVersion([10,1,19,4]);
installers = {
patchVersion: 0,
repository: {
objectKey: 'testInstaller',
s3Bucket: new Bucket(stack, 'LinuxInstallerBucket'),
},
client: {
objectKey: 'testClientInstaller',
s3Bucket: new Bucket(stack, 'LinuxClientInstallerBucket'),
},
};
version = create_version([10,1,19,4]);
});

test('can create two repositories', () => {
Expand Down Expand Up @@ -403,11 +408,17 @@ test('default repository installer log group created correctly', () => {
});
});

test('repository installer logs all required files', () => {
test.each([
[[10,1,19,4]],
[[10,2,0,9]],
])('repository installer logs all required files', (version_array: number[]) => {
// GIVEN
const repository_version = create_version(version_array);

// WHEN
new Repository(stack, 'repositoryInstaller', {
vpc,
version,
version: repository_version,
});

// THEN
Expand All @@ -424,7 +435,9 @@ test('repository installer logs all required files', () => {
{}, // log group name. checked in another test.
'\",\"log_stream_name\":\"cloud-init-output-{instance_id}\",\"file_path\":\"/var/log/cloud-init-output.log\",\"timezone\":\"Local\"},{\"log_group_name\":\"',
{}, // log group name again.
'\",\"log_stream_name\":\"deadlineRepositoryInstallationLogs-{instance_id}\",\"file_path\":\"/tmp/bitrock_installer.log\",\"timezone\":\"Local\"}]}},\"log_stream_name\":\"DefaultLogStream-{instance_id}\",\"force_flush_interval\":15}}',
'\",\"log_stream_name\":\"deadlineRepositoryInstallationLogs-{instance_id}\",\"file_path\":\"/tmp/'+
(repository_version.isLessThan(Version.MINIMUM_VERSION_USING_NEW_INSTALLBUILDER_LOG) ? 'bitrock' : 'installbuilder') +
'_installer.log\",\"timezone\":\"Local\"}]}},\"log_stream_name\":\"DefaultLogStream-{instance_id}\",\"force_flush_interval\":15}}',
],
],
},
Expand Down

0 comments on commit c6db7c0

Please sign in to comment.