Skip to content

[kubernetes] Fix dead-lock while reattaching a KubeVirt-CSI volume - #1135

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubevirt-csi
Jul 3, 2025
Merged

[kubernetes] Fix dead-lock while reattaching a KubeVirt-CSI volume#1135
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubevirt-csi

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Jun 30, 2025

Copy link
Copy Markdown
Member

What this PR does

This pr imports upstream fix for volume reattaching procedure

Release note

[kubernetes] Fix dead-lock while reattaching a KubeVirt-CSI volume

Summary by CodeRabbit

  • New Features

    • Improved volume management for virtual machines by adding checks to skip unnecessary attach or detach operations when the volume is already in the desired state.
  • Tests

    • Added new unit tests to verify optimized volume attach/detach workflows and ensure fast-path logic is functioning correctly.

@coderabbitai

coderabbitai Bot commented Jun 30, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d583f82 and 4c347cc.

📒 Files selected for processing (1)
  • packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1 hunks)

Walkthrough

The kubevirt-csi-driver Dockerfile was updated to check out a new Git commit and apply local patch files during the build. The controller service was enhanced with new VM-specific volume presence checks to optimize attach/detach operations by skipping redundant calls. Corresponding tests and mocks were added or updated.

Changes

File(s) Change Summary
packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile Updated Git commit checkout; added copying and applying local patch files during build
packages/apps/kubernetes/images/kubevirt-csi-driver/patches/143.diff Added VM-specific volume presence check methods; optimized controller volume attach/detach logic; added tests and mocks for new methods
pkg/kubevirt/client.go Added EnsureVolumeAvailableVM and EnsureVolumeRemovedVM methods to Client interface and client struct
pkg/service/controller_test.go Added VM-specific method mocks and unit tests verifying fast-path volume attach/detach logic
sanity/sanity_test.go Added no-op implementations of new VM-specific methods in fake client

Poem

A bunny hopped to clone anew,
From kvaps’ fork, the code it drew.
With Docker’s file, the path rewired,
The source retrieved as now desired.
🐇✨ In code we trust, in hops we cheer—
The driver’s build is crystal clear!

Now volumes check on VMs with grace,
Skipping steps to win the race! 🥕🚀


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1)

17-22: Metadata drift – LABEL still points to the upstream repo

multi.GIT_URL advertises https://github.com/kubevirt/csi-driver.git, which no longer matches the actual cloned source.
This causes confusion and breaks provenance tracking.

-ARG git_url=https://github.com/kubevirt/csi-driver.git
+ARG git_url=https://github.com/kvaps/csi-driver.git

Remember to propagate the same ARG (or the new repo_url) into the LABEL to keep the image metadata truthful.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3a2bc8 and 3ecb1e0.

📒 Files selected for processing (1)
  • packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Pull Request
packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile

[error] 4-6: Docker build failed: git clone and checkout failed with 'fatal: reference is not a tree: 35836e0c8b68d9916d29a838ea60cdd3fc6199cf'. Command exited with code 128.

🔇 Additional comments (1)
packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile (1)

4-6: Security/provenance consideration – pulling from a personal fork

Switching from the official upstream to a fork introduces supply-chain risk. Make sure:

  • The chosen commit is reviewed & signed.
  • SBOM / provenance attestation is updated.
  • Upstream is informed so the fix can be merged back, eliminating the need for the fork.

Comment thread packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile Outdated
@kvaps
Andrei Kvapil (kvaps) force-pushed the kubevirt-csi branch 5 times, most recently from d583f82 to 0671559 Compare July 2, 2025 12:18

@lllamnyp Timofei Larkin (lllamnyp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If it's good enough for upstream, it's good enough for us/

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps

Copy link
Copy Markdown
Member Author

PR rebased, patch removed and now targets on upstream commit

@kvaps
Andrei Kvapil (kvaps) merged commit 193f43d into main Jul 3, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the kubevirt-csi branch July 3, 2025 11:27
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