Skip to content

Refactor logic of referenced versions#17

Merged
valeryia-hurynovich merged 1 commit intomasterfrom
refactor-logic-of-referenced-versions
Apr 15, 2026
Merged

Refactor logic of referenced versions#17
valeryia-hurynovich merged 1 commit intomasterfrom
refactor-logic-of-referenced-versions

Conversation

@valeryia-hurynovich
Copy link
Copy Markdown
Collaborator

@valeryia-hurynovich valeryia-hurynovich commented Apr 15, 2026

ProviderConfig.machineImages were originally included in the referenced version calculation because it contains the resolved image mappings produced from the OCI source, and we treated it as part of the available version set for a CloudProfile.

After reviewing the reconciliation flow more carefully, it was realized that ProviderConfig is a derived artifact that is fully regenerated on each reconciliation from OCI and does not represent either user intent or actual runtime usage.

Including it in the referenced set causes inflated reference counts (as seen in logs with hundreds of versions) and prevents effective garbage collection of unused image versions.

Therefore, it's needed to adjus the logic so that only actual usage sources as Shoot is considered when determining referenced versions. ProviderConfig is excluded because it is not a lifecycle authority but a transient resolution layer.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3385fe7-f448-47d1-ad4a-414bbfe58593

📥 Commits

Reviewing files that changed from the base of the PR and between f6c3f55 and ae8c080.

📒 Files selected for processing (1)
  • controllers/managedcloudprofile_controller.go
💤 Files with no reviewable changes (1)
  • controllers/managedcloudprofile_controller.go

📝 Walkthrough

Walkthrough

The getReferencedVersions function in the managed cloud profile controller was simplified by removing logic that extracted version strings from CloudProfile provider configuration, retaining only the approach that collects versions from referenced Shoot objects' worker machine image specifications.

Changes

Cohort / File(s) Summary
Version Retrieval Simplification
controllers/managedcloudprofile_controller.go
Removed CloudProfile-based version extraction logic from getReferencedVersions. Function now exclusively derives referenced versions from Shoot objects by listing them and collecting Machine.Image.Version values from workers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A simpler path for versions we seek,
No CloudProfiles parsed week by week,
Just Shoots and their workers we inspect,
Cleaner logic, less to protect!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor logic of referenced versions' is related to the changeset, which refactors the getReferencedVersions function by removing CloudProfile fetching logic and simplifying to use only Shoot objects. However, it is vague and doesn't specify what the refactoring accomplishes or which component is being improved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-logic-of-referenced-versions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/cloud-profile-sync/controllers 56.84% (+1.88%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/cloud-profile-sync/controllers/managedcloudprofile_controller.go 56.84% (+1.88%) 285 (-17) 162 (-4) 123 (-13) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@valeryia-hurynovich valeryia-hurynovich merged commit b8fc518 into master Apr 15, 2026
7 checks passed
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