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): add custom user data commands to Worker instance startup #239

Merged
merged 1 commit into from
Nov 26, 2020

Conversation

kozlove-aws
Copy link
Contributor

@kozlove-aws kozlove-aws commented Nov 17, 2020

Problem

Users do not have possibility to run user data scripts before worker configured and run by RFDK configuration script.
Was created issue with request to add this functional: Worker nodes and UserData

Solution

Was chosen solution that allows user to create class with methods that add user data scripts in all stages of worker configuration.
Was added interface IInstanceUserDataProvider and class InstanceUserDataProvider with three methods.
Every method can be overridden by user and has possibility to modify worker user data.
Were added examples for this functionality for Python and Typescript.

Testing

Was added integration tests that cover 100% of new functionality.
Were deployed Python and Typescript examples and verified that all expected code was added to userdata and example script was copied to worker instance and run.

Was removed validation S3Bucket in version query test because these values are changed periodically.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@@ -0,0 +1 @@
mkdir test_dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Missing newline at end of file.

yarn.lock Outdated
@@ -10460,6 +10460,17 @@ ts-node@^8.0.2:
source-map-support "^0.5.17"
yn "3.1.1"

ts-node@^9.0.0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this wasn't an intended change.

@kozlove-aws kozlove-aws force-pushed the add_pre_configure_userdata branch 3 times, most recently from 3e1d81e to daf8bd6 Compare November 18, 2020 18:21
postWorkerLaunch(host: IHost): void;
}

export class InstanceUserDataProvider implements IInstanceUserDataProvider{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a docstring explaining what it's for.

Copy link
Contributor

@jusiskin jusiskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this looks good. The main request is to add an additional callback and make the base class a construct.

Comment on lines 36 to 41
// Method that is invoked before configuration Cloud Watch Agent.
preCloudWatchAgent(host: IHost): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be made into proper TSDoc strings so that they are visible in our API docs and discoverable from IDEs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm wrong here, the // syntax is just a comment and not a docstring. i.e. it doesn't end up in the API documentation.

packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
expect(userData).toContain('echo preCloudWatchAgent');
expect(userData).toContain('echo preDeadlineConfiguration');
expect(userData).toContain('echo postWorkerLaunch');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These make no guarantees that the user data are injected in the correct places. Any ideas on how we can test that here?

packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts Outdated Show resolved Hide resolved
@jusiskin
Copy link
Contributor

We haven't been great about doing this lately, but do you mind also adding documentation for this in packages/aws-rfdk/lib/deadline/README.md?

Comment on lines 36 to 41
// Method that is invoked before configuration Cloud Watch Agent.
preCloudWatchAgent(host: IHost): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missed.

@jusiskin jusiskin added the contribution/core This is a PR that came from AWS. label Nov 26, 2020
@@ -29,6 +29,39 @@ import {
Version,
} from './version';

/**
* Provider for adding user data scripts
* Methods of this class will be invoked in WorkerInstanceConfiguration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "Methods of this class"

This isn't a class... it's an interface

postWorkerLaunch(host: IHost): void;
}

export class InstanceUserDataProvider extends Construct implements IInstanceUserDataProvider{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a docstring on this class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs more documentation. This class is the API that RFDK users should use in order to achieve custom user data. In here, we should explain that users can sub-class this and override the desired methods to add custom user data commands for WorkerInstanceFleet or WorkerInstanceConfiguration.

}

/**
* This construct can be used to configure Deadline Workers on an instance to connect to a RenderQueue, stream their
* log files to CloudWatch, and configure various settings of the Deadline Worker.
*
* The configuration happens on instance start-up using user data scripting.
*
* The configuration has next steps:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "This configuration performs the following steps in order:"
?

Comment on lines 36 to 41
// Method that is invoked before configuration Cloud Watch Agent.
preCloudWatchAgent(host: IHost): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm wrong here, the // syntax is just a comment and not a docstring. i.e. it doesn't end up in the API documentation.

@kozlove-aws kozlove-aws force-pushed the add_pre_configure_userdata branch 4 times, most recently from fefa0f4 to c5aab19 Compare November 26, 2020 18:16
Copy link
Contributor

@jusiskin jusiskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better, but there are a few more things to address here - mostly around the docstrings.

packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
postWorkerLaunch(host: IHost): void;
}

export class InstanceUserDataProvider extends Construct implements IInstanceUserDataProvider{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs more documentation. This class is the API that RFDK users should use in order to achieve custom user data. In here, we should explain that users can sub-class this and override the desired methods to add custom user data commands for WorkerInstanceFleet or WorkerInstanceConfiguration.

packages/aws-rfdk/lib/deadline/lib/worker-configuration.ts Outdated Show resolved Hide resolved
@kozlove-aws kozlove-aws force-pushed the add_pre_configure_userdata branch 3 times, most recently from 95c7f0f to 882d388 Compare November 26, 2020 19:58
ddneilson
ddneilson previously approved these changes Nov 26, 2020
Copy link
Contributor

@jusiskin jusiskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice an issue in the python example that needs to be updated after some PR changes.

def pre_render_queue_configuration(self, host) -> None:
host.user_data.add_commands("echo preRenderQueueConfiguration")

def pre_deadline_configuration(self, host) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to be updated with the new hook name.

@jusiskin jusiskin changed the title fix(deadline): User Data execution on Worker Nodes feature(deadline): add custom user data commands to Worker instance startup Nov 26, 2020
@jusiskin jusiskin changed the title feature(deadline): add custom user data commands to Worker instance startup feat(deadline): add custom user data commands to Worker instance startup Nov 26, 2020
@jusiskin jusiskin merged commit bdef391 into mainline Nov 26, 2020
@jusiskin jusiskin deleted the add_pre_configure_userdata branch November 26, 2020 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants