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

Assembly files with unnormalized paths don't get fileMode changes #1483

Closed
manusa opened this issue May 2, 2022 · 4 comments · Fixed by #1487
Closed

Assembly files with unnormalized paths don't get fileMode changes #1483

manusa opened this issue May 2, 2022 · 4 comments · Fixed by #1487
Assignees
Labels
bug Something isn't working
Milestone

Comments

@manusa
Copy link
Member

manusa commented May 2, 2022

Description

The following entries are not equal but should be:

  • /quarkus-demo/build/./camel-quarkus-demo-1.0.0-runner
  • /quarkus-demo/build/camel-quarkus-demo-1.0.0-runner

https://github.com/eclipse/jkube/blob/ee2390178dcad8a9cc3a9cb6d5e8c5d70a162a04/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/archive/JKubeTarArchiver.java#L80-L85

This is caused by a configuration such as:

<files>
  <file>
    <source>target/${project.artifactId}-${project.version}.jar</source>
    <outputDirectory>.</outputDirectory>
  </file>
</files>

We should normalize the output directory to avoid this issue:

https://github.com/eclipse/jkube/blob/c83eb4bace375fd53f2c83b987a5c728d7695f89/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/archive/AssemblyFileUtils.java#L49

Maybe:

outputDirectory.toPath().normalize().toFile();
@manusa manusa added the bug Something isn't working label May 2, 2022
@manusa manusa added this to the 1.8.0 milestone May 2, 2022
@rohanKanojia rohanKanojia self-assigned this May 6, 2022
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue May 6, 2022
…leMode changes (eclipse-jkube#1483)

Normalize output directory returned by AssemblyFileUtils

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa
Copy link
Member Author

manusa commented May 9, 2022

Could you please try with this repo (note the commit hash): https://github.com/iam-roger-io/camel-quarkus-demo/blob/6161f0a989e5436f179efc08e80ed7a3ae12ef04/pom.xml

									<build>
										<from>registry.access.redhat.com/ubi8/ubi-minimal:8.5</from>
										
										<tags>
											<tag>latest</tag>
											<tag>${project.version}</tag>
										</tags>

										<entryPoint>/${project.artifactId}-${project.version}-runner</entryPoint>
										<assembly>
											<mode>dir</mode>
											<targetDir>/</targetDir>
											<inline>
												<id>customized-quarkus</id>
												<files>
													<file>
														<source>target/${project.artifactId}-${project.version}-runner</source>
														<outputDirectory>.</outputDirectory>
														<fileMode>0755</fileMode>
													</file>
												</files>
											</inline>										
										</assembly>

										<runCmds>
											<!-- <run>chown 1001:root -R /application</run> -->
											<run>chmod +x /${project.artifactId}-${project.version}-runner</run>
										</runCmds>
									</build>

The runCmds commands should not be necessary, and permissions in the generated container should be changed in the tar archive:

tar --numeric-owner -tvf ./target/docker/org.acme/camel-quarkus-demo/tmp/docker-build.tar

@rohanKanojia
Copy link
Member

Somehow native build isn't working for me on this repository. I had to make some changes to project to copy quarkus-run jar instead of native executable. Here are my observations:

With 1.7.0 permission of quarkus-run jar is 0644 (not as configured)

camel-quarkus-demo : $ mvn k8s:build -Pkubernetes


camel-quarkus-demo : $ tar --numeric-otar --numeric-owner -tvf ./target/docker/org.acme/camel-quarkus-demo/tmp/docker-build.tar
drwxr-xr-x 1000/1000         0 2022-05-09 17:12 customized-quarkus/
-rw-r--r-- 1000/1000       608 2022-05-09 17:12 customized-quarkus/quarkus-run.jar
drwxr-xr-x 1000/1000         0 2022-05-09 17:12 jkube-generated-layer-final-artifact/
-rw-r--r-- 1000/1000      9375 2022-05-09 17:12 jkube-generated-layer-final-artifact/camel-quarkus-demo-1.0.0.jar
-rw-r--r-- 1000/1000       149 2022-05-09 17:12 Dockerfile

Docker container:

camel-quarkus-demo : $ docker run -it --entrypoint /bin/sh cdd7c
sh-4.4$ cd /
sh-4.4$ ls -lt quarkus-run.jar 
-rw-r--r-- 1 root root 608 May  9 11:58 quarkus-run.jar

With 1.8.0-SNAPSHOT based on #1487 permissions of quarkus-run jar is 0755 as expected

camel-quarkus-demo : $ mvn k8s:build  -Pkubernetes

camel-quarkus-demo : $ tar --numeric-owner -tvf ./target/docker/org.acme/camel-quarkus-demo/tmp/docker-build.tar
drwxr-xr-x 1000/1000         0 2022-05-09 17:16 customized-quarkus/
-rwxr-xr-x 1000/1000       608 2022-05-09 17:16 customized-quarkus/quarkus-run.jar
drwxr-xr-x 1000/1000         0 2022-05-09 17:16 jkube-generated-layer-final-artifact/
-rw-r--r-- 1000/1000      9375 2022-05-09 17:16 jkube-generated-layer-final-artifact/camel-quarkus-demo-1.0.0.jar
-rw-r--r-- 1000/1000       149 2022-05-09 17:16 Dockerfile

Docker container:

camel-quarkus-demo : $ docker run -it --entrypoint /bin/sh 6222c
sh-4.4$ ls -lt /quarkus-run.jar 
-rwxr-xr-x 1 root root 608 May  9 12:08 /quarkus-run.jar

@manusa
Copy link
Member Author

manusa commented May 9, 2022

Somehow native build isn't working for me on this repository. I had to make some changes to project to copy quarkus-run jar instead of native executable. Here are my observations:

Have you tried using a remote container build (n.b. use Java 11 unless you want to provide additional options)?

mvn clean package -Pnative -Dquarkus.native.remote-container-build=true

@rohanKanojia
Copy link
Member

Thanks, I was using the remote container build but in my minikube docker-env session. Running it against local docker daemon works.

I just verified this scenario with native executable as well. fix seems to be working as expected (i.e. even after removing runCmds I can see correct permissions 0755 set in tarball and inside running container for runner file)

manusa pushed a commit that referenced this issue May 10, 2022
…leMode changes (#1483)

Normalize output directory returned by AssemblyFileUtils

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants