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

Try to import docker images before falling back to building #3891

Merged
merged 3 commits into from
Sep 14, 2020

Conversation

arlyon
Copy link
Contributor

@arlyon arlyon commented Mar 31, 2020

Fixes: #3886

Description

When perfoming a lookup of artifacts, this change will attempt to import artifacts from docker running locally as well as whatever remote registry is configured. This enables the worklow outlined in the issue above.

This PR is not done because there needs to be some discussion as it changes the behaviour of builds. Should the functionality be placed behind a flag? Since the contents of images aren't verified, this could for example cause problems if a malicious (or unaware) user uploads images tagged with an incorrect commit however for those who are aware of the (imo limited) drawbacks the productivity boost far-outweighs the risk. That said, I would argue to make it opt-in.

User facing changes

This would cause anyone running skaffold build to have the images be imported from docker, if possible, 'short circuiting' some builds. This is particularly useful when sharing images across teams (say someone needs to check out your branch to help diagnose an issue).

Follow-up work

Once the questions above are answered, then the PR needs to be adapted slightly and the docs updated.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@arlyon
Copy link
Contributor Author

arlyon commented Mar 31, 2020

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@tstromberg tstromberg added !! wip !! triage/discuss Items for discussion labels Apr 20, 2020
@dgageot dgageot marked this pull request as draft April 21, 2020 08:24
@dgageot dgageot changed the title WIP: Try to import docker images before falling back to building Try to import docker images before falling back to building Apr 21, 2020
@dgageot dgageot removed the !! wip !! label Apr 21, 2020
@arlyon
Copy link
Contributor Author

arlyon commented Apr 27, 2020

@tstromberg Just fixed the failing test and added the debug log!

@arlyon arlyon force-pushed the docker-import branch 2 times, most recently from 6871453 to 8cc15a8 Compare April 27, 2020 14:30
@dgageot
Copy link
Contributor

dgageot commented Apr 27, 2020

@arlyon I think it's best to make it opt-in or to make it possible to get the current behaviour back. I've always found it super important in a fully local mode to be able to never connect to a remote registry. For example, you are in a train, with no network, assuming all the layers where already downloaded, you are able to iterate quickly without reaching out to the network.

@arlyon arlyon force-pushed the docker-import branch 2 times, most recently from 9fc4706 to 77bf521 Compare April 27, 2020 17:10
@arlyon
Copy link
Contributor Author

arlyon commented Apr 27, 2020

@arlyon I think it's best to make it opt-in or to make it possible to get the current behaviour back. I've always found it super important in a fully local mode to be able to never connect to a remote registry. For example, you are in a train, with no network, assuming all the layers where already downloaded, you are able to iterate quickly without reaching out to the network.

You're right. For now I implemented it as a config option under local builds. Notice that this either imports or doesn't (it doesn't distinguish between only importing from local docker daemon and a remote registry)

build:
  artifacts:
  - image: arlyon/workout-server
    context: ./server/
  - image: arlyon/workout-learn
    context: ./learn/
  local:
    tryImportMissing: true
    push: true

Input welcome!

@briandealwis briandealwis removed the triage/discuss Items for discussion label Apr 27, 2020
@@ -191,6 +191,10 @@ type LocalBuild struct {
// connects to a remote cluster.
Push *bool `yaml:"push,omitempty"`

// TryImportMissing should attempt to import this artifact from
// Docker (either locally or a remote registry) if not in cache.
TryImportMissing bool `yaml:"tryImportMissing,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please make this a pointer like other?
And then you would need to set to it false in defaultToLocalBuild in pkg/skaffold/schemadefaults/

@tejal29 tejal29 self-assigned this May 18, 2020
@tejal29
Copy link
Contributor

tejal29 commented Jun 8, 2020

@arlyon are you still working on this?

@nkubala
Copy link
Contributor

nkubala commented Jun 22, 2020

@arlyon this PR is getting a bit stale but I'd love to help you get it in. let me know if you need any help with it! i'm still seeing a test failing on a data race in the cache somewhere, can you check that out?

@arlyon
Copy link
Contributor Author

arlyon commented Jun 25, 2020

Hey, haven't been using skaffold at my day job recently but I have some time today so I'll rebase and see if I can get the requested changes in today.

@codecov
Copy link

codecov bot commented Jun 25, 2020

Codecov Report

Merging #3891 into master will increase coverage by 0.00%.
The diff coverage is 77.27%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3891   +/-   ##
=======================================
  Coverage   73.81%   73.82%           
=======================================
  Files         347      347           
  Lines       13758    13799   +41     
=======================================
+ Hits        10156    10187   +31     
- Misses       2970     2977    +7     
- Partials      632      635    +3     
Impacted Files Coverage Δ
pkg/skaffold/build/cache/details.go 13.79% <0.00%> (-1.03%) ⬇️
pkg/skaffold/schema/latest/config.go 100.00% <ø> (ø)
pkg/skaffold/build/cache/lookup.go 88.73% <71.42%> (-11.27%) ⬇️
pkg/skaffold/build/cache/cache.go 57.77% <100.00%> (+0.95%) ⬆️
pkg/skaffold/build/cache/retrieve.go 70.65% <100.00%> (+1.33%) ⬆️
pkg/skaffold/build/local/types.go 88.23% <100.00%> (+1.56%) ⬆️
pkg/skaffold/runner/new.go 68.18% <100.00%> (+0.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cd560b...21de9ea. Read the comment docs.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jun 25, 2020
@arlyon
Copy link
Contributor Author

arlyon commented Jun 25, 2020

I have updated with the requested changes and fixed the potential data race issues by introducing a RWMutex. make test fails complaining that schema v2beta5 is already released but I'm not sure what to do about that. There seems to be a PR to address it already. Do I base on top of that?

@gsquared94
Copy link
Contributor

You can rebase on master now. A new schema version has already been created. That should help with the tests

@arlyon arlyon force-pushed the docker-import branch 2 times, most recently from f8a0707 to 8757b78 Compare July 12, 2020 16:25
@arlyon arlyon marked this pull request as ready for review July 13, 2020 08:42
@arlyon arlyon requested a review from a team as a code owner July 13, 2020 08:42
@gsquared94 gsquared94 added the kokoro:force-run forces a kokoro re-run on a PR label Jul 21, 2020
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Jul 21, 2020
@arlyon
Copy link
Contributor Author

arlyon commented Jul 24, 2020

Hate to ping because I know you're all busy but would appreciate a merge @gsquared94 @tejal29 :)

@dgageot
Copy link
Contributor

dgageot commented Jul 24, 2020 via email

Copy link
Contributor

@dgageot dgageot left a comment

Choose a reason for hiding this comment

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

Here's a first round of review

pkg/skaffold/build/local/types.go Outdated Show resolved Hide resolved
pkg/skaffold/build/cache/lookup.go Outdated Show resolved Hide resolved
pkg/skaffold/build/cache/cache.go Outdated Show resolved Hide resolved
pkg/skaffold/build/cache/details.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/types.go Outdated Show resolved Hide resolved
@nkubala
Copy link
Contributor

nkubala commented Sep 9, 2020

@arlyon this PR is getting a bit stale. do you still have the bandwidth to try and push it through?

@arlyon
Copy link
Contributor Author

arlyon commented Sep 10, 2020

Hi @nkubala sorry for the delay I though I'd pushed the requested changes but clearly not. I have rebased on master now!

Copy link
Contributor

@MarlonGamez MarlonGamez left a comment

Choose a reason for hiding this comment

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

@arlyon This looks good to me! Thanks for making all of the requested changes :)

@MarlonGamez MarlonGamez merged commit 10275c6 into GoogleContainerTools:master Sep 14, 2020
@arlyon arlyon deleted the docker-import branch September 15, 2020 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants