8000 `--optimized` flag and providers jar are incompatible when used with tools changing `last-modify-date` · Issue #41268 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

--optimized flag and providers jar are incompatible when used with tools changing last-modify-date #41268

Closed

Description

@davinkevin

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

dist/quarkus

Describe the bug

Hello 👋

I open this request after this request in another already closed issue. I hope I selected the area correctly.

The main issue is when we want to use and follow practices from Reproducible Builds, some are interfering with the way the kc.sh build --optimized system is working.

It's important to note our issue is mainly buildah related, managed by IronBank, but under certain circumstances, that could be reproduced with any kind of build system (docker, kaniko…).

The problem is buildah, when used with the --timestamp parameter and some provider jars, the kc.sh build --optimized generates a text file with the "now" timestamp associated to the jar (mechanism to validate if the jar has changed or not).

The main issue is after the RUN step, buildah applies this timestamp to every file of this layer.

Image

Then, we end up with an error at keycloak startup with the following error:

A provider JAR was updated since the last build, please rebuild for this to be fully utilized.

This can be reproduced with any build system, as soon as it changes date of files created after the complete build.

Version

26.2+

Regression

  • The issue is a regression

Expected behavior

We should be able to start the app if the last-modify-date is changed, because the file itself should be verified (and not only the date that represent nothing really valuable).

In another thread, we recommended to base this mechanism on something less fragile than date, like digest (CRC32, MD5, SHA…).

Actual behavior

The built container can't be executed correctly. We have the following error when we launch it:

A provider JAR was updated since the last build, please rebuild for this to be fully utilized.

How to Reproduce?

Because we use the IronBank system, I don't have (atm) a clear reproducer, but some are described in the original issue.

The main way to reproduce it is to:

  1. Build a first version of keycloak
  • ADD any 3rd party jar into ./providers/
  • RUN the kc.sh build --optimized command
  1. Build the inherited image with --timestamp 0, using buildah for example
  • COPY /opt/keycloak from image created in step 1
  • (implicitly, all files from this second image will have last-modify-date to the 1970-1-1
  1. docker run -it --rm image-from-step-2

Anything else?

Our IronBank repository is accessible if you want more context.

Activity

  1. added
    kind/bug
    on Jul 19, 2025
  2. added
    area/dist/quarkus
    on Jul 19, 2025
  3. mabartos commented on Jul 21, 2025

    @mabartos
    Member

    @shawkins Could you please check it? Thanks

  4. shawkins commented on Jul 21, 2025

    @shawkins
    Contributor

    Based upon the discussions on the other issue, we generally would want users to touch the files to a known timestamp. As shown here any manipulation of the last modified date in the inherited image to an arbitrary timestamp will be problematic.

    The workaround is to touch the provider files in the base image to 1970-1-1 prior to running build --optimized and require that timestamp 0 be used in any derived image.

    In another thread, we recommended to base this mechanism on something less fragile than date, like digest (CRC32, MD5, SHA…).

    We rejected computing a hash / digest on every start as a solution. We have lighter weight options:

    • add an option to change the timestamp check behavior - could be one of: ignore, warn, error.
    • add an option to override the expected lib timestamp

    I am more open to the first option. We also already have an KC_RUN_IN_CONTAINER env variable in our base image Dockerfile that could be used to automatically drive it - If KC_RUN_IN_CONTAINER=true, then default to ignore / warn and document that any containerized manipulation of providers with build --optimized requires creating a new image.

    Let's get more input from @keycloak/cloud-native-maintainers

    Whatever we decide to do here will influence #38894 - as we want to make sure that our behavior is as clear as possible moving forward.

  5. davinkevin commented on Jul 21, 2025

    @davinkevin
    Author

    Thank you for those details and consideration of this request 😇

  6. 5 remaining items

  7. added a commit that references this issue on Aug 18, 2025
    02cd3dd
  8. added a commit that references this issue on Aug 18, 2025
    36b3392
  9. added a commit that references this issue on Aug 18, 2025
    4a6a66a
  10. bartlomiejduda commented on Jan 30, 2026

    @bartlomiejduda

    This solution worked for me:

    // buildah
    buildah run $runtimecontainer -- find /opt/keycloak/providers -type f -exec touch -a -m --date=@1743465600 {} +

    // docker
    RUN find /opt/keycloak/providers -type f -exec touch -a -m --date=@1743465600 {} +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/dist/quarkushelp wantedkind/bugpriority/importantrelease/26.3.3release/26.4.0status/bumped-by-botteam/cloud-native

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0