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: add Worker pre-install commands, --start, and Job.get_logs #25

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

jericht
Copy link
Contributor

@jericht jericht commented Oct 11, 2023

Related aws-deadline/deadline-cloud-worker-agent#54

What was the problem/requirement? (What/Why)

Need more features and some fixes to add a Worker agent test for the jobRunAsUser feature

What was the solution? (How)

Major changes:

  • Add DeadlineWorkerConfiguration,pre_install_commands property that is a list of commands that run before the Worker agent installer is run
    • Usage: create a session-scoped pytest fixture that overrides the worker_config fixture from fixtures.py (see pytest docs on overriding fixtures), then return a new DeadlineWorkerConfiguration with the modified configuration
  • Add DeadlineWorkerConfiguration.start_service and pass it to the Worker agent installer so that the systemd service can be started during installation
  • Add Job.get_logs which retrieves the logs for a job

Minor changes / fixes:

  • Add raw_kwargs option to all resource methods that wrap an AWS API call (e.g. CreateJob, CreateQueue, etc.). This gives us the ability to not have to upgrade the library version in order to write tests
  • (bug) Actually pass through FARM_ID and FLEET_ID to Docker container worker so that users do not need to define those env vars when not using BYO_DEADLINE
  • (bug) properly parse the USE_DOCKER_WORKER so that setting it to something other than true will not use a Docker worker

What is the impact of this change?

  • New features to use in jobRunAsUser tests for Worker agent
  • Bugs were fixed

How was this change tested?

Was this change documented?

  • No

Is this a breaking change?

  • No

@jericht jericht changed the title feat: add Worker pre-install commands, --start, and Job.get_logs feat!: add Worker pre-install commands, --start, and Job.get_logs Oct 11, 2023
@jericht jericht force-pushed the jericht/more_fixes branch 3 times, most recently from 95e3dac to 938de80 Compare October 11, 2023 21:52
@jericht jericht changed the title feat!: add Worker pre-install commands, --start, and Job.get_logs feat: add Worker pre-install commands, --start, and Job.get_logs Oct 11, 2023
@jericht jericht force-pushed the jericht/more_fixes branch 3 times, most recently from 0029fff to 01e314a Compare October 12, 2023 00:06
Comment on lines +421 to +424
# TODO: Support multiple job users on Docker
assert (
len(self.configuration.job_users) == 1
), f"Multiple job users not supported on Docker worker: {self.configuration.job_users}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to do the Docker stuff later. It's mostly a dev convenience, and we're at a time crunch at the moment.

@jericht jericht force-pushed the jericht/more_fixes branch 2 times, most recently from 415f508 to b7f25c4 Compare October 12, 2023 17:46
@jericht jericht force-pushed the jericht/more_fixes branch from b7f25c4 to e57b537 Compare October 12, 2023 17:59
@jericht jericht marked this pull request as ready for review October 12, 2023 18:05
@jericht jericht requested a review from a team as a code owner October 12, 2023 18:05
session_log_map: dict[str, list[CloudWatchLogEvent]] = {}
for session in sessions:
session_id = session["sessionId"]
get_log_events_response = logs_client.get_log_events(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a paginated API. As written, this won't be able to fetch the full log stream if there's a lot of data in it.

Returns:
JobLogs: The job logs
"""
list_sessions_response = deadline_client.list_sessions(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a paginated API. Jobs that have a lot of tasks/steps may end up with more sessions than can be sent in a single response.

Returns:
JobLogs: The job logs
"""
list_sessions_response = deadline_client.list_sessions(
Copy link
Contributor

Choose a reason for hiding this comment

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

Canary permissions will need to be updated

session_log_map: dict[str, list[CloudWatchLogEvent]] = {}
for session in sessions:
session_id = session["sessionId"]
get_log_events_response = logs_client.get_log_events(
Copy link
Contributor

Choose a reason for hiding this comment

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

Canary permissions will need updating

Signed-off-by: Jericho Tolentino <[email protected]>
@jericht jericht force-pushed the jericht/more_fixes branch from 7706c1f to 2e3eb1c Compare October 12, 2023 20:13
@jericht jericht merged commit ddfb51c into mainline Oct 12, 2023
11 checks passed
@jericht jericht deleted the jericht/more_fixes branch October 12, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants