Skip to content

Fix imagemanager allocation - #593

Open
MykolaSuperman wants to merge 4 commits into
aosedge:developfrom
MykolaSuperman:fix_imagemanager_allocation
Open

Fix imagemanager allocation#593
MykolaSuperman wants to merge 4 commits into
aosedge:developfrom
MykolaSuperman:fix_imagemanager_allocation

Conversation

@MykolaSuperman

Copy link
Copy Markdown

No description provided.

Mykola Solianko added 3 commits June 18, 2026 16:51
ResizeSpace called Partition::Free + Partition::Allocate which toggled
mAllocationCount on every resize. Since mAllocationCount > 0 suppresses
disk re-reads, mAvailableSize became stale and lazy eviction stopped
triggering, leading to ENOSPC on subsequent allocations.

Add Partition::AdjustSize that adjusts mAvailableSize and triggers
eviction when needed without touching mAllocationCount. ResizeSpace now
calls AdjustSize instead of the Free/Allocate pair on the partition,
keeping mAllocationCount as a pure count of live Space objects.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
RemoveOrphans sweeps the disk and deletes everything not referenced by
any DB item. Blobs and layer dirs for concurrently-installing items are
on disk but not yet committed to DB, so they were deleted as orphans.

Before calling RemoveOrphanBlobs and RemoveOrphanLayers, add the blob
path and corresponding layer dir path for every digest in mInProgressBlobs
to the respective used-sets. This prevents the sweep from touching files
that belong to an in-progress installation.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
… deletion

RemoveOrphans sweeps the entire disk and deletes everything not
referenced by the DB. When called from RemoveItem during eviction, it
raced with concurrent installs: files on disk but not yet in DB were
deleted as orphans, causing "Failed to unpack layer" errors.

Replace the RemoveOrphans call in RemoveItem with targeted deletion:
1. Collect the blobs/layers still needed by all remaining DB items
   (CalcRemainingBlobsAndLayers, skipping the evicted item).
2. Load the evicted item's own manifest to enumerate exactly what it
   owns (FindUpdateItemData + DeleteEvictedItemFiles).
3. Delete only the evicted item's exclusive files, blobs and layers
   not present in the remaining set.

RemoveOrphans is retained as a fallback for the allocation-failure path
where no item data is available.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.66142% with 116 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.66%. Comparing base (4491aee) to head (3979a43).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
src/core/sm/imagemanager/imagemanager.cpp 0.91% 108 Missing ⚠️
src/core/common/spaceallocator/spaceallocator.hpp 46.66% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #593      +/-   ##
===========================================
- Coverage    84.98%   84.66%   -0.32%     
===========================================
  Files          325      325              
  Lines        29036    29155     +119     
  Branches      3896     3943      +47     
===========================================
+ Hits         24677    24685       +8     
- Misses        4359     4470     +111     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…llation

When a download is cancelled to process a new desired status, mCancel is
set to true. Once the cancelled download finishes and mInProgress becomes
false, a subsequent DownloadUpdateItems call would enter StartAction and
immediately return false because mCancel was still set, causing the new
download to fail with eCanceled without attempting any network activity.

Only reject starting a new action when mCancel is true and mInProgress is
also true, meaning there is an active download being cancelled. A stale
mCancel with no in-progress action should not block the next download.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
44.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

* @param newSize new size to reserve.
* @return Error.
*/
Error AdjustSize(size_t oldSize, size_t newSize)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename method to Resize. It looks like we can keep only one parameter as deltaSize. It could be positive and negative in the general case. In case negative delta size we can just update mAvailableSize for positive delta size we shuould check if there is enough available space and try to remove outdated items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants