Run scripts as an administrator to configure workers
Custom fleet host configuration scripts allow you to perform administrative tasks, such as software installation, on your service-managed fleet workers. These scripts run with elevated privileges, giving you the flexibility to configure your workers for your system.
Deadline Cloud runs the script after the worker enters the STARTING
state and before
it runs any tasks.
Important
The script runs with elevated permissions, sudo
on Linux systems and
'Administrator' on Windows systems. It is your responsibility to ensure that the script
does not introduce any security issues.
When you use an admin script you are responsible for monitoring the health of your fleet.
Common uses for the script include:
-
Installing software that requires administrator access
-
Installing Docker containers
You can create and update a host configuration script using the console or using the AWS CLI.
The following scripts demonstrate:
-
The environment variables available to the script
-
That AWS credentials are working in the shell
-
That the script is running in an elevated shell
Troubleshooting host configuration scripts
When you run the host configuration script:
-
On success: The worker runs the job
-
On failure (non-zero exit code or crash):
-
The worker shuts down
The fleet automatically launches a new worker using the latest host configuration script
-
To monitor the script:
-
Open the fleet page in the Deadline Cloud console.
-
Choose View workers to open the Deadline Cloud monitor.
-
View the worker status in the monitor page.
Important notes:
-
Workers that shut down due to an error are not available in the list of workers in the monitor. Use CloudWatch Logs to view the worker logs in the following log group:
/aws/deadline/farm-
XXXXX
/fleet-YYYYY
Within that log group is a stream of
worker-
ZZZZZ
-
CloudWatch Logs retains worker logs according to your configured retention period.
Monitoring host configuration script execution
With Admin scripts to configure workers, you can take full control of a Deadline Cloud worker. You can install any software package, reconfigure operating system parameters, or mount shared file systems. With this advanced feature and Deadline Cloud's capability to scale to thousands of workers, you can now monitor when configuration scripts are executed successfully or failed. Failure causes may include script errors, flaky behavior, or other unknown situations.
We recommend the following solutions for monitoring host configuration script execution.
CloudWatch Logs monitoring
All fleet host configuration logs are streamed to the fleet's CloudWatch log group, and specifically to a worker's CloudWatch log stream. For example, /aws/deadline/farm-123456789012/fleet-777788889999
is the log group for farm 123456789012
, fleet 777788889999
.
Each worker provisions a dedicated log stream, for example worker-123456789012
. Host configuration logs include log banners such as Running Host Configuration Script and Finished running Host Configuration Script, exit code: 0. The exit code of the script is included in the finished banner and can be queried using CloudWatch tools.
CloudWatch Logs Insights
CloudWatch Logs Insights offers advanced capabilities to analyze log information. For example, the following Log Insights query parses for the host configuration exit code, sorted by time:
fields @timestamp, @message, @logStream, @log | filter @message like /Finished running Host Configuration Script/ | parse @message /exit code: (?<exit_code>\d+)/ | display @timestamp, exit_code | sort @timestamp desc
For more information about CloudWatch Logs Insights, see Analyzing log data with CloudWatch Logs Insights in the Amazon CloudWatch Logs User Guide.
Worker agent structured logging
Deadline Cloud's worker agent publishes structured JSON logs to CloudWatch. The worker agent offers a wide array of structured logs for analyzing worker health. For more information, see Deadline Cloud worker agent logging
The attributes of the structured logs are unpacked to fields in Log Insights. You can use this CloudWatch capability to count and analyze host configuration startup failures. For example, a count and bin query can be used to determine how often failures occur:
fields @timestamp, @message, @logStream, @log | sort @timestamp desc | filter message like /Worker Agent host configuration failed with exit code/ | stats count(*) by exit_code, bin(1h)
CloudWatch metric filters for metrics and alarming
You can set up CloudWatch metric filters to generate CloudWatch metrics from logs. This lets you create alarms and dashboards for monitoring host configuration script execution.
To create a metric filter
-
Open the CloudWatch console.
-
In the navigation pane, choose Logs, then Log groups.
-
Select your fleet's log group.
-
Choose Create metric filter.
-
Define your filter pattern using one of the following:
-
For success metrics:
{$.message = "*Worker Agent host configuration succeeded.*"}
-
For failure metrics:
{$.exit_code != 0 && $.message = "*Worker Agent host configuration failed with exit code*"}
-
-
Choose Next to create a metric with the following values:
-
Metric namespace: Your metric namespace (for example,
MyDeadlineFarm
) -
Metric name: Your requested metric name (for example,
host_config_failure
) -
Metric value:
1
(each instance is a count of 1) -
Default value: Leave empty
-
Unit:
Count
-
After creating metric filters, you can configure standard CloudWatch alarms to take action on elevated host configuration failure rates, or add the metrics to a CloudWatch dashboard for day-to-day operations and monitoring.
For more details, see Filter and pattern syntax in the Amazon CloudWatch Logs User Guide.