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

Allow re-use of Docker image (reopen #319) #341

Merged
merged 5 commits into from
Jan 2, 2019

Conversation

130s
Copy link
Member

@130s 130s commented Dec 12, 2018

What does this PR change

Re-opening #319 using the commits from the requester there.
This adds a feature to run docker commit from industrial_ci, so that the users can access the built docker image for later usage.

Review comments up to this point #319 (review) are hopefully addressed.

Maturity of the suggested feature

At the time of opening this PR, the feature is experimental. We've been actively using on our (private) repos, and I found there are still some basic issues that need to be fixed in order for this feature to be integrated into a full-automated cycle. That said, we've been able to use this feature in semi-automated situation where small manual change to the built image makes the image usable.

Instead of trying to fix all of those issues in a single initial PR, I'd suggest to move on, claiming experimental, merge, open tickets, and keep iterating.

Review items

  • @130s Locally test.
  • CI pass.
  • Review changes.

@130s
Copy link
Member Author

130s commented Dec 12, 2018

Not sure why Travis CI didn't grab this. Close-reopening.

@130s 130s closed this Dec 12, 2018
@130s 130s reopened this Dec 12, 2018
doc/index.rst Outdated Show resolved Hide resolved
Copy link
Member

@mathias-luedtke mathias-luedtke left a comment

Choose a reason for hiding this comment

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

Code is ready for merge.

.travis.yml Outdated Show resolved Hide resolved
@130s
Copy link
Member Author

130s commented Dec 23, 2018

@ipa-mdl Thank you for the review #341 (review). Hopefully updated commit addressed all comments.

Copy link
Member

@mathias-luedtke mathias-luedtke left a comment

Choose a reason for hiding this comment

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

Code and documentation are alright (just a minor glitch left).
But please update rerun_ci accordingly.

industrial_ci/src/docker.sh Outdated Show resolved Hide resolved
@130s 130s mentioned this pull request Dec 30, 2018
4 tasks
130s added a commit to 130s/industrial_ci that referenced this pull request Dec 30, 2018
Addressing https://github.com/ros-industrial/industrial_ci/pull/319/files#r220267620

[feat:commit_img] Add a section to readme.

[feat:commit_img] Remove 'COMMIT_IMAGE' variable. Add a test.

Address https://github.com/ros-industrial/industrial_ci/pull/319/files#r222089723

[feat:commit_img] Adding a test for DOCKER_COMMIT_IMAGE.

[feat:commit_img] Simplify 'docker commit' variable names. Revert change in rerun_ci (address a review commnet ros-industrial#319 (review)).

Rename the variables to clarify they are related to Docker.

Addressing https://github.com/ros-industrial/industrial_ci/pull/319/files#r220267620

expose COMMIT_IMAGE variable to user. Updates related documentation and variables.

[feat:commit_img] Remove 'COMMIT_IMAGE' variable. Add a test.

Address https://github.com/ros-industrial/industrial_ci/pull/319/files#r222089723

[feat:commit_img] Simplify 'docker commit' variable names. Revert change in rerun_ci (address a review commnet ros-industrial#319 (review)).

[doc] Remove unused, obsolete var name (address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591444)
[doc] Remove unused var (address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591088).

[feat:commit_img] Simplified test (attempting to address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591026)

[feat:commit_img] Simplify test logic (based on suggestion AustinDeric#3 (comment)).

[feat:commit_img] Removed obsolete logic (address ros-industrial#319 (comment)).

[feat:commit_img] address review comments (ros-industrial#319 (review))

[docker.sh] Indentation (ros-industrial#341 (comment)).
Addressing https://github.com/ros-industrial/industrial_ci/pull/319/files#r220267620

[feat:commit_img] Add a section to readme.

[feat:commit_img] Remove 'COMMIT_IMAGE' variable. Add a test.

Address https://github.com/ros-industrial/industrial_ci/pull/319/files#r222089723

[feat:commit_img] Adding a test for DOCKER_COMMIT_IMAGE.

[feat:commit_img] Simplify 'docker commit' variable names. Revert change in rerun_ci (address a review commnet ros-industrial#319 (review)).

Rename the variables to clarify they are related to Docker.

Addressing https://github.com/ros-industrial/industrial_ci/pull/319/files#r220267620

expose COMMIT_IMAGE variable to user. Updates related documentation and variables.

[feat:commit_img] Remove 'COMMIT_IMAGE' variable. Add a test.

Address https://github.com/ros-industrial/industrial_ci/pull/319/files#r222089723

[feat:commit_img] Simplify 'docker commit' variable names. Revert change in rerun_ci (address a review commnet ros-industrial#319 (review)).

[doc] Remove unused, obsolete var name (address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591444)
[doc] Remove unused var (address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591088).

[feat:commit_img] Simplified test (attempting to address https://github.com/ros-industrial/industrial_ci/pull/319/files#r230591026)

[feat:commit_img] Simplify test logic (based on suggestion AustinDeric#3 (comment)).

[feat:commit_img] Removed obsolete logic (address ros-industrial#319 (comment)).

[feat:commit_img] address review comments (ros-industrial#319 (review))

[docker.sh] Indentation (ros-industrial#341 (comment)).
@130s
Copy link
Member Author

130s commented Dec 30, 2018

Commit updated.

Locally I tested rerun_ci, which seems to work fine without DOCKER_COMMIT defined (i.e. I see a temporary Docker image commited), but with the arg the behavior is still the same as no arg.

$ SRCDIR=/tmp/cws_dr/src/ && mkdir -p $SRCDIR && cd $SRCDIR && git clone https://github.com/ros-drivers/openni2_camera
$ cd /tmp && git clone https://github.com/130s/industrial_ci -b feature/docker_commit
$ /tmp/industrial_ci/industrial_ci/scripts/rerun_ci . ROS_DISTRO=melodic ROS_REPO=ros-shadow-fixed
$ /tmp/industrial_ci/industrial_ci/scripts/rerun_ci . ROS_DISTRO=melodic ROS_REPO=ros-shadow-fixed DOCKER_COMMIT="test_rerun_ci" DOCKER_COMMIT_MSG="testing_rerun_msg"

$ docker images| grep -i openni2                                                                                                                                                                                                                                                                                                          
REPOSITORY                                                          TAG                                                           IMAGE ID            CREATED             SIZE
industrial-ci/rerun_ci/openni2_camera                               66d52ad29be5                                                  efa6e1eb336e        2 hours ago         1.76GB

UPDATE: Figured it out the reason why the specified image isn't committed #341 (comment). rerun_ci looks for environment variables while I only specified the command args. Will update.

@130s
Copy link
Member Author

130s commented Dec 30, 2018

Please re-review @ipa-mdl.

Copy link
Member

@mathias-luedtke mathias-luedtke left a comment

Choose a reason for hiding this comment

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

Locally I tested rerun_ci, which seems to work fine without DOCKER_COMMIT defined (i.e. I see a temporary Docker image commited), but with the arg the behavior is still the same as no arg.

Yes, this is how rerun_ci works, it commits the image and run further tests in the new images.
That's why I implemented _DOCKER_COMMIT in the first place.

_COMMIT_IMAGE_MSG="$repo_dir $*"
env_hash=($(sha256sum <<< "$_COMMIT_IMAGE_MSG"))
_COMMIT_IMAGE="industrial-ci/rerun_ci/$(basename "$repo_dir"):${env_hash:0:12}"
if [ -z $DOCKER_COMMIT_MSG ]; then DOCKER_COMMIT_MSG="$repo_dir $*"; fi
Copy link
Member

Choose a reason for hiding this comment

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

DOCKER_COMMIT_MSG and DOCKER_COMMIT should not get overwritten from the outside, they are crucial to the argument hashing.
Please remove these if clauses.

@130s
Copy link
Member Author

130s commented Dec 31, 2018

TLDR; @ipa-mdl Could you elaborate how you want us to update rerun_ci (mentioned at #341 (review))?

Locally I tested rerun_ci, which seems to work fine without DOCKER_COMMIT defined (i.e. I see a temporary Docker image commited), but with the arg the behavior is still the same as no arg.

Yes, this is how rerun_ci works, it commits the image and run further tests in the new images.
That's why I implemented _DOCKER_COMMIT in the first place.

In this PR DOCKER_COMMIT variable is exposed to users, allowing them to specify the name to save docker image with. Then I thought we'd want rerun_ci script to behave the same. When a user defines the docker image name by DOCKER_COMMIT, wouldn't rerun_ci script save the state into the given image name instead of automatically generated hash value? And if that's correct wouldn't it be ok?

@mathias-luedtke
Copy link
Member

Could you elaborate how you want us to update rerun_ci

Just remove the if clauses and overwrite DOCKER_COMMIT and DOCKER_COMMIT_MSG (as before).

then I thought we'd want rerun_ci script to behave the same. When a user defines the docker image name by DOCKER_COMMIT, wouldn't rerun_ci script save the state into the given image name instead of automatically generated hash value? And if that's correct wouldn't it be ok?

No.
rerun_ci is just a little helper to take care of DOCKER_COMMITetc.
The hashing is the main functionality. If you change the image name or the message, it does not work properly anymore.
If hashing is not needed, just use run_ci.

@130s
Copy link
Member Author

130s commented Jan 2, 2019

Just remove the if clauses and overwrite DOCKER_COMMIT and DOCKER_COMMIT_MSG (as before).

Ok.

In that case I don't see a point in updating the variable names (_COMMIT_IMAGE to DOCKER_COMMIT etc.) in rerun_ci. I've kept the change but let me know if I should revert.

Also updated the document, as I think the new feature added in this PR doesn't work for rerun (I tested it locally. Not sure if that's what's supposed to be though).

@mathias-luedtke
Copy link
Member

Thanks!

In that case I don't see a point in updating the variable names (_COMMIT_IMAGE to DOCKER_COMMIT etc.) in rerun_ci. I've kept the change but let me know if I should revert.

It is crucial to rename the variables everywhere. rerun_ci would not work anymore, it built around this feature.

Also updated the document, as I think the new feature added in this PR doesn't work for rerun (I tested it locally. Not sure if that's what's supposed to be though).

I don't see the need for an "exception", but we could add a note that rerun_ci manages these variables for its special purpose.
This PR does not add a new feature, it just exposes an exisiting feature.

I did not make it public in the first place, because the resulting images are not well-formed.
However, I see 2 legit usecases:

  1. rerun_ci
  2. speedup different [build stages](https://github.com/ros-industrial/industrial_ci/pull/286#issuecomment-395332995] (together with Add DOCKER_PULL option #283)

It could even be pushed to a registry and reused as DOCKER_IMAGE, but I would not recommend it.

doc/index.rst Outdated Show resolved Hide resolved
@130s 130s force-pushed the feature/docker_commit branch 3 times, most recently from 566c4ef to 7963ecd Compare January 2, 2019 19:42
@130s
Copy link
Member Author

130s commented Jan 2, 2019

Updated to address your comment @ipa-mdl.

It could even be pushed to a registry and reused as DOCKER_IMAGE, but I would not recommend it.

Ha, my team has been happilly doing so for a few months :P Indeed built Docker images currently need some manual update (which I'll open tickets about once this PR finishes) but overall being able to automate Docker build as part of normal CI pipeline w/o maintaining Dockerfiles etc. is very helpful for our usecase.

@mathias-luedtke
Copy link
Member

Ha, my team has been happilly doing so for a few months :P Indeed built Docker images currently need some manual update

That's great to hear :)
But I still do not recommend it to the average user on Travis CI ;)

Copy link
Member

@mathias-luedtke mathias-luedtke left a comment

Choose a reason for hiding this comment

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

👍

@mathias-luedtke mathias-luedtke merged commit 6c97518 into ros-industrial:master Jan 2, 2019
@130s 130s deleted the feature/docker_commit branch January 3, 2019 02:52
@130s 130s changed the title Add a feature to commit Docker image (reopen #319) Allow re-use of Docker image (reopen #319) Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants