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

Add heuristics to speed up Jib check in skaffold init #3120

Merged
merged 2 commits into from
Oct 25, 2019
Merged

Add heuristics to speed up Jib check in skaffold init #3120

merged 2 commits into from
Oct 25, 2019

Conversation

TadCordle
Copy link
Contributor

With this PR, skaffold first checks for Jib-related strings in the build file before attempting to run the task/goal, rather than attempting to call into Jib any time a build.gradle or pom.xml is found. This eliminates a lot of false positives and speeds up skaffold init considerably on projects that don't have Jib configured.

Here are the timings for running skaffold init --XXenableJibInit --analyze on a 2-module maven project with no Jib configurations, before and after this PR:

  • Before: 5.593s
  • After: 0.246s

Timings before and after are about the same if Jib is configured on all modules. This PR seems to save around 2-3 seconds for every module Jib is not configured.

It still may be a good idea to consider automatically applying Jib on Java projects where it isn't already configured, but in the meantime this seems like a good improvement to have.

Release Notes

Speed up Jib checks in skaffold init on Java projects.

@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #3120 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted Files Coverage Δ
pkg/skaffold/jib/jib_init.go 89.55% <100%> (+0.66%) ⬆️
pkg/skaffold/server/server.go 58.57% <0%> (ø) ⬆️

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

This is really cool. It could be worse in the status quo when artifacts are not downloaded in Maven/Gradle caches.

The only corner case I have been thinking about is the multi-module/project case, where I can imagine <artifactId>jib-maven-plugin</artifactId> is defined only in the parent project or the other way around. Will skaffold init work for both Maven and Gradle in these cases?

@TadCordle
Copy link
Contributor Author

Assuming I tested everything correctly, my findings:

Maven

  • Parent only: jib:_skaffold-init runs on the root project and lists all modules.
  • Module only: Parent pom is skipped, and jib:_skaffold-init runs on the module directly.

Gradle

  • Parent only: If jib isn't applied to the subprojects, _jibSkaffoldInit won't list them.
  • Module only: Parent is skipped and _jibSkaffoldInit runs on the module directly.

@chanseokoh
Copy link
Member

Are your findings before or after this quick check? Doesn't this PR change any behavior? I think I better talk to you offline.

@loosebazooka
Copy link
Member

loosebazooka commented Oct 24, 2019

Does this work if jib is configured further down the tree in a multimodule project? (and not at the root)

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.

4 participants