Skip to content

[kubernetes] Fix patches for kubevirt-cloud-provider - #735

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubernetes-kccm-patches
Apr 2, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubernetes-kccm-patches

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Apr 2, 2025 •

Copy link
Copy Markdown
Member

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

  • Chores
    • Updated the cloud provider’s container image to a new stable version.
  • New Features
    • Enhanced multi-cluster support to ensure services are correctly scoped to their respective clusters.
  • Refactor
    • Removed legacy service management logic for streamlined processing.
  • Tests
    • Adjusted test coverage to validate the improved multi-cluster and service filtering behaviors.

@coderabbitai

coderabbitai Bot commented Apr 2, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request updates the image tag for the kubevirt-cloud-provider by replacing an old digest with a new one. It also removes the old reconcileByAddressType method and its corresponding test, and revises the kubevirteps controller. The controller’s initialization now requires a new clusterName parameter, and its service filtering logic is updated accordingly. In addition, a redundant controller file is removed to streamline the implementation.

Changes

File(s) Change Summary
packages/apps/kubernetes/images/.../kubevirt-cloud-provider.tag Updated image digest from sha256:a2739ab1a400664207c96ca60d88004ce244dcbb81204a32a517ff59d0061459 to sha256:47ad85a2bb2b11818df85e80cbc6e07021e97e429d5bb020ce8db002b37a77f1.
packages/apps/kubernetes/images/.../patches/335.diff, 341.diff, 999.diff
pkg/controller/kubevirteps/...
Removed the reconcileByAddressType method and its test; updated NewKubevirtEPSController to include a new clusterName parameter and added a corresponding field in the Controller struct; refined service filtering based on cluster identity; removed redundant controller implementation.

Sequence Diagram(s)

sequenceDiagram
    participant C as Controller
    participant K8s as Kubernetes API
    C->>C: Initialize controller with clusterName
    C->>C: Start controller (startKubevirtCloudController)
    C->>C: Check for clusterName
    alt clusterName missing
        C->>C: Log fatal error and exit
    else clusterName present
        C->>K8s: Retrieve services
        K8s-->>C: Return list of services
        C->>C: Filter services by clusterName
        C->>K8s: Create/Update EndpointSlice for valid services
        K8s-->>C: Acknowledge update
    end
Loading

Suggested reviewers

  • lllamnyp

Poem

I'm a nimble rabbit on a coding spree,
Hopping through changes with clarity.
New cluster names guide my jaunty pace,
Old methods vanish without a trace.
With every update, my heart does cheer—
CodeRabbit hops on, full of good cheer! 🐇🎉


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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@kvaps Andrei Kvapil (kvaps) changed the title Fix patches for kubevirt-cloud-provider [kubernetes] Fix patches for kubevirt-cloud-provider Apr 2, 2025

@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

🧹 Nitpick comments (2)
packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/341.diff (2)

24-35: Consider gracefully handling missing clusterName.

klog.Fatalf abruptly terminates the process if --cluster-name is empty. If that's not strictly necessary, consider returning an error or setting a default instead.


309-436: Comprehensive slice update logic.

Merging "delete + create" into "update" is an efficient approach. Consider testing corner cases (mismatched address types, partial merges) to ensure robust behavior.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f4fba79 and 67217f2.

📒 Files selected for processing (4)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider.tag (1 hunks)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/335.diff (0 hunks)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/341.diff (4 hunks)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/999.diff (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/999.diff
  • packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/335.diff
🔇 Additional comments (9)
packages/apps/kubernetes/images/kubevirt-cloud-provider.tag (1)

1-1:

Details

❓ Verification inconclusive

Confirm the updated image digest.

It's recommended to verify the new digest points to a trusted image.

Run the following command to confirm the image is recognized in the registry:


🏁 Script executed:

#!/bin/bash
docker pull ghcr.io/cozystack/cozystack/kubevirt-cloud-provider:latest@sha256:47ad85a2bb2b11818df85e80cbc6e07021e97e429d5bb020ce8db002b37a77f1

Length of output: 241


Image Digest Verification Required

The updated image digest in packages/apps/kubernetes/images/kubevirt-cloud-provider.tag appears updated, but the automated verification failed because the Docker CLI wasn't available in the execution environment. Please manually verify that the image digest points to a trusted image using Docker in a local or properly configured environment. For example, run the following command where Docker is installed:

docker pull ghcr.io/cozystack/cozystack/kubevirt-cloud-provider:latest@sha256:47ad85a2bb2b11818df85e80cbc6e07021e97e429d5bb020ce8db002b37a77f1

Once confirmed, you can safely proceed.

packages/apps/kubernetes/images/kubevirt-cloud-provider/patches/341.diff (8)

51-55: New clusterName field in the Controller.

Adding clusterName clarifies multi-cluster usage. Ensure single-cluster scenarios also account for a non-empty clusterName.


82-117: Refined label selection with clusterName.

This ensures EndpointSlices are fetched only for the correct cluster. Verify that all relevant resources set the essential labels.


127-138: Updated EndpointSlice retrieval with clusterName.

Applying tighter scoping avoids cross-cluster collisions. Confirm that EndpointSlices are labeled properly.

Do you want a script to check for missing clusterName labels in EndpointSlices?


155-167: Skipping services from other clusters.

Properly filters out services that belong to different clusters. This helps maintain isolation in multi-cluster setups.


293-303: Resolved closure capture pitfalls.

Switching to an indexed loop prevents subtle bugs caused by capturing the loop variable. Good fix.


455-456: Test constructor now requires clusterName.

Good to see test coverage for new multi-cluster logic.


465-690: Extended test coverage.

These tests thoroughly validate multi-port endpoints, no-selector usage, and cross-cluster scenarios. Excellent improvement in reliability.


58-66:

Details

✅ Verification successful

Ensure consistent usage of the updated constructor.

Every call to NewKubevirtEPSController must now supply clusterName. Double-check references throughout the codebase.


🏁 Script executed:

#!/bin/bash
rg -A 5 'NewKubevirtEPSController'

Length of output: 3546


Updated Constructor Usage Verified

The changes correctly update the NewKubevirtEPSController signature to include the clusterName parameter, and all call sites in the patch now supply this additional argument. Specifically:

  • The constructor in the patch file now takes infraNamespace string, clusterName string and returns *Controller.
  • Existing references, including the test call, have been updated (e.g., "test" becomes "test", "test-cluster"), ensuring consistency with the new signature.

Please double-check any external usages outside of this patch to confirm they match the updated constructor pattern.

Comment on lines +9 to +14
+issues:
+ exclude-rules:
+ - filename: "kubevirteps_controller_test.go"
+ linters:
+ - govet
+ text: "declaration of \"err\" shadows"

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.

🛠️ Refactor suggestion

Fix err shadowing instead of ignoring the warning.

Excluding lint rules can hide real issues. It's often better to address the root cause by refactoring the code to avoid redeclaring err.

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.

1 participant