Skip to content

store/onprem: add .cache to .state migration#4615

Open
croissanne wants to merge 1 commit into
osbuild:mainfrom
croissanne:cache-migration
Open

store/onprem: add .cache to .state migration#4615
croissanne wants to merge 1 commit into
osbuild:mainfrom
croissanne:cache-migration

Conversation

@croissanne

Copy link
Copy Markdown
Member

This was backported to 10.2. For certainty, let's keep it around for a bit longer, in case users upgrade from 10.0 or 10.1 straight to a future minor version.

This was backported to 10.2. For certainty, let's keep it around for a
bit longer, in case users upgrade from 10.0 or 10.1 straight to a future
minor version.
@croissanne croissanne requested a review from a team as a code owner July 9, 2026 15:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider guarding the migration script with more explicit error handling or logging so failures copying from ~/.cache are visible and don't silently proceed to use an empty state directory.
  • The inline comment about dropping after 10.4 is vague; it may be clearer to link this to a specific cleanup ticket or configuration to avoid leaving stale compatibility code indefinitely.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding the migration script with more explicit error handling or logging so failures copying from ~/.cache are visible and don't silently proceed to use an empty state directory.
- The inline comment about dropping after 10.4 is vague; it may be clearer to link this to a specific cleanup ticket or configuration to avoid leaving stale compatibility code indefinitely.

## Individual Comments

### Comment 1
<location path="src/store/api/backend/onprem/composerApi/helpers/getBlueprintsPath.ts" line_range="16" />
<code_context>
   }
   const blueprintsDir = path.join(stateDir, BLUEPRINTS_DIR);

+  // Backwards compatibility, drop after 10.4?
+  await cockpit.script(`
+if [ ! -e "${blueprintsDir}" ] && [ -d "${user.home}/.cache/cockpit-image-builder" ] ; then
</code_context>
<issue_to_address>
**suggestion:** The version-specific backwards-compatibility note could become stale without a more explicit mechanism.

Because this cleanup is only indicated by a comment, it depends on someone remembering to remove it. Consider driving this via a feature flag or a version check, or at least replace the question mark with a clear TODO that references the cutoff version so it’s easier to track and remove when the time comes.

Suggested implementation:

```typescript
  const blueprintsDir = path.join(stateDir, BLUEPRINTS_DIR);

  // TODO: Remove this backwards-compatibility shim after cockpit-image-builder version 10.4.
  //       When dropping support for pre-10.4, delete this block and the legacy cache directory handling.
  await cockpit.script(`
if [ ! -e "${blueprintsDir}" ] && [ -d "${user.home}/.cache/cockpit-image-builder" ] ; then
  mkdir -p "${stateDir}"
  cp -a "${user.home}/.cache/cockpit-image-builder" "${stateDir}/"
fi
`);

```

If the project introduces a feature flag or a version check mechanism for compatibility shims elsewhere in the codebase, this block should also be guarded by that mechanism (for example, checking the cockpit-image-builder version or a configuration flag) so it can be disabled centrally when support for versions before 10.4 is dropped.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.53%. Comparing base (9f4afa4) to head (e00dc91).
⚠️ Report is 213 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4615      +/-   ##
==========================================
- Coverage   75.90%   71.53%   -4.37%     
==========================================
  Files         225      255      +30     
  Lines        7209     6830     -379     
  Branches     2668     2503     -165     
==========================================
- Hits         5472     4886     -586     
- Misses       1494     1911     +417     
+ Partials      243       33     -210     
Flag Coverage Δ
vitest 71.53% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 177 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f4afa4...e00dc91. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kingsleyzissou

Copy link
Copy Markdown
Collaborator

Looks fine, just need #4616 to land first

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.

2 participants