-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support aws ecs readonly_root_filesystem #27496
base: master
Are you sure you want to change the base?
Support aws ecs readonly_root_filesystem #27496
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickLavrov thanks for sending this out! Do you think its plausible that somebody would want to vary the value of this for different code locations within their deployment? Or would it always be a single setting that you put on the run launcher / agent in the dagster.yaml? Asking because if you don't need to vary it per code location, it doesn't need to go on EcsContainerContext
python_modules/libraries/dagster-aws/dagster_aws/ecs/container_context.py
Outdated
Show resolved
Hide resolved
@gibsondan Personally I want this value to be I'm not sure how to implement that other scenario, also. I just followed the pattern of I also note all the CI tests are failing due to a docker pull error unrelated to my changes. |
…n value when False. Update pytest for both true and false scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, that's my intuition too. I think if that's the case we can simplify this a bit - removing it from the 'per-location configuration piece' and only referencing it in the run launcher instead of EcsContainerContext. That should be a strict subset of what you have now.
We'll get the CI fixed, we changed the image recently and just need to get it applied here too. Thanks for flagging that.
@@ -734,6 +741,7 @@ def _run_task_kwargs( | |||
ephemeral_storage=container_context.run_resources.get("ephemeral_storage"), | |||
volumes=container_context.volumes, | |||
mount_points=container_context.mount_points, | |||
readonly_root_filesystem=container_context.readonly_root_filesystem, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once this is just on the run launcher and not on EcsContainerContext, this can be self.readonly_root_filesystem
instead
] | ||
container_definition = task_definition["containerDefinitions"][0] | ||
|
||
# Assert that readonlyRootFilesystem is set to correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment readonlyRootFilesystem is set to correctly
contains a grammatical error. Consider revising to readonlyRootFilesystem is set correctly
.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
"readonly_root_filesystem": Field( | ||
BoolSource, | ||
is_required=False, | ||
description=( | ||
"When true, the root filesystem of the container is read-only." | ||
"See https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html" | ||
), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configuration that just goes on the run launcher config and not in the per-location config goes here instead:
dagster/python_modules/libraries/dagster-aws/dagster_aws/ecs/launcher.py
Lines 392 to 399 in ff96fcb
"task_definition_prefix": Field( | |
StringSource, | |
is_required=False, | |
default_value="run", | |
description=( | |
"A prefix that is applied to all task definitions created by the EcsRunLauncher. Defaults to 'run'." | |
), | |
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented out all instances of readonly_root_filesystem in container_context.py, moved that def to launcher.py, and changed the pytest to use:
with instance_cm(
{
"task_definition": {
"task_role_arn": "fake-task-role",
"execution_role_arn": "fake-execution-role",
},
"readonly_root_filesystem": readonly_root_filesystem,
}
Is this approach correct in general (i.e. is that the right way to have this test run?)? I think I will have to uncomment some instances of readonly_root_filesystem in container_context.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks right to me!
Hi @NickLavrov , thanks for this. I once explored implementing this for Dagster+ and I encountered pitfalls that I am not sure you'll also experience in a OSS context. There are, depending on logging setup or other configuration, files that may be written to the volume, not to mention what the actual user code does. To get the full value out of this change, you may have other hurdles to jump through, such as defining and mounting writable volumes to receive these files. That being said, if that bit works correctly, then the rest can be incremental change. |
Summary & Motivation
When unset,
readonlyRootFilesystem
is false on ECS tasks, which then violates this Security Hub controlHow I Tested These Changes
Not sure how to test ECS launching. I added an assertion to the existing pytest that this defaults to
None
, and added a new pytest that verifies a setting oftrue
carries through to the task definition.Changelog