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

bootBuildImage runs forever when a custom image name is used and the version contains an illegal character #23115

Closed
mxab opened this issue Aug 27, 2020 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@mxab
Copy link
Contributor

mxab commented Aug 27, 2020

I noticed that when I have for example a + in the version the build fails, which is ok I guess. But when I have a + in the version and set a custom image name e.g:

// version that contains a '+'
version="1.6.0-dev.2.uncommitted+wip.foo.c75795d"

and

tasks.named("bootBuildImage") {
    imageName = "registry.example.com/example/example-app:${version}"
}

the build image job runs forever.

See this example app here:
https://github.com/mxab/spring-boot-illegal-version-custom-name-problem

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 27, 2020
@scottfrederick
Copy link
Contributor

Thanks for the example app.

I noticed that when I have for example a + in the version the build fails, which is ok I guess.

The Spring Boot Gradle plugin and the Paketo CNB builder that bootBuildImage invokes by default use the same Docker image reference validation rules, which are codified by Docker and do not allow a + in an image tag.

The bootBuildImage task should fail with an error similar to this when provided this image name:

Execution failed for task ':bootBuildImage'.
> Unable to parse image reference "demo:1.6.0-dev.2.uncommitted+wip.foo.c75795d". Image reference must be in the form '[domainHost:port/][path/]name[:tag][@digest]', with 'path' and 'name' containing only [a-z0-9][.][_][-]

If you provide the same image reference to the pack CLI, it will fail with a similar message:

ERROR: failed to build: invalid image name 'demo:1.6.0-dev.2.uncommitted+wip.foo.c75795d': could not parse reference: demo:1.6.0-dev.2.uncommitted+wip.foo.c75795d

the build image job runs forever

I was able to re-create this, but not consistently. When it does appear to hang, Gradle is repeatedly acquiring and releasing a lock on the daemon. Changing imageName from registry.example.com/example/example-app:${version} to registry.example.com/example/demo:${version} seems to eliminate the hanging. We'll keep digging on that.

@mxab
Copy link
Contributor Author

mxab commented Aug 28, 2020

Yes I saw the same acquiring/releasing lock message when I run it with --debug.

As context to the version, this was generated by the nebula release plugin, but you can turn of this +my-metadata-info... off
via:

release.sanitizeVersion=true

https://github.com/nebula-plugins/nebula-release-plugin#sanitize-versions

in case someone has the same issue

@scottfrederick scottfrederick self-assigned this Aug 29, 2020
@scottfrederick
Copy link
Contributor

I've narrowed this down to a complex regular expression that Spring Boot uses to parse an image reference to make sure it's valid before passing it off to downstream APIs. Providing an image reference registry.example.com/example/example-app:1.6.0-dev.2.uncommitted+wip.foo.c75795d to ImageReference#of(String) in a unit test will cause the matcher.matches() call to process for 20+ minutes before returning a false return value. Editing the image reference in small ways like reducing the size of the tag or replacing one of the instances of example in the path reduces the time spent in matcher.matches().

Marking this as a bug in 2.3.x but it may take some time to isolate the interaction between this input and the regular expression.

@scottfrederick scottfrederick added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 31, 2020
@scottfrederick scottfrederick added this to the 2.3.x milestone Aug 31, 2020
@SimSonic
Copy link

SimSonic commented Feb 2, 2021

I've just spent about 6 hrs looking why

gradle --no-daemon --build-cache --info bootBuildImage --imageName=$BACKEND_IMAGE

is just silently freezes.

Also found release/lock loop messages but not the problem itself.

Resolved just thanksfully to this issue!

@scottfrederick scottfrederick added the for: team-meeting An issue we'd like to discuss as a team to make progress label May 27, 2021
@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label May 28, 2021
@philwebb philwebb self-assigned this May 28, 2021
@philwebb
Copy link
Member

We discussed this again and think it's a good idea to review the regex patterns. If we can't improve them then we're going to do the work in a thread and add a timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants