Skip to content

Commit

Permalink
add upgrade documentation and general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jericht committed Nov 10, 2021
1 parent ec959cd commit 5d85d5d
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():
sep_props = sep_stack.SEPStackProps(
docker_recipes_stage_path=os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'stage'),
worker_machine_image=MachineImage.generic_linux(config.deadline_client_linux_ami_map),
deadline_resource_tracker_exists=config.create_resource_tracker_role,
create_resource_tracker_role=config.create_resource_tracker_role,
)
service = sep_stack.SEPStack(app, 'SEPStack', props=sep_props, env=env)

Expand Down
1 change: 1 addition & 0 deletions packages/aws-rfdk/docs/upgrade/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ upgrading to (or beyond) a version listed below, you should consult the the link
* [`0.27.x`](./upgrading-0.27.md)
* [`0.37.x`](./upgrading-0.37.md)
* [`0.38.x`](./upgrading-0.38.md)
* [`0.39.x`](./upgrading-0.39.md)
13 changes: 13 additions & 0 deletions packages/aws-rfdk/docs/upgrade/upgrading-0.39.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Upgrading to RFDK v0.39.x or Newer

Starting in RFDK v0.39.0, the `SpotEventPluginFleet` construct now creates an [EC2 Launch Template](https://docs.aws.amazon.com/autoscaling/ec2/userguide/LaunchTemplates.html)
instead of using Launch Specifications. This change will reconfigure the Spot Event Plugin settings in Deadline to use a new Spot Fleet Request configuration. If you have active
Spot Fleet Requests created by the Spot Event Plugin, upgrading to RFDK v0.39.x and redeploying your render farm will orphan those Spot Fleet Requests. Therefore, we highly
recommend following these instructions to upgrade to RFDK v0.39.x:

1. Disable the Spot Event Plugin in Deadline. Refer to the [Spot Event Plugin "State" option in Deadline](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/event-spot-configuration-options.html)
for more information.
2. Cancel any Spot Fleet Requests created by the Spot Event Plugin, which you can do by following these [instructions](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/work-with-spot-fleets.html#cancel-spot-fleet).
3. Upgrade to RFDK v0.39.x and redeploy your render farm.
4. Once the deployment is complete, re-enable the Spot Event Plugin in Deadline. Refer to the [Spot Event Plugin "State" option in Deadline](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/event-spot-configuration-options.html)
for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export interface SpotEventPluginSettings {

/**
* Determines whether the Deadline Resource Tracker should be used.
*
* In addition to this property, the Spot Instances deployed by the Spot Event Plugin must also be configured to be tracked by the Resource Tracker using the
* [`trackInstancesWithResourceTracker`](https://docs.aws.amazon.com/rfdk/api/latest/docs/aws-rfdk.deadline.SpotEventPluginFleet.html#trackinstanceswithresourcetracker)
* property of the `SpotEventPluginFleet` construct, which is `true` by default. You can set that property to `false` for fleets that you would like to opt out of the
* Resource Tracker.
*
* See https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/resource-tracker-overview.html
*
* @default true
Expand Down
12 changes: 5 additions & 7 deletions packages/aws-rfdk/lib/deadline/lib/spot-event-plugin-fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export interface SpotEventPluginFleetProps {
/**
* Whether the instances in the Spot Fleet should be tracked by Deadline Resource Tracker.
*
* In addition to this property, the Spot Event Plugin must also be configured to use the Resource tracker by using the
* [`enableResourceTracker`](https://docs.aws.amazon.com/rfdk/api/latest/docs/aws-rfdk.deadline.SpotEventPluginSettings.html#enableresourcetracker)
* property of the `ConfigureSpotEventPlugin` construct, which is `true` by default.
*
* @default true
*/
readonly trackInstancesWithResourceTracker?: boolean;
Expand Down Expand Up @@ -364,11 +368,6 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
*/
public readonly fleetRole: IRole;

/**
* An id of the Worker AMI.
*/
public readonly imageId: string;

/**
* The Worker AMI.
*/
Expand Down Expand Up @@ -445,7 +444,7 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
/**
* @internal
*/
public readonly _launchTemplateConfigs: any[];
public readonly _launchTemplateConfigs: LaunchTemplateConfig[];

constructor(scope: Construct, id: string, props: SpotEventPluginFleetProps) {
super(scope, id);
Expand Down Expand Up @@ -493,7 +492,6 @@ export class SpotEventPluginFleet extends Construct implements ISpotEventPluginF
const imageConfig = props.workerMachineImage.getImage(this);
this.osType = imageConfig.osType;
this.userData = props.userData ?? imageConfig.userData;
this.imageId = imageConfig.imageId;
this.machineImage = props.workerMachineImage;

const workerConfig = new WorkerInstanceConfiguration(this, id, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
InstanceSize,
InstanceType,
SubnetType,
SecurityGroup,
Vpc,
} from '@aws-cdk/aws-ec2';
import {
Expand All @@ -31,7 +30,6 @@ import {
Duration,
Expiration,
Stack,
Tags,
} from '@aws-cdk/core';
import { X509CertificatePem } from '../../core';
import { tagFields } from '../../core/lib/runtime-info';
Expand Down Expand Up @@ -411,66 +409,6 @@ describe('ConfigureSpotEventPlugin', () => {
}),
})));
});

test('adds multiple fleet security groups to launch template', () => {
// GIVEN
const securityGroups = [
new SecurityGroup(stack, 'NewFleetSecurityGroup1', { vpc }),
new SecurityGroup(stack, 'NewFleetSecurityGroup2', { vpc }),
];
const fleet2 = new SpotEventPluginFleet(stack, 'SpotFleet2', {
vpc,
renderQueue,
deadlineGroups: ['group2'],
instanceTypes: [new InstanceType('t2.micro')],
workerMachineImage,
maxCapacity: 1,
securityGroups,
});

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

// THEN
cdkExpect(stack).to(haveResourceLike('AWS::EC2::LaunchTemplate', {
LaunchTemplateData: objectLike({
SecurityGroupIds: securityGroups.map(sg => stack.resolve(sg.securityGroupId)),
}),
}));
});

test('adds fleet tags to launch template', () => {
// GIVEN
const tag = {
key: 'mykey',
value: 'myvalue',
};
Tags.of(fleet).add(tag.key, tag.value);

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

// THEN
cdkExpect(stack).to(haveResourceLike('AWS::EC2::LaunchTemplate', {
LaunchTemplateData: objectLike({
TagSpecifications: arrayWith({
ResourceType: SpotFleetResourceType.INSTANCE.toString(),
Tags: arrayWith({
Key: tag.key,
Value: tag.value,
}),
}),
}),
}));
});
});

test('only one object allowed per render queue', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
VersionQuery,
SpotEventPluginFleet,
SpotFleetAllocationStrategy,
SpotFleetResourceType,
} from '../lib';

let app: App;
Expand Down Expand Up @@ -418,6 +419,64 @@ describe('SpotEventPluginFleet', () => {
}),
}));
});

test('adds multiple fleet security groups to launch template', () => {
// GIVEN
const securityGroups = [
new SecurityGroup(stack, 'NewFleetSecurityGroup1', { vpc }),
new SecurityGroup(stack, 'NewFleetSecurityGroup2', { vpc }),
];

// WHEN
new SpotEventPluginFleet(spotFleetStack, 'SpotFleet2', {
vpc,
renderQueue,
deadlineGroups: ['group2'],
instanceTypes: [new InstanceType('t2.micro')],
workerMachineImage,
maxCapacity: 1,
securityGroups,
});

// THEN
expectCDK(spotFleetStack).to(haveResourceLike('AWS::EC2::LaunchTemplate', {
LaunchTemplateData: objectLike({
SecurityGroupIds: securityGroups.map(sg => spotFleetStack.resolve(sg.securityGroupId)),
}),
}));
});

test('adds fleet tags to launch template', () => {
// GIVEN
const tag = {
key: 'mykey',
value: 'myvalue',
};
const fleet = new SpotEventPluginFleet(spotFleetStack, 'SpotFleet', {
vpc,
renderQueue,
instanceTypes,
deadlineGroups,
workerMachineImage,
maxCapacity,
});

// WHEN
Tags.of(fleet).add(tag.key, tag.value);

// THEN
expectCDK(spotFleetStack).to(haveResourceLike('AWS::EC2::LaunchTemplate', {
LaunchTemplateData: objectLike({
TagSpecifications: arrayWith({
ResourceType: SpotFleetResourceType.INSTANCE.toString(),
Tags: arrayWith({
Key: tag.key,
Value: tag.value,
}),
}),
}),
}));
});
});

describe('created with custom values', () => {
Expand All @@ -436,7 +495,6 @@ describe('SpotEventPluginFleet', () => {
// THEN
expect(fleet.deadlineGroups).toStrictEqual(deadlineGroups.map(group => group.toLocaleLowerCase()));
expect(fleet.instanceTypes).toBe(instanceTypes);
expect(fleet.imageId).toBe(imageConfig.imageId);
expect(fleet.osType).toBe(imageConfig.osType);
expect(fleet.maxCapacity).toBe(maxCapacity);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ describe('validateLaunchTemplateConfigs', () => {
.toThrowError(`${propertyName}[0].LaunchTemplateSpecification type is not valid.`);
});

test('throws when LaunchTemplateSpecification is invalid', () => {
test('throws when Version is invalid', () => {
// GIVEN
const invalidValue = 123;
const config: LaunchTemplateConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,7 @@ describe('SEPConfiguratorResource', () => {
mockSpotEventPluginClient.saveServerData = mockSaveServerData;

// WHEN
const promise = handler.doCreate('physicalId', {
connection: validSepConfiguration.connection,
spotFleetRequestConfigurations: validSepConfiguration.spotFleetRequestConfigurations,
});
const promise = handler.doCreate('physicalId', validSepConfiguration);

// THEN
await expect(promise)
Expand All @@ -320,10 +317,7 @@ describe('SEPConfiguratorResource', () => {
mockSpotEventPluginClient.configureSpotEventPlugin = mockConfigureSpotEventPlugin;

// WHEN
const promise = handler.doCreate('physicalId', {
connection: validSepConfiguration.connection,
spotPluginConfigurations: validSepConfiguration.spotPluginConfigurations,
});
const promise = handler.doCreate('physicalId', validSepConfiguration);

// THEN
await expect(promise)
Expand Down

0 comments on commit 5d85d5d

Please sign in to comment.