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

Failing UP-TO-DATE checks for jib-gradle-plugin #4250

Closed
JoarSvartholm opened this issue May 17, 2024 · 2 comments
Closed

Failing UP-TO-DATE checks for jib-gradle-plugin #4250

JoarSvartholm opened this issue May 17, 2024 · 2 comments

Comments

@JoarSvartholm
Copy link

Environment:

  • Jib version: 3.4.2
  • Build tool: jib-gradle-plugin
  • OS: all

Description of the issue:
Gradles build cache seem to be unsupported causing the build to always create a new image, even if no sources are changed.
This can be seen in the logs when running gradlew jibDockerBuild --info

> Task :jibDockerBuild
Caching disabled for task ':jibDockerBuild' because:
  Caching has not been enabled for the task
Task ':jibDockerBuild' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Expected behavior:
Running the same command twice should not create a new image the second time
Eg, this should be in the logs:

> Task :jibDockerBuild UP-TO-DATE

Steps to reproduce:

  1. Configure jib-gradle-plugin to produce an image
  2. run a jib task (eg jibDockerBuild)
  3. Run the same task again

Log output:

> Task :jibDockerBuild
Caching disabled for task ':jibDockerBuild' because:
  Caching has not been enabled for the task
Task ':jibDockerBuild' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Additional Information:
Up-to-date checks in gradle are typically done by specifying a field on the task marked with one of the @Output annotations, see this page: https://docs.gradle.org/current/userguide/implementing_custom_tasks.html#sec:task_groups

It looks like the following properties should be marked as outputs:

  • jib-image.digest
  • jib-image.id
  • jib-image.json
  • (Maybe: jib-cache)
@chanseokoh
Copy link
Member

chanseokoh commented May 17, 2024

This is intentional, because the purpose of jibDockerBuild is to push an image to a Docker engine. Suppose that your Docker daemon doesn't have an image yet, while there exist jib-image.digest, etc. (which can be created by other tasks) whose presence makes Gradle skip jibDockerBuild. Then you'll have to clean them to be able to push an image to your Docker daemon. (Worse, there is no way to check whether the exact same image already exists in a Docker engine, which is the limitation of the Docker Engine API. Even if it were possible, jibDockerBuild would have to run every time to do the check anyway.)

But at least Jib caches all the necessary assets including image layers, so subsequent jibDockerBuild runs don't rebuild assets already built and are fast. It's just that it has to push an image to Docker every time (which could have been even faster if the Docker Engine API had better support).

@JoarSvartholm
Copy link
Author

JoarSvartholm commented May 20, 2024

This is intentional, because the purpose of jibDockerBuild is to push an image to a Docker engine. Suppose that your Docker daemon doesn't have an image yet, while there exist jib-image.digest, etc. (which can be created by other tasks) whose presence makes Gradle skip jibDockerBuild. Then you'll have to clean them to be able to push an image to your Docker daemon. (Worse, there is no way to check whether the exact same image already exists in a Docker engine, which is the limitation of the Docker Engine API. Even if it were possible, jibDockerBuild would have to run every time to do the check anyway.)

But at least Jib caches all the necessary assets including image layers, so subsequent jibDockerBuild runs don't rebuild assets already built and are fast. It's just that it has to push an image to Docker every time (which could have been even faster if the Docker Engine API had better support).

Ah I see, that actually makes sense. Unless theres a way for gradle to do the up-to-date check towards the docker engine (like checking with docker inspect <image>), it has to be kept like this. Thanks for the well-explained reply 👍

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

No branches or pull requests

2 participants