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

dockerTools.pullImage: use skopeo to pull the image #29302

Merged
merged 2 commits into from Sep 17, 2017

Conversation

nlewo
Copy link
Member

@nlewo nlewo commented Sep 13, 2017

Motivation for this change

Fixes #29271

Before this patch, a VM was used to spawn docker that pulled the
VM. Now, the tool Skopeo does this job well so we can simplify our
dockerTools since we doesn't need Docker anymore:)

This also fixe the regression described in
#29271 : cntlm proxy doesn't
work in 17.09 while it worked in 17.03.

Note Skopeo doesn't produce the same output than docker pull so, we
have to update sha.

Things done

Successfully run:

nix-build ./ -A dockerTools.examples.nix && docker load -i result

And also the ubuntu:latest image.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@nlewo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @lethalman, @matejc and @0arthur to be potential reviewers.

@nlewo nlewo changed the title dockerTools.pullImage: use skopeo to pull the image [WIP] dockerTools.pullImage: use skopeo to pull the image Sep 13, 2017
@nlewo
Copy link
Member Author

nlewo commented Sep 13, 2017

cc @matejc @grahamc

@nlewo nlewo changed the title [WIP] dockerTools.pullImage: use skopeo to pull the image dockerTools.pullImage: use skopeo to pull the image Sep 13, 2017
@Mic92
Copy link
Member

Mic92 commented Sep 13, 2017

+1 for the idea in general because it is faster and better maintainable. I think there should be a release note item or hint that we broke sha256 of the previous version.

Before this patch, a VM was used to spawn docker that pulled the
VM. Now, the tool Skopeo does this job well so we can simplify our
dockerTools since we doesn't need Docker anymore:)

This also fixe the regression described in
NixOS#29271 : cntlm proxy doesn't
work in 17.09 while it worked in 17.03.

Note Skopeo doesn't produce the same output than docker pull so, we
have to update sha.
@grahamc
Copy link
Member

grahamc commented Sep 13, 2017

This looks great to me, but I haven't tested it yet.

Copy link
Member

@peti peti left a comment

Choose a reason for hiding this comment

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

I've never used docker tools, so I don't have a qualified opinion. The change looks good in principle, though.

Copy link
Member

@copumpkin copumpkin left a comment

Choose a reason for hiding this comment

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

Looks great in principle, and the VM has annoyed me in the past!

nameReplace = name: builtins.replaceStrings ["/" ":"] ["-" "-"] name;
in
# For simplicity we only support sha256.
{ imageName, imageTag ? "latest", imageId ? "${imageName}:${imageTag}"
Copy link
Member

Choose a reason for hiding this comment

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

Does "latest" really make sense as a tag to use here? I know you're just carrying it over from the previous version, but it seems like a recipe for distributing unreproducible code: I use imageTag = "latest";, set the sha256 I get, and then as long as it stays in my store, I don't think about it for a while. I push up the code to my colleagues who don't share my store, and they pull latest and get a different image. If anything I'd try to actively discourage folks from using latest. That might be a topic for a separate review though 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

I fully agree with you.
Since this PR will be backported into 17.09, maybe it would be better to minimize changes.

So I could open another PR to remove the default "latest" value and go further.
It's possible to pull image by using the image digest (immutable):
https://docs.docker.com/engine/reference/commandline/pull/#pull-an-image-by-digest-immutable-identifier
Moreover, this is supported by Skopeo. So maybe we could add a digest argument and print a warning if the user uses the tag. I'm not sure that removing the tag argument is a good idea because it's not easy to find the digest of an image (I was not able to find it on the docker hub...).

Copy link
Contributor

@purefn purefn Sep 13, 2017

Choose a reason for hiding this comment

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

Being able to pull by the image digest, previously called imageId in dockerTools, is what my team has been using. The change earlier this year repurposed imageId to what it is now, which is not nearly as useful and has prevented us from updating nixpkgs on our projects. I am in favor of changing imageId back to what it meant before the change use a VM.

Copy link
Member

Choose a reason for hiding this comment

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

@purefn is there an open issue for that? We shouldn't be breaking interfaces without providing reasonable alternatives, at least

Copy link
Contributor

Choose a reason for hiding this comment

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

@copumpkin Sadly, no. I had run into another issue with that commit, #27294, and thought when that had been fixed it fixed our only issue. I tried it and encountered more problems, but didn't get to in any further until just recently.

Copy link
Member

Choose a reason for hiding this comment

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

Can we come to a decision and get this merged and backported? My $0.02 is I think it is important to be able to pull by digest. This tooling has been largely broken forever. I'm not convinced too many people are depending on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@grahamc we depend on digests but I think we agree that this PR is better than the current state.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is not relevant to this improvement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks.
And I've open #29505 to continue the discussion :)

@domenkozar domenkozar merged commit ea6d37c into NixOS:master Sep 17, 2017
@nlewo nlewo deleted the pr/dockerpull branch September 17, 2017 19:26
@fpletz fpletz added this to the 17.09 milestone Sep 18, 2017
@globin
Copy link
Member

globin commented Sep 28, 2017

I'm reverting the skopeo stuff for now.. I generally think it's a good idea but creates too many incompatibilities right now.. sorry and I really hope you don't feel discouraged by that as you have been doing awesome work on the dockerTools! But having a clean release is a priority there.. I really hope we can improve this to make this compatible as it is definitely superior otherwise..

@Mic92
Copy link
Member

Mic92 commented Sep 28, 2017

Did you revert on master or on the release branch?

@Mic92
Copy link
Member

Mic92 commented Sep 28, 2017

Ah ok so mesos was the reason here: dabb296
I would say open a new pull request to find a way to fix this, is a good idea.

globin added a commit that referenced this pull request Sep 28, 2017
This reverts commit 01174c5.

See #29302 (comment)
for more information. This broke image format compatibility and
therefore amongst others mesos.
globin added a commit that referenced this pull request Sep 28, 2017
This reverts commit 01174c5.

See #29302 (comment)
for more information. This broke image format compatibility and
therefore amongst others mesos.

(cherry picked from commit 5c6dc71)
@nlewo
Copy link
Member Author

nlewo commented Sep 28, 2017

@globin Don't worry. I don't have any problems with these reverts! I'm waiting for some feedbacks from the Skopeo community before resubmitting improved versions of these patches.

How could I reproduce your issue with Mesos?
Or could you describe a little bit what was your issue?

@globin
Copy link
Member

globin commented Sep 28, 2017

Just running nix-build -A nixos/tests/mesos.nix should be enough now that mesos itself is fixed. I hope I'll get a bit more involved with this after the release, but don't really have time right now..

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.

dockerTools.pullImage fails to pull image when behind corporate proxy