fix(controller): wait for each required CRD, not only its group #169
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/kubevirt/virt-template/pull/169?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_status_start -->
No actionable comments were generated in the recent review.
<!-- recent_review_status_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Walkthrough</strong></summary>
<dl>
<dd>
<br>
The controller now checks availability for each required resource during startup and polling. It reports missing resources and waits until all required resources are served. Cache entries are configured for served DataVolume and VirtualMachineSnapshot resources, while VirtualMachineSnapshotContent is always excluded from cached reads. The controller also skips status patches when status is unchanged. Tests cover waiting for a missing resource and a NotFound response when reading an unavailable VirtualMachineSnapshotContent.
<!-- change_assessment_start -->
Estimated code review effort: 3 (Moderate) | ~20 minutes
<!-- change_assessment_commit:"d8110e7a4b84a2fb2c2031f70098397ac7fa4d14" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
<!-- change_assessment_end -->
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>d8110</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to d8110
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"d8110e7a4b84a2fb2c2031f70098397ac7fa4d14","coveredCommitId":"d8110e7a4b84a2fb2c2031f70098397ac7fa4d14","kind":"reviewed"} -->
The change makes the controller wait for each required CRD individually and avoids cache failures when snapshot CRDs are installed after startup. No concrete merge-blocking risk was identified.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- operational_warnings_start -->
<!-- This is an auto-generated comment: resource warnings by coderabbit.ai -->
[!WARNING]
Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. Analyzedkubevirt/kubevirt,kubevirt/enhancements, skippedkubevirt/virt-template-api,kubevirt/virt-template-client-go,kubevirt/virt-template-engine,kubevirt/containerized-data-importer.
<!-- end of auto-generated comment: resource warnings by coderabbit.ai -->
<!-- operational_warnings_end -->
<!-- tips_start -->
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.
<details>
<summary><strong>Share</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
<!-- tips_end -->
<!-- recent_review_start -->
<h6>
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<br>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
<br>
9418f1d4-d563-4ded-b46d-6ba086950989</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between 8f6cf73cd18dbe61405a3b976c10aacd09ec9f4d and d8110e7a4b84a2fb2c2031f70098397ac7fa4d14.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary>
<dl>
<dd>
<br>
internal/controller/vmtr_availability_controller.go
internal/controller/vmtr_availability_controller_test.go
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/linked-repositories-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/linked-repositories.svg" width="16" height="16" align="absmiddle" alt=""></picture> Linked repositories identified</strong></summary>
<dl>
<dd>
<br>
CodeRabbit considers these linked repositories for cross-repo context during reviews:
kubevirt/kubevirt _(manual)_kubevirt/enhancements _(manual)_</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- recent_review_end -->
/cherry-pick release-0.3
@0xFelix: once the present PR merges, I will cherry-pick it on top of release-0.3 in a new PR and assign it to you.
<details>
In response to this:
>/cherry-pick release-0.3
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
I think what you meat here is !isResourceServed. Otherwise the client is disabled when the resource is served
It's intentional, we don't want VirtualMachineSnapshotContents to be read from the informer/cache
But... it doesn't have to be conditional, you're right!
Actually it doesn't need to be conditional, and that breaks if the CRD shows up after startup. Fixed
/cherry-pick release-0.2
@0xFelix: once the present PR merges, I will cherry-pick it on top of release-0.2 in a new PR and assign it to you.
<details>
In response to this:
>/cherry-pick release-0.2
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubevirt/virt-template/pull/169#issuecomment-7289889378" title="Approved">ksimon1</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
@0xFelix: new pull request created: #230
<details>
In response to this:
>/cherry-pick release-0.3
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
@0xFelix: new pull request created: #231
<details>
In response to this:
>/cherry-pick release-0.2
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
jcanocan
0xFelix
What this PR does / why we need it:
The availability controller started the VMTR controller as soon as the
cdi.kubevirt.ioandsnapshot.kubevirt.iogroups were served. CRDs of a group are registered one by one, so one could still be missing. Check each resource (datavolumes,virtualmachinesnapshots,virtualmachinesnapshotcontents) instead, also for the cache config.While waiting, it also skips the status patch of requests whose status did not change.
It also disables the client cache for
VirtualMachineSnapshotContentsunconditionally. Before, reading them failed if their CRD was installed after startup.Which issue(s) this PR fixes:
Special notes for your reviewer:
Release note:
``
release-note
``Fix requests failing if the snapshot CRDs are installed after virt-template started
Generated with Claude Code