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

Improve Maven/Jib multimodule builds between Minikube and remote clusters #2122

Merged
merged 26 commits into from
Jul 24, 2019

Conversation

briandealwis
Copy link
Member

@briandealwis briandealwis commented May 14, 2019

Fixes #1876

Jib for Maven 1.3.0 1.4.0 will allow restricting Jib's image-building goals to a specific artifact. This ability means there is no additional package-binding step required for Skaffold-JibMaven projects. Maven/Jib multi-module project will need updating, and these changes are not compatible with previous versions of Jib.

This PR reworks the Jib support to:

  • check for a minimum Jib version (1.3.0 1.4.0)
  • remove the previous package-goal checks
  • add documentation

Projects using older versions of Jib will be prompted to update to Jib 1.3.0 1.4.0. For versions prior to 1.4.0, the build will fail due to a new goal introduced to check the required version:

$ skaffold dev
FATA[0002] watching files for artifact gcr.io/k8s-skaffold/skaffold-jib: listing files: listing files: getting jibMaven dependencies: initial Jib dependency refresh failed: failed to get Jib dependencies: Running [/Users/bsd/Projects/GPE/repo-skaffold/integration/testdata/jib/mvnw jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=[1.4.0,) -Djib.maven-plugin-version=1.3.0 --non-recursive jib:_skaffold-files-v2 --quiet]: stdout [ERROR] Could not find goal '_skaffold-fail-if-jib-out-of-date' in plugin com.google.cloud.tools:jib-maven-plugin:1.3.0 among available goals _skaffold-files, _skaffold-files-v2, _skaffold-init, _skaffold-package-goals, build, buildTar, dockerBuild -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
, stderr: , err: exit status 1: exit status 1 

For later versions of Jib, when we bump this required version, they will see failures like:

FATA[0002] watching files for artifact gcr.io/k8s-skaffold/skaffold-jib: listing files: listing files: getting jibMaven dependencies: initial Jib dependency refresh failed: failed to get Jib dependencies: Running [/Users/bsd/Projects/GPE/repo-skaffold/integration/testdata/jib/mvnw jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=(1.4.0,) -q --non-recursive jib:_skaffold-files-v2 --quiet]: stdout [ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.4.0:_skaffold-fail-if-jib-out-of-date (default-cli) on project hello-spring-boot: Jib plugin version is 1.4.0 but is required to be (1.4.0,) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
, stderr: , err: exit status 1: exit status 1 

Technically, only Maven multi-module projects require updating to 1.4.0, but for simplicity we're bumping the required version for Gradle too. If a user is willing to switch to a newer version of Skaffold, switching to a newer Jib should not present a problem either.

@briandealwis
Copy link
Member Author

PR will break since 1.3.0 is not released.

@briandealwis
Copy link
Member Author

To test: I bumped the jib-maven-plugin version to 1.3.0-SNAPSHOT and installed locally.

CHANGELOG.md Outdated Show resolved Hide resolved
examples/jib-multimodule/pom.xml Outdated Show resolved Hide resolved
@tejal29
Copy link
Member

tejal29 commented May 16, 2019

The integration test is still failing
--- FAIL: TestRun/jib_in_googlecloudbuild (9.30s) run_test.go:124: skaffold run: exit status 1, Generating tags... - gcr.io/k8s-skaffold/skaffold-jib -> gcr.io/k8s-skaffold/skaffold-jib:v0.29.0-11-gd116eff Tags generated in 18.462803ms Starting build... Building [gcr.io/k8s-skaffold/skaffold-jib]...
Not sure if this is regarding the jib version. Don't see "requires Jib v%s+", minJibVersion". But again, it could be we are not collecting the output correctly.

Thanks
Tejal

@briandealwis
Copy link
Member Author

Thanks for taking a look @tejal29 but the tests won't work until we release Jib 1.3.0. I'll update this PR when that happens.

- move example changes to integration/examples
- adopt new testutil changes in changes
@briandealwis briandealwis marked this pull request as ready for review June 10, 2019 18:24
@briandealwis
Copy link
Member Author

Jib 1.3.0 has been released and this is now ready for review.
PTAL @GoogleContainerTools/java-tools-build

pkg/skaffold/jib/jib_maven_test.go Outdated Show resolved Hide resolved
{"1.2.0", true},
{"1.2.0-SNAPSHOT", true},
{"1.3.0", false},
{"1.3.0-SNAPSHOT", false},
Copy link
Member

Choose a reason for hiding this comment

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

will it work with our potential RCs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm no. Will fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

chanseokoh
chanseokoh previously approved these changes Jun 11, 2019
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -9,6 +9,7 @@

<properties>
<java.version>1.8</java.version>
<jib.maven-plugin-version>1.3.0</jib.maven-plugin-version>
Copy link
Member

Choose a reason for hiding this comment

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

should this (and other instances of this) be defined in a parent?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh jeepers where would we define it?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know. Maybe don't do this. Just wondering.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be worth doing in the integration tests but the examples should be standalone. I'll leave it for now: these values were hard-coded previously and making them properties makes testing easier.

Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

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

Looks fine to me, should we have a go person go over it?

But also, maybe we should do a jib team experiment on a local build of this. Testing out all scenarios since we expect some breakages for existing users?

@briandealwis briandealwis added the kokoro:run runs the kokoro jobs on a PR label Jun 13, 2019
@briandealwis briandealwis removed the !! blocked !! this issue/PR is blocked by another issue label Jul 18, 2019
@briandealwis
Copy link
Member Author

Jib 1.4.0 has been released with the new requiredVersion functionality. I added a test to verify that a build will fail when the Jib version is too old. PTAL.

CHANGELOG.md Outdated Show resolved Hide resolved
@chanseokoh
Copy link
Member

Do you think the Kokoro failure is related?

     --- FAIL: TestRun/jib_in_googlecloudbuild (9.12s)
        run_test.go:130: skaffold run: exit status 1, Generating tags...
             - gcr.io/k8s-skaffold/skaffold-jib -> gcr.io/k8s-skaffold/skaffold-jib:v0.33.0-151-gde5bc34
            Tags generated in 21.036902ms
            Starting build...
            Building [gcr.io/k8s-skaffold/skaffold-jib]...

@briandealwis
Copy link
Member Author

I wouldn't have thought so, but that test output is not helpful :-(

docs/content/en/docs/how-tos/builders/_index.md Outdated Show resolved Hide resolved
docs/content/en/docs/how-tos/builders/_index.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
integration/testdata/jib/skaffold.yaml Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib_maven_test.go Show resolved Hide resolved
pkg/skaffold/jib/jib.go Outdated Show resolved Hide resolved
@@ -27,6 +27,9 @@ import (
"github.com/sirupsen/logrus"
)

// Skaffold-Jib depends on functionality introduced after Jib-Gradle 1.4.0
const MinimumJibGradleVersion = "(1.4.0,)"
Copy link
Member

Choose a reason for hiding this comment

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

Huh, shouldn't this be [1.4.0,) (i.e., includes 1.4.0)? But tests are not failing??

pkg/skaffold/jib/jib_gradle_test.go Outdated Show resolved Hide resolved
@@ -26,6 +26,9 @@ import (
"github.com/sirupsen/logrus"
)

// Skaffold-Jib depends on functionality introduced after Jib-Maven 1.4.0
const MinimumJibMavenVersion = "(1.4.0,)"
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@briandealwis
Copy link
Member Author

Thanks for the details look @chanseokoh — you caught a bunch of things. The GCB failure is related: the version range should be left-closed (:blush:).

@briandealwis
Copy link
Member Author

PTAL @balopat @dgageot

integration/build_test.go Outdated Show resolved Hide resolved
integration/build_test.go Outdated Show resolved Hide resolved
integration/build_test.go Show resolved Hide resolved
t.Skip("skipping test that is not gcp only")
}

err := skaffold.Build(test.args...).WithConfig(test.filename).InDir(test.dir).Run(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think .RunOrFail does that

Copy link
Member Author

Choose a reason for hiding this comment

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

RunOrFail fails the test on error, whereas the error is a sign of success here.

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 updated this test to check for expected error text as it would spuriously pass if (say) the wrong skaffold version was picked up ("Your Skaffold version might be too old").

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, right!

pkg/skaffold/jib/jib_test.go Outdated Show resolved Hide resolved
integration/build_test.go Show resolved Hide resolved
@dgageot dgageot merged commit 7013ed2 into GoogleContainerTools:master Jul 24, 2019
@briandealwis briandealwis deleted the i1876-jibmm branch November 11, 2019 20:24
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.

Maven multimodule projects should not require pom changes to switch between minikube and a remote cluster
7 participants