Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-23021

Inline Dockerbuild type doesn't preserve file modified timestamp

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Normal Normal
    • 4.13.z
    • 4.12.z
    • Build
    • None
    • No
    • Rejected
    • False
    • Hide

      None

      Show
      None
    • Hide
      Previously, the copy command was missing the `-p` flag option. Now the command supports the `-p` flag so that the command preserves timestamps. (link:https://issues.redhat.com/browse/OCPBUGS-23021[*OCPBUGS-23021*])
      Show
      Previously, the copy command was missing the `-p` flag option. Now the command supports the `-p` flag so that the command preserves timestamps. (link: https://issues.redhat.com/browse/OCPBUGS-23021 [* OCPBUGS-23021 *])
    • Bug Fix
    • Done

      This is a clone of issue OCPBUGS-23006. The following is the description of the original issue:

      This is a clone of issue OCPBUGS-22497. The following is the description of the original issue:

      While trying to develop a demo for a Java application, that first builds using the source-to-image strategy and then uses the resulting image to copy artefacts from the s2i-builder+compiled sources-image to a slimmer runtime image using an inline Dockerfile build strategy on OpenShift, the deployment then fails since the inline Dockerfile hooks doesn't preserve the modification time of the file that gets copied. This is different to how 'docker' itself does it with a multi-stage build.

      Version-Release number of selected component (if applicable):

      4.12.14
      

      How reproducible:

      Always
      

      Steps to Reproduce:

      1. git clone https://github.com/jerboaa/quarkus-quickstarts
      2. cd quarkus-quickstarts && git checkout ocp-bug-inline-docker
      3. oc new-project quarkus-appcds-nok
      4. oc process -f rest-json-quickstart/openshift/quarkus_runtime_appcds_template.yaml | oc create -f -
      

      Actual results:

      $ oc logs quarkus-rest-json-appcds-4-xc47z
      INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -Xshare:on -XX:SharedArchiveFile=/deployments/app-cds.jsa -Dquarkus.http.host=0.0.0.0 -cp "." -jar /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar 
      INFO running in /deployments
      Error occurred during initialization of VM
      Unable to use shared archive.
      An error has occurred while processing the shared archive file.
      A jar file is not the one used while building the shared archive file: rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
      

      Expected results:

      Starting the Java application using /opt/jboss/container/java/run/run-java.sh ...
      INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -Xshare:on -XX:SharedArchiveFile=/deployments/app-cds.jsa -Dquarkus.http.host=0.0.0.0 -cp "." -jar /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar 
      INFO running in /deployments
      __  ____  __  _____   ___  __ ____  ______ 
       --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
       -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
      --\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
      2023-10-27 18:13:01,866 INFO  [io.quarkus] (main) rest-json-quickstart 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.4.3) started in 0.966s. Listening on: http://0.0.0.0:8080
      2023-10-27 18:13:01,867 INFO  [io.quarkus] (main) Profile prod activated. 
      2023-10-27 18:13:01,867 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, vertx]
      

      Additional info:

      When deploying with AppCDS turned on, then we can get the pods to start and when we then look at the modified file time of the offending file we notice that these differ from the original s2i-merge-image (A) and the runtime image (B):
      
      (A)
      $ oc rsh quarkus-rest-json-appcds-s2i-1-x5hct stat /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        File: /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        Size: 16057039  	Blocks: 31368      IO Block: 4096   regular file
      Device: 200001h/2097153d	Inode: 60146490    Links: 1
      Access: (0664/-rw-rw-r--)  Uid: (  185/ default)   Gid: (    0/    root)
      Access: 2023-10-27 18:11:22.000000000 +0000
      Modify: 2023-10-27 18:11:22.000000000 +0000
      Change: 2023-10-27 18:11:41.555586774 +0000
       Birth: 2023-10-27 18:11:41.491586774 +0000
      
      (B)
      $ oc rsh quarkus-rest-json-appcds-1-l7xw2 stat /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        File: /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        Size: 16057039  	Blocks: 31368      IO Block: 4096   regular file
      Device: 2000a3h/2097315d	Inode: 71601163    Links: 1
      Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
      Access: 2023-10-27 18:11:44.000000000 +0000
      Modify: 2023-10-27 18:11:44.000000000 +0000
      Change: 2023-10-27 18:12:12.169087346 +0000
       Birth: 2023-10-27 18:12:12.114087346 +0000
      
      Both should have 'Modify: 2023-10-27 18:11:22.000000000 +0000'.
      

      When I perform a local s2i build of the same application sources and then use this multi-stage Dockerfile, the modify time of the files remain the same.

      FROM quarkus-app-uberjar:ubi9 as s2iimg
      
      FROM registry.access.redhat.com/ubi9/openjdk-17-runtime as final
      COPY --from=s2iimg /deployments/* /deployments/
      ENV JAVA_OPTS_APPEND="-XX:+UseCompressedClassPointers -XX:+UseCompressedOops -Xshare:on -XX:SharedArchiveFile=app-cds.jsa"
      

      as shown here:

      $ sudo docker run --rm -ti --entrypoint /bin/bash quarkus-app-uberjar:ubi9 -c 'stat /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar'
        File: /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        Size: 16057020  	Blocks: 31368      IO Block: 4096   regular file
      Device: 6fh/111d	Inode: 276781319   Links: 1
      Access: (0664/-rw-rw-r--)  Uid: (  185/ default)   Gid: (    0/    root)
      Access: 2023-10-27 15:52:28.000000000 +0000
      Modify: 2023-10-27 15:52:28.000000000 +0000
      Change: 2023-10-27 15:52:37.352926632 +0000
       Birth: 2023-10-27 15:52:37.288926109 +0000
      $ sudo docker run --rm -ti --entrypoint /bin/bash quarkus-cds-app -c 'stat /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar'
        File: /deployments/rest-json-quickstart-1.0.0-SNAPSHOT-runner.jar
        Size: 16057020  	Blocks: 31368      IO Block: 4096   regular file
      Device: 6fh/111d	Inode: 14916403    Links: 1
      Access: (0664/-rw-rw-r--)  Uid: (  185/ default)   Gid: (    0/    root)
      Access: 2023-10-27 15:52:28.000000000 +0000
      Modify: 2023-10-27 15:52:28.000000000 +0000
      Change: 2023-10-27 15:53:04.408147760 +0000
       Birth: 2023-10-27 15:53:04.346147253 +0000
      

      Both have a modified file time of 2023-10-27 15:52:28.000000000 +0000

              cdaley Corey Daley
              openshift-crt-jira-prow OpenShift Prow Bot
              Corey Daley Corey Daley
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: