Stage package tracking is unaware of partitions
Metadata
Current evaluation
Closed. Proposed a short-term fix to track stage packages per-partition during priming, with a long-term partition-aware solution planned. A temporary workaround branch was created to disable tracking.
Suggested action: —
No scores available.
Issue body
### Bug Description
If partitions are enabled and a project's parts make use of them, the LifecycleManager will try to prime files from the default prime directory, ignoring any partition prefix. The files do actually exist inside the partition's prime directory, where they are supposed to be.
Note also that the specific file that the failure occurs on will randomly be one of the primed files, it isn't always the same one. Don't know if that's relevant.
### To Reproduce
Enable and make use of partitions, then prime some file(s) from `stage-packages` (I think?)
### part yaml
```shell
kernel:
stage-packages:
linux-image-generic
organize:
lib/modules: (mattos-a)/lib/modules
prime:
(mattos-a)/lib/modules/*/kernel/drivers/net/virtio_net.ko,
(mattos-a)/lib/modules/*/modules.builtin,
(mattos-a)/lib/modules/*/modules.builtin.modinfo,
(mattos-a)/lib/modules/*/modules.order,
```
### Relevant log output
```shell
2024-08-08 13:56:15.372 execute action kernel:Action(part_name='kernel', step=Step.PRIME, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2024-08-08 13:56:18.786 /home/mrc/code/willis/mattcraft/examples/coaster-os/prime/lib/modules/5.15.0-118-generic/kernel/drivers/net/virtio_net.ko: No such file or directory
2024-08-08 13:56:18.786 Detailed information: FileNotFoundError: filename: '/home/mrc/code/willis/mattcraft/examples/coaster-os/prime/lib/modules/5.15.0-118-generic/kernel/drivers/net/virtio_net.ko'
2024-08-08 13:56:18.787 Traceback (most recent call last):
2024-08-08 13:56:18.787 File "/home/mrc/code/willis/mattcraft/.direnv/python-3.10.12/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 261, in run
2024-08-08 13:56:18.787 aex.execute(action, stdout=stream, stderr=stream)
2024-08-08 13:56:18.787 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/executor.py", line 327, in execute
2024-08-08 13:56:18.788 self._executor.execute(actions, stdout=stdout, stderr=stderr)
2024-08-08 13:56:18.788 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/executor.py", line 137, in execute
2024-08-08 13:56:18.788 self._run_action(act, stdout=stdout, stderr=stderr)
2024-08-08 13:56:18.788 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/executor.py", line 214, in _run_action
2024-08-08 13:56:18.788 handler.run_action(action, stdout=stdout, stderr=stderr)
2024-08-08 13:56:18.788 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/part_handler.py", line 170, in run_action
2024-08-08 13:56:18.788 state = handler(step_info, stdout=stdout, stderr=stderr)
2024-08-08 13:56:18.788 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/part_handler.py", line 424, in _run_prime
2024-08-08 13:56:18.788 primed_stage_packages = _get_primed_stage_packages(
2024-08-08 13:56:18.789 File "/home/mrc/code/willis/craft-parts/craft_parts/executor/part_handler.py", line 1140, in _get_primed_stage_packages
2024-08-08 13:56:18.789 stage_package = read_origin_stage_package(snap_file)
2024-08-08 13:56:18.789 File "/home/mrc/code/willis/craft-parts/craft_parts/packages/base.py", line 259, in read_origin_stage_package
2024-08-08 13:56:18.789 return xattrs.read_xattr(path, _STAGE_PACKAGE_KEY)
2024-08-08 13:56:18.789 File "/home/mrc/code/willis/craft-parts/craft_parts/xattrs.py", line 47, in read_xattr
2024-08-08 13:56:18.789 value = os.getxattr(path, key)
2024-08-08 13:56:18.789 FileNotFoundError: [Errno 2] No such file or directory: '/home/mrc/code/willis/mattcraft/examples/coaster-os/prime/lib/modules/5.15.0-118-generic/kernel/drivers/net/virtio_net.ko'
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Closed. Proposed a short-term fix to track stage packages per-partition during priming, with a long-term partition-aware solution planned. A temporary workaround branch was created to disable tracking. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved in craft-parts by implementing per-partition stage package tracking during the prime step. The fix checks each partition's prime directory for xattrs, addressing the original bug. Long-term partition awareness remains planned. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed via a short-term patch to check stage packages per-partition during prime. The LifecycleManager now correctly resolves partition prefixes. A long-term solution awaits partition-aware StateManager support. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by implementing per-partition stage package tracking during the prime step to prevent FileNotFoundError. Long-term partition-aware state management remains pending. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #834 fix: use partitions for stage-packages tracking | craft-parts | merged | Merged to fix issue #804. The change updates stage-package tracking to scan primed files per partition, resolving failures in common partitioned setups. Multi-partition tracking still requires deeper refactoring. Approved by three reviewers and passed CI. |