Skip to content

Don't list KAR files that are still being extracted - #3164

Draft
holgerfriedrich wants to merge 1 commit into
apache:mainfrom
holgerfriedrich:fix-kar-list-incomplete
Draft

holgerfriedrich wants to merge 1 commit into
apache:mainfrom
holgerfriedrich:fix-kar-list-incomplete

Conversation

@holgerfriedrich

Copy link
Copy Markdown
Contributor

KarServiceImpl.list() returned every directory in the KAR storage. Kar.extract() creates that directory before unpacking, so a KAR was reported as installed while it was still being extracted. Callers acting on list() could then fail to resolve artifacts from the KAR repository, and KarArtifactInstaller skipped a KAR whose extraction had been interrupted, so it was never completed.

Only list directories containing features.cfg, which install() writes once the extraction is complete.

KarServiceImpl.list() returned every directory in the KAR storage. Kar.extract()
creates that directory before unpacking, so a KAR was reported as installed
while it was still being extracted. Callers acting on list() could then fail to
resolve artifacts from the KAR repository, and KarArtifactInstaller skipped a KAR
whose extraction had been interrupted, so it was never completed.

Only list directories containing features.cfg, which install() writes once the
extraction is complete.
@github-actions

Copy link
Copy Markdown

Test Results

1 132 files  ±0  1 132 suites  ±0   1h 29m 23s ⏱️ - 1h 57m 35s
1 401 tests  - 2  1 270 ✅ +1  131 💤 ±0  0 ❌  - 1 
5 604 runs  ±0  5 078 ✅ +3  526 💤 ±0  0 ❌  - 1 

Results for commit 70c82cb. ± Comparison against base commit dcc0ea4.

This pull request removes 2 tests.
org.apache.karaf.itests.examples.DeployerExampleTest ‑ initializationError
org.apache.karaf.itests.examples.NamespaceHandlerExampleTest ‑ initializationError

@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

Reported in openhab/openhab-distro#2007.

Reproduced with openHAB on Karaf 4.4.11 and 4.5.0 by creating the KAR directory before startup, which is the state during extraction or after an interrupted install. Feature installation failed with Could not find artifact, and the deployer logged "KAR ... is already installed" and never extracted the KAR. With this change, kar:list doesn't report the KAR until the extraction is complete, the deployer extracts it into the existing directory, and the features install from it.

@jbonofre
jbonofre self-requested a review November 26, 2026 15:17
lolodomo pushed a commit to lolodomo/openhab-core that referenced this pull request Nov 28, 2026
Karaf lists a KAR as installed as soon as its extraction starts, and
skips it on every following start. If openHAB is stopped while the KAR
is extracted, features.cfg is never written and FeatureInstaller would
wait for it forever.

Track the size of the KAR directory. If a listed KAR without
features.cfg does not change for 4 consecutive checks, install it again
once. Afterwards it counts as installed even if that failed, so the
add-on installation is never blocked.

This can be removed once Karaf contains apache/karaf#3164.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant