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

[build] Add safety report to docker image #1186

Merged
merged 96 commits into from
Sep 26, 2021

Conversation

tejaschumbalkar
Copy link
Contributor

@tejaschumbalkar tejaschumbalkar commented Jun 25, 2021

Issue #, if available:

PR Checklist

  • I've prepended PR tag with frameworks/job this applies to : [mxnet, tensorflow, pytorch] | [ei/neuron] | [build] | [test] | [benchmark] | [ec2, ecs, eks, sagemaker]
  • (If applicable) I've documented below the DLC image/dockerfile this relates to
  • (If applicable) I've documented below the tests I've run on the DLC image
  • (If applicable) I've reviewed the licenses of updated and new binaries and their dependencies to make sure all licenses are on the Apache Software Foundation Third Party License Policy Category A or Category B license list. See https://www.apache.org/legal/resolved.html.
  • (If applicable) I've scanned the updated and new binaries to make sure they do not have vulnerabilities associated with them.

Pytest Marker Checklist

  • (If applicable) I have added the marker @pytest.mark.model("<model-type>") to the new tests which I have added, to specify the Deep Learning model that is used in the test (use "N/A" if the test doesn't use a model)
  • (If applicable) I have added the marker @pytest.mark.integration("<feature-being-tested>") to the new tests which I have added, to specify the feature that will be tested
  • (If applicable) I have added the marker @pytest.mark.multinode(<integer-num-nodes>) to the new tests which I have added, to specify the number of nodes used on a multi-node test
  • (If applicable) I have added the marker @pytest.mark.processor(<"cpu"/"gpu"/"eia"/"neuron">) to the new tests which I have added, if a test is specifically applicable to only one processor type

EIA/NEURON Checklist

  • When creating a PR:
  • I've modified src/config/build_config.py in my PR branch by setting ENABLE_EI_MODE = True or ENABLE_NEURON_MODE = True
  • When PR is reviewed and ready to be merged:
  • I've reverted the code change on the config file mentioned above

Benchmark Checklist

  • When creating a PR:
  • I've modified src/config/test_config.py in my PR branch by setting ENABLE_BENCHMARK_DEV_MODE = True
  • When PR is reviewed and ready to be merged:
  • I've reverted the code change on the config file mentioned above

Reviewer Checklist

  • For reviewer, before merging, please cross-check:
  • I've verified the code change on the config file mentioned above has already been reverted

Description:

  • This functionality will add the safety report as a part of the docker image.
  • Safety check will run on the image during build time and the safety report will be embedded into the image itself.
  • For any kind of image, it first builds the original image, then builds its common stage image and then pushes the common stage image to the repo. For eg., it first builds Standard images, then common stage images for Standard images and then pushes these common stage images to the repo. Thereafter it start processing the Example images and does the same for those as well.
  • During the sanity test, the tests will check if the safety report has been embedded or not and check if all the packages have passed the safety check.
  • In case any of the packages have failed the safety check, the sanity tests would fail.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

assert (safety_check.run_safety_check_with_ignore_list(docker_exec_cmd, ignore_str) == 0), \
f"Safety test failed for {image}"
else:
LOGGER.info(f"Safety check is complete as a part of docker build and report exist at {SAFETY_FILE}")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo - exists

saimidu
saimidu previously approved these changes Sep 23, 2021
src/image.py Outdated
Comment on lines 88 to 89
if self.to_push:
raise ValueError("Corresponding common stage image can only exist if the image is non-pushable")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can this only exist if the image is non-pushable?

Copy link
Contributor

@shantanutrip shantanutrip Sep 24, 2021

Choose a reason for hiding this comment

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

Changed as per conversation.

"38452":"for shipping pillow<=6.2.2 - the last available version for py2",
"35015":"for shipping pycrypto<=2.6.1 - the last available version for py2"
},
"py3": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this contain the python minor version as well? What happens when a DLC has 2 python version support?

Copy link
Contributor

Choose a reason for hiding this comment

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

Synced up

THREADS = {}
# Standard images must be built before example images
# Example images will use standard images as base
# Common images must be built at the end as they will consume respective standard and example images
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be reworded

Copy link
Contributor

Choose a reason for hiding this comment

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

Synced up

standard_images = [image for image in PRE_PUSH_STAGE_IMAGES if "example" not in image.name.lower()]
example_images = [image for image in PRE_PUSH_STAGE_IMAGES if "example" in image.name.lower()]
ALL_IMAGES = PRE_PUSH_STAGE_IMAGES + COMMON_STAGE_IMAGES
IMAGES_TO_PUSH = [image for image in ALL_IMAGES if image.to_push and image.to_build]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can the IMAGES_TO_PUSH be COMMON_STAGE_IMAGES ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Synced up

Copy link
Contributor

@saimidu saimidu left a comment

Choose a reason for hiding this comment

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

Approved.

LOGGER.info(f"Completed Push for {self.name}")
return self.build_status

def push_image_with_additional_tags(self):
Copy link
Contributor Author

@tejaschumbalkar tejaschumbalkar Sep 25, 2021

Choose a reason for hiding this comment

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

Why do we need at separate function to push a additional tag? Why cant be this done in push_image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that we need to tag the docker image first and push to ECR later.

pushed and pushes them accordingly.

Note that the common stage images should always be built after the pre-push images of a
particular kind. This is because the Common stage images use are built on respctive
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: respctive spell

@tejaschumbalkar
Copy link
Contributor Author

Changes looks good. The ECR images are tagged as expected. Let's comment the safety functionality as discussed.

@tejaschumbalkar
Copy link
Contributor Author

Soft Approved!

@tejaschumbalkar
Copy link
Contributor Author

PR is good to merge. Thanks for adding the functionality to our build system @shantanutrip !

@shantanutrip shantanutrip merged commit 954f91e into aws:master Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size:XL Determines the size of the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants