-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e07787
fix: :bug: Add SELinux label to local docker volumes
sodre fb830f4
fix: :lock: Use a shared Docker volume in sagemaker.local
sodre 550f525
feat: :children_crossing: Add SAGEMAKER_LOCAL_SELINUX_ENABLED environ…
sodre 10cae85
test: :white_check_mark: Add unit tests for SELinux usecase
sodre 98ef1ef
test: :green_heart: Remove :z from volumes in unit test assertion
sodre 253cce4
fix: :bug: Remove SELinux label when parsing volumes from compose_data
sodre 41e6187
chore: :rotating_light: Fix lint errors
sodre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
from mock import patch, Mock, MagicMock | ||
|
||
import sagemaker | ||
from sagemaker.local.image import _SageMakerContainer, _aws_credentials | ||
from sagemaker.local.image import _SageMakerContainer, _Volume, _aws_credentials | ||
|
||
REGION = "us-west-2" | ||
BUCKET_NAME = "mybucket" | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Remove the |
||
assert "%s:/opt/ml/code" % "/tmp/code" in volumes | ||
assert "%s:/opt/ml/shared" % shared_folder_path in volumes | ||
|
||
|
@@ -564,9 +565,26 @@ def test_train_local_intermediate_output(get_data_source_instance, tmpdir, sagem | |
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] | ||
assert "%s:/opt/ml/output/intermediate" % intermediate_folder_path in volumes | ||
|
||
|
||
@patch("platform.system", Mock(return_value="Linux")) | ||
@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True)) | ||
def test_container_selinux_has_label(tmpdir): | ||
volume = _Volume(str(tmpdir), "/opt/ml/model") | ||
|
||
assert volume.map.endswith(":z") | ||
|
||
|
||
@patch("platform.system", Mock(return_value="Darwin")) | ||
@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True)) | ||
def test_container_has_selinux_no_label(tmpdir): | ||
volume = _Volume(str(tmpdir), "/opt/ml/model") | ||
|
||
assert not volume.map.endswith(":z") | ||
|
||
|
||
def test_container_has_gpu_support(tmpdir, sagemaker_session): | ||
instance_count = 1 | ||
image = "my-image" | ||
|
@@ -650,6 +668,7 @@ def test_serve_local_code(tmpdir, sagemaker_session): | |
assert config["services"][h]["command"] == "serve" | ||
|
||
volumes = config["services"][h]["volumes"] | ||
volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] | ||
assert "%s:/opt/ml/code" % "/tmp/code" in volumes | ||
assert ( | ||
"SAGEMAKER_SUBMIT_DIRECTORY=/opt/ml/code" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fromcompose_data