Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deadline): Allow passing Context to SEP config #1211

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export class ConfigureSpotEventPlugin extends Construct {
ValidUntil: fleet.validUntil?.date.toISOString(),
// Need to convert from IResolvable to bypass TypeScript
TagSpecifications: (spotFleetRequestTagsToken as unknown) as SpotFleetTagSpecification[],
Context: fleet.context,
};

const spotFleetRequestConfigurations = fleet.deadlineGroups.map(group => {
Expand Down
18 changes: 16 additions & 2 deletions packages/aws-rfdk/lib/deadline/lib/spot-event-plugin-fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
ISecurityGroup,
IVpc,
LaunchTemplate,
LaunchTemplateSpecialVersions,
OperatingSystemType,
Port,
SecurityGroup,
Expand Down Expand Up @@ -207,6 +206,13 @@ export interface SpotEventPluginFleetProps {
*/
readonly validUntil?: Expiration;

/**
* Reserved
*
* @default - No context string
*/
readonly context?: string;

/**
* Properties for setting up the Deadline Worker's LogGroup
* @default - LogGroup will be created with all properties' default values and a prefix of "/renderfarm/".
Expand Down Expand Up @@ -429,6 +435,13 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
*/
public readonly validUntil?: Expiration;

/**
* Reserved
*
* @default - No context string
*/
public readonly context?: string;

/**
* The Block devices that will be attached to your workers.
*
Expand Down Expand Up @@ -488,6 +501,7 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
this.maxCapacity = props.maxCapacity;
this.validUntil = props.validUntil;
this.keyName = props.keyName;
this.context = props.context;

const imageConfig = props.workerMachineImage.getImage(this);
this.osType = imageConfig.osType;
Expand Down Expand Up @@ -563,7 +577,7 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
this.subnets.subnetIds.forEach(subnetId => {
launchTemplateConfigs.push({
LaunchTemplateSpecification: {
Version: LaunchTemplateSpecialVersions.LATEST_VERSION,
Version: this.launchTemplate.versionNumber,
LaunchTemplateId: this.launchTemplate.launchTemplateId,
LaunchTemplateName: this.launchTemplate.launchTemplateName,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('ConfigureSpotEventPlugin', () => {
LaunchTemplateConfigs: Match.arrayWith([
Match.objectLike({
LaunchTemplateSpecification: {
Version: '$Latest',
Version: stack.resolve(fleet.launchTemplate.versionNumber),
LaunchTemplateId: stack.resolve(fleet.launchTemplate.launchTemplateId),
},
}),
Expand Down Expand Up @@ -407,6 +407,42 @@ describe('ConfigureSpotEventPlugin', () => {
}),
}));
});

test('fleet with context', () => {
// GIVEN
const context = 'context-abcdef';
const fleetWithCustomProps = new SpotEventPluginFleet(stack, 'SpotEventPluginFleet', {
vpc,
renderQueue,
deadlineGroups: [
groupName,
],
instanceTypes: [
InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
],
workerMachineImage,
maxCapacity: 1,
context,
});

// WHEN
new ConfigureSpotEventPlugin(stack, 'ConfigureSpotEventPlugin', {
vpc,
renderQueue: renderQueue,
spotFleets: [
fleetWithCustomProps,
],
});

// THEN
Template.fromStack(stack).hasResourceProperties('Custom::RFDK_ConfigureSpotEventPlugin', Match.objectLike({
spotFleetRequestConfigurations: Match.objectLike({
[groupName]: Match.objectLike({
Context: context,
}),
}),
}));
});
});

test('only one object allowed per render queue', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function convertSpotFleetRequestConfiguration(spotFleetRequestConfigs: Sp
Type: validateString(sfrConfigs.Type, `${group_name}.Type`),
ValidUntil: validateStringOptional(sfrConfigs.ValidUntil, `${group_name}.ValidUntil`),
TagSpecifications: convertTagSpecifications(sfrConfigs.TagSpecifications, `${group_name}.TagSpecifications`),
Context: validateStringOptional(sfrConfigs.Context, `${group_name}.Context`),
};
convertedSpotFleetRequestConfigs[group_name] = convertedSpotFleetRequestProps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ export interface SpotFleetRequestProps {
* @default - the Spot Fleet request remains until you cancel it.
*/
readonly ValidUntil?: string;

/**
* Reserved
*
* @default - No context string
*/
readonly Context?: string;
}

/**
Expand Down