-
Notifications
You must be signed in to change notification settings - Fork 512
METRON-2246 rpm-docker - minimise use of bind mounts due to performance #1501
base: master
Are you sure you want to change the base?
Conversation
… input files are built into the docker iamge
I was considering this type of thing as my next step in my pr. I'll review |
Can you do a scan of the documentation and make sure that the RPM location is correctly referenced? |
That's excellent
This makes me nervous. Can you clarify this a bit more? How is this going to impact the build lifecycle for fulldev? If I do a |
@ottobackwards The new process moves away from this by:
Pushing this last step inside the running docker image allows rpmlint to process the rpms while they are still sitting on the higher-performing in-docker filesystems, rather then while the RPMS are sitting on a shared bind directory. The readme was updated to show the new location that rpms are located once the docker image has finished running as it does this "move to target directory" step rather then the maven process; |
@mmiklavc Fair question. Docker keeps track (i.e. checksums) all of the source data used to build each step of a docker image (This is called the docker context). When you rebuild a docker image, docker compares the checksums to the source data, and skips the build process if nothing in the docker context of that image has changed. The rpm-docker build process builds both docker images every times it runs. Most times the first image has no changes in its source files, so the build is skipped. The second build process (the one that embeds Metron jars) will actually skip as well if none of the Metron source jars have changed. (bonus optimisation!). But in all cases, the jars embedded in the docker image will be a 100% match with the jars that are in rpm-docker/SOURCES . This "keeping track of docker contexts" is fundamental to how the docker build process runs, and has been validated and tested by everyone who utilises docker over many years. |
@mmiklavc Documentation on the docker build caching process https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache |
@tigerquoll, for my issue, i was going to take it a step further and just do a ROOT level docker file, and copy/add . /code. Mainly because i want to do full END to END in the container:
Having gotten that far in my thinking I stopped however, because I haven't had time to think through all the restructuring it would take, given the way we have the docker stuff buried and purposed right now. Does that make sense? |
Heh @ottobackwards, |
hahah |
I have a PR up already. The idea is to have the virtual box created and up, and have the docker container run ansible with it as the target. |
It is currently conflicted, I am going to get back to it until you are done here, really. Feel free to review and comment. |
Hm, this doesn't appear to have made a difference on my machine. Am I missing something? 2nd run with the new approach Master branch for Metron |
That is a bit weird, I'll pull the branch and re-run my tests. |
Are you using a Mac for your testing? |
Here is what I am noticing with this change. If I both build the code and create the RPMs, I see times of roughly 11 - 12 minutes for RPM creation consistently. Said a different way, the first time I create the RPMs, it takes 11 -12 minutes.
Now, if I then attempt to create the RPMs again (without rebuilding the code), I do see improved times of roughly 8 - 9 minutes.
I believe that once I do a mvn clean or rebuild the code, the next time I go about creating RPMs, it takes 11-12 minutes. In master, no matter how I go about it, RPM creation takes 11 - 12 minutes. @tigerquoll Why do you think this is? Could the time savings here actually be from re-use of the phase 1 container? Does the phase 1 container get removed after a clean? I think your use of multi-stage Docker builds makes sense here, but I have not had a chance to dig-in to this enough to explain what I am seeing. |
Contributor Comments
Docker bind shared folders have a reputation as being fairly slow and inefficient on Docker for Mac. This project restructures the rpm-docker project to stop docker bind folders from being used by the RPM process for input and scratch pad use. Docker bind folders are still used for output of the constructed RPMs.
This PR restructures the rpm-docker project to use a three-stage docker build process. The first docker file is a template with the RPM building tools installed, that will be cached by docker once it is build.
The second phase of the docker build process involves constructing a new docker image based on the 1st phase docker image plus the Metron jars.
The third phase involves running the second phase docker image which will process the Metron Jars and place the packaged rpms into the appropriate folders in the project directory.
Performance improvement.
On my 2019 MBP, the following performance improvement were obtained:
Unmodified rpm-docker project:
This PR:
Test plan:
mvn package -DskipTests -T 2C -P HDP-2.5.0.0,mpack
cd metron-deployment
mvn clean package -Pbuild-rpms -T 2C
metron-deployment/packaging/docker/rpm-docker/target/RPMS
for presence of RPMS.Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
n/a Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
n/a Have you written or updated unit tests and or integration tests to verify your changes?
n/a If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
n.a Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html
:n/a Have you ensured that any documentation diagrams have been updated, along with their source files, using draw.io? See Metron Development Guidelines for instructions.
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.