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

java plugin should not link java under /bin #813

Open
vpa1977 opened this issue Aug 15, 2024 · 6 comments
Open

java plugin should not link java under /bin #813

vpa1977 opened this issue Aug 15, 2024 · 6 comments
Labels
Bug Something isn't working

Comments

@vpa1977
Copy link
Contributor

vpa1977 commented Aug 15, 2024

Bug Description

Java plugin attempts to link java executable under /bin.
This causes conflict with the other parts writing to /bin.

To Reproduce

  1. rockcraft pack attached project

part yaml

name: maven-sample-chisel
version: 0.0.1
summary: Sample Maven-based chiselled rock
description: |
  This image is a sample maven application
  using openjdk-21-jre-headless slices

base: bare
build-base: [email protected]

run-user: _daemon_

platforms:
  amd64:

services:
  test:
    override: replace
    summary: Service summary
    command: /usr/lib/jvm/java-21-openjdk-amd64/bin/java -jar /jars/sample-0.0.1-SNAPSHOT.jar
    startup: enabled

parts:
  application:
    plugin: maven
    source: ./sample
    source-type: local
    build-packages:
      - maven
      - openjdk-21-jdk

  runtime:
    plugin: nil
    source: https://github.com/vpa1977/chisel-releases
    source-type: git
    source-branch: 24.04-openjdk-21-jre-headless
    build-packages:
      - ca-certificates-java
    override-build: |
      chisel cut --release ./ --root ${CRAFT_PART_INSTALL} \
        base-files_base openjdk-21-jre-headless_security
      mkdir -p ${CRAFT_PART_INSTALL}/etc/ssl/certs/java/
      cp /etc/ssl/certs/java/cacerts ${CRAFT_PART_INSTALL}/etc/ssl/certs/java/cacerts

Relevant log output

2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.322 Staging application
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.322 execute action application:Action(part_name='application', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.347 Failed to stage: parts list the same file with different contents or permissions.
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.347 Detailed information: Parts 'runtime' and 'application' list the following files, but with different contents or permissions:
2024-08-16 11:47:22.717 ::     bin
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348 Traceback (most recent call last):
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 261, in run
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     aex.execute(action, stdout=stream, stderr=stream)
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 324, in execute
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     self._executor.execute(actions, stdout=stdout, stderr=stderr)
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 136, in execute
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     self._run_action(act, stdout=stdout, stderr=stderr)
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 206, in _run_action
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     check_for_stage_collisions(
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/collisions.py", line 59, in check_for_stage_collisions
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     _check_for_stage_collisions_per_partition(part_list, partition)
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/collisions.py", line 111, in _check_for_stage_collisions_per_partition
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     raise errors.PartFilesConflict(
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348 craft_parts.errors.PartFilesConflict: Failed to stage: parts list the same file with different contents or permissions.
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348 Parts 'runtime' and 'application' list the following files, but with different contents or permissions:
2024-08-16 11:47:22.717 :: 2024-08-16 11:47:22.348     bin
2024-08-16 11:47:22.717 Executing on host: lxc --project rockcraft config device show local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577
2024-08-16 11:47:22.813 Executing on host: lxc --project rockcraft config device remove local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577 disk-/root/project
2024-08-16 11:47:22.957 Executing on host: lxc --project rockcraft stop local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577
2024-08-16 11:47:27.024 Failed to execute rockcraft in instance.
2024-08-16 11:47:27.026 Traceback (most recent call last):
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 376, in run_managed
2024-08-16 11:47:27.026     instance.execute_run(  # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_providers/lxd/lxd_instance.py", line 293, in execute_run
2024-08-16 11:47:27.026     return self.lxc.exec(
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 387, in exec
2024-08-16 11:47:27.026     return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/usr/lib/python3.10/subprocess.py", line 526, in run
2024-08-16 11:47:27.026     raise CalledProcessError(retcode, process.args,
2024-08-16 11:47:27.026 subprocess.CalledProcessError: Command '['lxc', '--project', 'rockcraft', 'exec', 'local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=BRIEF', 'rockcraft', 'pack']' returned non-zero exit status 1.
2024-08-16 11:47:27.026 
2024-08-16 11:47:27.026 The above exception was the direct cause of the following exception:
2024-08-16 11:47:27.026 Traceback (most recent call last):
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 541, in run
2024-08-16 11:47:27.026     self.run_managed(platform, build_for)
2024-08-16 11:47:27.026   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 383, in run_managed
2024-08-16 11:47:27.026     raise craft_providers.ProviderError(
2024-08-16 11:47:27.026 craft_providers.errors.ProviderError: Failed to execute rockcraft in instance.
2024-08-16 11:47:27.026 Full execution log: '/home/vladimirp/.local/state/rockcraft/log/rockcraft-20240816-114556.473928.log'
@vpa1977 vpa1977 added the Bug Something isn't working label Aug 15, 2024
@vpa1977
Copy link
Contributor Author

vpa1977 commented Aug 15, 2024

chiselled-rock.tar.gz

@vpa1977 vpa1977 changed the title java plugin should no link java under /bin java plugin should not link java under /bin Aug 15, 2024
@lengau
Copy link
Contributor

lengau commented Aug 17, 2024

Like the staged runtime, I'm not sure we can change the default behaviour here without breaking backwards compatibility.

@vpa1977
Copy link
Contributor Author

vpa1977 commented Aug 18, 2024

I wonder if anyone used the plugin since it conflicts with anything providing /bin.

@lengau
Copy link
Contributor

lengau commented Aug 18, 2024

There are definitely snaps that use it and could be broken if this location changes. If this prevents rocks from building, craft-parts should offer a way for applications to override the location where Java is placed so Rockcraft can place it in /usr/bin (or wherever), similar to the Python plugin. However, that may also break rocks that expect Java to be in /bin (if any exist).

Cc @tigarmo

@vpa1977
Copy link
Contributor Author

vpa1977 commented Aug 18, 2024

There are definitely snaps that use it and could be broken if this location changes. If this prevents rocks from building, craft-parts should offer a way for applications to override the location where Java is placed so Rockcraft can place it in /usr/bin (or wherever), similar to the Python plugin. However, that may also break rocks that expect Java to be in /bin (if any exist).

Cc @tigarmo

In my use-case it would be better to have an option not to deploy links in staging.

@lengau
Copy link
Contributor

lengau commented Aug 30, 2024

@vpa1977 paired with the jlink plugin for rockcraft that makes a lot of sense - we'll just need to figure out details.

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
Development

No branches or pull requests

2 participants