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

Remove PreBuiltImageBuilder and make it a function instead. #1986

Conversation

tejal29
Copy link
Contributor

@tejal29 tejal29 commented Apr 18, 2019

For #922, i am making changes to skaffold deploy to not run skaffold build.
--images flag is only used deploy flow.
The way it works is when --images flag is present, runner creates a
PreBuiltImageBuilder. All it does is, parses the images and converts
them to build.Artifact. If during deploy, an image in the list was also
built, then it uses the built image tag vs the tag present on the
commmand line flag.

In this change, we remove creating a PreBuiltImageBuilder in the runner.
(Remember this flag is only available for deploy and hence other command
won't get affected)
The --images will now be converted to build.Artifact in the
runner.Deploy flow.

Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-io
Copy link

codecov-io commented Apr 18, 2019

Codecov Report

Merging #1986 into master will decrease coverage by 0.16%.
The diff coverage is 28.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1986      +/-   ##
==========================================
- Coverage   55.48%   55.32%   -0.17%     
==========================================
  Files         173      173              
  Lines        7510     7505       -5     
==========================================
- Hits         4167     4152      -15     
- Misses       2952     2961       +9     
- Partials      391      392       +1
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/deploy.go 34.61% <0%> (-40.39%) ⬇️
pkg/skaffold/runner/runner.go 61.93% <0%> (-1.08%) ⬇️
pkg/skaffold/runner/prebuilt.go 81.81% <81.81%> (ø)

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 37baddd...71b52b6. Read the comment docs.

@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Apr 19, 2019
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Apr 19, 2019
@tejal29 tejal29 force-pushed the remove_pre_built_image_builder branch from 88590c6 to be6c8f6 Compare April 19, 2019 23:33
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.

The idea behind curent implementation is to remove as many branches as possible in the Runner's functions. Too many branches make it too hard to maintain. I'd like to see the bug fixed without removing the PreBuiltImageBuilder

@tejal29
Copy link
Contributor Author

tejal29 commented Apr 22, 2019

@dgageot, Keeping PreBuiltImageBuilder adds unnecessary build flow into deploy which we need to get rid off.
Other way to fix this, by introducing one more flow in the runner where if command is deploy and opts.PreBuiltImages is present, then run build or else only deploy which is add more complexity to the code.

tejal29 added 2 commits April 22, 2019 10:20
For GoogleContainerTools#922, i am making changes to `skaffold deploy` to  not run `skaffold build`.
`--images` flag is only used `deploy` flow.
The way it works is when `--images` flag is present, runner creates a
`PreBuiltImageBuilder`. All it does is, parses the images and converts
them to build.Artifact. If during deploy, an image in the list was also
built, then it uses the built image tag vs the tag present on the
commmand line flag.

In this change, we remove creating a PreBuiltImageBuilder in the runner.
(Remember this flag is only available for deploy and hence other command
won't get affected)
The `--images` will now be converted to build.Artifact in the
runner.Deploy flow.
@tejal29 tejal29 force-pushed the remove_pre_built_image_builder branch from be6c8f6 to be936d3 Compare April 22, 2019 17:21
cmd/skaffold/app/cmd/deploy.go Outdated Show resolved Hide resolved
cmd/skaffold/app/cmd/deploy.go Outdated Show resolved Hide resolved
cmd/skaffold/app/cmd/deploy.go Outdated Show resolved Hide resolved
pkg/skaffold/runner/runner.go Outdated Show resolved Hide resolved
@tejal29 tejal29 force-pushed the remove_pre_built_image_builder branch from 71b52b6 to 20e2afc Compare April 23, 2019 16:24
@balopat
Copy link
Contributor

balopat commented Apr 23, 2019

The idea behind curent implementation is to remove as many branches as possible in the Runner's functions. Too many branches make it too hard to maintain. I'd like to see the bug fixed without removing the PreBuiltImageBuilder

I agree that introducing an if statement and overriding the artifacts parameter in the Deploy method is not the nicest, it would be great to have the Build step be conditionally skipped in case we are using prebuilt images and pass in the artifacts to be deployed to the Deploy method.

This conditional branching is implemented currently by the switch statement used in the Build step. Which is - I think one of those "clever" solutions that are a bit of a surprising as

  • for skaffold deploy we are doing a build - and led to the bug of introducing a build step during a deploy-only operation.
  • we are "building prebuilt images"... which is just weird

So I think we can do better than the current design in terms of non-surpising, more maintainable code.

My suggestion would be to introduce the explicit conditional in the runner above the build step.

@tejal29 tejal29 closed this Apr 23, 2019
@tejal29 tejal29 deleted the remove_pre_built_image_builder branch September 18, 2019 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants