-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: Add SELinux label to local docker volumes #3790
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
Conversation
16d174e
to
047e158
Compare
@knikure, this PR is ready for review |
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.
Added notes for reviewer.
src/sagemaker/local/image.py
Outdated
@@ -49,6 +49,9 @@ | |||
TRAINING_JOB_NAME_ENV_NAME = "TRAINING_JOB_NAME" | |||
S3_ENDPOINT_URL_ENV_NAME = "S3_ENDPOINT_URL" | |||
|
|||
# SELinux Enabled | |||
SELINUX_ENABLED = os.environ.get("SAGEMAKER_LOCAL_SELINUX_ENABLED", "False").lower() in ["1", "true", "yes"] |
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 used an environment variable because I could not find a pythonic way to check if the system is running SELinux. The selinux package in pypi failed on my workstation when installed inside a conda environment, so I am discarding that option.
@@ -513,6 +513,7 @@ def test_train_local_code(get_data_source_instance, tmpdir, sagemaker_session): | |||
assert config["services"][h]["image"] == image | |||
assert config["services"][h]["command"] == "train" | |||
volumes = config["services"][h]["volumes"] | |||
volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] |
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.
Remove the :z
SELinux label while reading the volume back from compose_data
@@ -349,6 +352,7 @@ def retrieve_artifacts(self, compose_data, output_data_config, job_name): | |||
# Gather the artifacts from all nodes into artifacts/model and artifacts/output | |||
for host in self.hosts: | |||
volumes = compose_data["services"][str(host)]["volumes"] | |||
volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] |
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.
Remove the :z
SELinux label while reading the volume back from compose_data
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.
/bot run all
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
/bot run all |
@knikure, I fixed the lint issues. I don't think the failed integration tests are related to the change I made. Can you trigger the CI/CD again? |
This flag can be used to turn on/off the SELinux labels for docker volumes
a129ece
to
41e6187
Compare
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.
/bot run pr, slow-tests
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Codecov Report
@@ Coverage Diff @@
## master #3790 +/- ##
==========================================
- Coverage 89.95% 89.25% -0.71%
==========================================
Files 1140 267 -873
Lines 105316 26061 -79255
==========================================
- Hits 94741 23261 -71480
+ Misses 10575 2800 -7775
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue #, if available:
Description of changes:
Add the SELinux ":z" option to the docker volume mounts. Without this setting the mounted volume is not visible inside the container. More documentation about the SELabel mount options and docker can be found in this blog-post
Testing done:
Ran sagemaker local in an SELinux enabled workstation.
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
unique_name_from_base
to create resource names in integ tests (if appropriate)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.