Skip to content

cm: imagemanager: limit number of stored item versions - #641

Merged
al1img merged 1 commit into
aosedge:developfrom
MykolaSuperman:fix/cm-item-versions-limit
Aug 12, 2026
Merged

cm: imagemanager: limit number of stored item versions#641
al1img merged 1 commit into
aosedge:developfrom
MykolaSuperman:fix/cm-item-versions-limit

Conversation

@MykolaSuperman

Copy link
Copy Markdown

CM kept every removed item version in storage until updateItemTTL expired (30d by default), while all read buffers were sized against cMaxNumItemVersions (2). On the third consecutive update of the same item GetItemInfos() overflowed its array and the launcher failed with "can't add item info", leaving the instance unable to start.

Trim the oldest removed versions before adding a new one, the way SM does it in RemoveOldItemVersions(), so an item never exceeds cMaxNumItemVersions rows. An installed version is never force removed: if no removed version is left to reclaim, the trim just stops.

Move cMaxNumItemVersions to the storage interface as it now describes a storage invariant, and add cMaxNumStoredItems for the whole table. GetAllItemsInfos() buffers counted items instead of rows and would have overflowed the same way past 64 rows, so size them accordingly.

/**
* Max number of versions stored per update item.
*/
constexpr auto cMaxNumItemVersions = 2;

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.

Why do you need it in public? It could be private consts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

to calculate this one
constexpr auto cMaxNumStoredItems = cMaxNumUpdateItems * cMaxNumItemVersions;

in this case than i need to repeat in here

@MykolaSuperman
MykolaSuperman force-pushed the fix/cm-item-versions-limit branch from c4ba2a6 to 1df9e2e Compare August 11, 2026 14:08

@al1img al1img left a comment

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.

Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

CM kept every removed item version in storage until updateItemTTL
expired (30d by default), while all read buffers were sized against
cMaxNumItemVersions (2). On the third consecutive update of the same
item GetItemInfos() overflowed its array and the launcher failed with
"can't add item info", leaving the instance unable to start.

Trim the oldest removed versions before adding a new one, the way SM
does it in RemoveOldItemVersions(), so an item never exceeds
cMaxNumItemVersions rows. An installed version is never force removed:
if no removed version is left to reclaim, the trim just stops.

Add cMaxNumStoredItems to size the buffers holding the whole table:
GetAllItemsInfos() ones counted items instead of rows and would have
overflowed the same way past 64 rows.

Signed-off-by: Mykola Solianko <mykola_solianko@epam.com>
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
Reviewed-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
@MykolaSuperman
MykolaSuperman force-pushed the fix/cm-item-versions-limit branch from 1df9e2e to bd4fb3f Compare August 11, 2026 14:20
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@mykola-kobets-epam mykola-kobets-epam left a comment

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.

Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>

@al1img
al1img merged commit 29f2d2b into aosedge:develop Aug 12, 2026
4 of 5 checks passed
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.

3 participants