Skip to content

Reset API intents on every dev cycle to avoid queueing #5636

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

Merged
merged 2 commits into from
Apr 7, 2021

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Apr 6, 2021

Related: #5551
Merge after: #5553

Description

Before this change, sending an execution intent to the Control API would queue up that intent, meaning that the next time Skaffold was able to execute on it it would, even if that ability came well after the intent was issued by the user. Now, we will stop queueing these intents and only process them ephemerally, meaning that they either trigger the associated action if it's eligible in the dev loop, or they are discarded.

Before:

$ skaffold dev --rpc-http-port=1234 --auto-build=false
    # normal build and deploy happens
$ curl http://localhost:12345/v1/execute -X POST -d '{"build": true}'
    # nothing happens, because no build files have changed

    # then, user changes an artifact source file, and.....
Generating tags...
 - skaffold-example -> skaffold-example:v1.19.0-99-ga976e5249-dirty
INFO[0082] Tags generated in 46.804306ms                
Checking cache...
 - skaffold-example: Not found. Building
INFO[0082] Cache check completed in 2.282136ms          
Starting build...

After:

$ skaffold dev --rpc-http-port=1234 --auto-build=false
    # normal build and deploy happens
$ curl http://localhost:12345/v1/execute -X POST -d '{"build": true}'
   # nothing happens, because no build files have changed
   
   # then, user changes an artifact source file, and.....

   # nothing happens again, because the intent has been discarded
$ curl http://localhost:12345/v1/execute -X POST -d '{"build": true}'
Generating tags...
 - skaffold-example -> skaffold-example:v1.19.0-99-ga976e5249-dirty
INFO[0082] Tags generated in 46.804306ms                
Checking cache...
 - skaffold-example: Not found. Building
INFO[0082] Cache check completed in 2.282136ms          
Starting build...

@nkubala nkubala requested a review from a team as a code owner April 6, 2021 21:22
@google-cla google-cla bot added the cla: yes label Apr 6, 2021
@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #5636 (bb1d7bc) into master (9edaca4) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5636      +/-   ##
==========================================
- Coverage   70.83%   70.68%   -0.16%     
==========================================
  Files         404      408       +4     
  Lines       15243    15588     +345     
==========================================
+ Hits        10798    11019     +221     
- Misses       3647     3758     +111     
- Partials      798      811      +13     
Impacted Files Coverage Δ
pkg/skaffold/runner/dev.go 73.00% <100.00%> (-0.78%) ⬇️
pkg/skaffold/runner/intent.go 76.92% <100.00%> (+2.45%) ⬆️
cmd/skaffold/app/cmd/run.go 71.42% <0.00%> (-16.08%) ⬇️
pkg/skaffold/server/server.go 41.96% <0.00%> (-1.61%) ⬇️
pkg/skaffold/runner/new.go 62.56% <0.00%> (-0.57%) ⬇️
pkg/skaffold/diagnose/diagnose.go 14.70% <0.00%> (-0.45%) ⬇️
pkg/skaffold/runner/runner.go 0.00% <0.00%> (ø)
pkg/skaffold/build/docker/types.go 100.00% <0.00%> (ø)
pkg/skaffold/build/cluster/types.go 100.00% <0.00%> (ø)
... and 9 more

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 9edaca4...bb1d7bc. Read the comment docs.

@@ -39,6 +39,14 @@ func newIntents(autoBuild, autoSync, autoDeploy bool) *intents {
return i
}

func (i *intents) Reset() {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about reset since all the other methods are also unexported and the only use is in the current package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

if r.changeSet.needsReload {
return ErrorConfigurationChanged
}

buildIntent, syncIntent, deployIntent := r.intents.GetIntents()
logrus.Tracef("dev intents: build %t, sync %t, deploy %t\n", buildIntent, syncIntent, deployIntent)
Copy link
Contributor

@gsquared94 gsquared94 Apr 6, 2021

Choose a reason for hiding this comment

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

should we notify the user either in the API response (but that'd require making it synchronous) or a string output that we're skipping this request since nothing has changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would require a bit more plumbing, since in the runner we're just asking whether the intent's gate is open, not whether the user requested to open it. i think this would be a good improvement, but it should probably happen outside the scope of this PR.

Copy link
Contributor

@gsquared94 gsquared94 left a comment

Choose a reason for hiding this comment

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

lgtm!

@nkubala nkubala merged commit 70a7485 into GoogleContainerTools:master Apr 7, 2021
@nkubala nkubala deleted the reset-intents branch April 7, 2021 22:32
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.

2 participants