-
Notifications
You must be signed in to change notification settings - Fork 57
CNV-71151: Update service label selectors to use vmi.kubevirt.io/id for KubeVirt v1.7+ compatibility #3150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
CNV-71151: Update service label selectors to use vmi.kubevirt.io/id for KubeVirt v1.7+ compatibility #3150
Conversation
|
@galkremer1: This pull request references CNV-71151 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: galkremer1 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughServices lookup and creation for RDP/SSH were made pod-aware: components fetch pods and derive pod-based label selectors; utility functions and service builders accept optional pod parameters and prefer pod-derived labels, with fallbacks to VMI/VM labels. Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant useVMIAndPodsForVM
participant getVMIPod
participant getVMILabelForServiceSelector
participant ServiceUtils
participant K8sAPI
rect rgb(240,248,255)
Note over Component,ServiceUtils: Pod-aware resolution flow
Component->>useVMIAndPodsForVM: request vmi + pods for VM
useVMIAndPodsForVM-->>Component: {vmi, pods}
Component->>getVMIPod: getVMIPod(vmi, pods)
getVMIPod-->>Component: pod (optional)
alt pod exists
Component->>getVMILabelForServiceSelector: derive {labelKey,labelValue} from pod
getVMILabelForServiceSelector-->>Component: {labelKey,labelValue}
Component->>ServiceUtils: find/create service with pod and selector
else no pod
Component->>ServiceUtils: find/create service using vmi/vm labels
end
ServiceUtils->>K8sAPI: create/patch Service, patch VM/VMI labels (using labelKey)
K8sAPI-->>ServiceUtils: result
ServiceUtils-->>Component: service created / port resolved
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧬 Code graph analysis (4)src/utils/resources/vmi/utils/tests/services.test.ts (1)
src/utils/components/SSHAccess/utils.ts (4)
src/utils/components/SSHAccess/components/SSHCommand.tsx (5)
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Comment |
|
@galkremer1: This pull request references CNV-71151 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (1)
8-8: Duplicate constant definition.This is the same duplication issue flagged in
src/utils/components/SSHAccess/constants.ts. Please consolidate to a single source of truth.
🧹 Nitpick comments (2)
src/utils/components/SSHAccess/components/SSHCommand.tsx (1)
49-50: Consider using the error and loaded states from useVMIAndPodsForVM.The hook returns
{ error, loaded, pods, vmi }but onlypodsandvmiare destructured. While the pod derivation logic will handle missing data gracefully, explicitly checkingerrororloadedcould provide better user feedback or prevent unnecessary operations when data is still loading or has failed to load.Consider this refactor if you want to add explicit error handling:
- const { pods, vmi } = useVMIAndPodsForVM(getName(vm), getNamespace(vm), getCluster(vm)); + const { pods, vmi, loaded: vmiAndPodsLoaded, error: vmiAndPodsError } = useVMIAndPodsForVM(getName(vm), getNamespace(vm), getCluster(vm)); const pod = getVMIPod(vmi, pods);Then you could use these states to conditionally render or handle errors.
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (1)
37-74: Verify consistency with getServicesForVmi matching logic.The
findVMServiceWithPortfunction implements pod-aware service matching with special handling forVMI_ID_LABEL(lines 59-61) andTEMPLATE_VM_NAME_LABEL(lines 64-66). This logic is similar but not identical to the matching logic ingetServicesForVmi(src/utils/resources/vmi/utils/services.ts, lines 86-97).Differences observed:
- Line 65: Falls back to
vmiName === selectorValueforTEMPLATE_VM_NAME_LABEL- The
getServicesForVmifunction has a more general approach that checks all selectors againstlabelsToMatchWhile both implementations appear correct for their specific contexts, having duplicate matching logic increases maintenance burden and the risk of inconsistency.
Consider refactoring to use a shared matching utility or ensuring both implementations stay aligned, especially if the backward compatibility logic needs to evolve.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
src/utils/components/Consoles/components/DesktopViewer/Components/RDPServiceModal.tsx(4 hunks)src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts(1 hunks)src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts(7 hunks)src/utils/components/SSHAccess/components/SSHCommand.tsx(4 hunks)src/utils/components/SSHAccess/constants.ts(1 hunks)src/utils/components/SSHAccess/useSSHService.tsx(2 hunks)src/utils/components/SSHAccess/utils.ts(3 hunks)src/utils/resources/vmi/utils/services.ts(1 hunks)src/utils/resources/vmi/utils/tests/services.test.ts(2 hunks)src/views/virtualmachines/details/tabs/overview/components/VirtualMachinesOverviewTabService/VirtualMachinesOverviewTabService.tsx(2 hunks)src/views/virtualmachinesinstance/details/tabs/details/components/Services/Services.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (11)
src/utils/components/SSHAccess/constants.ts (2)
src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (1)
VMI_ID_LABEL(8-8)src/utils/resources/vmi/utils/services.ts (1)
VMI_ID_LABEL(8-8)
src/views/virtualmachines/details/tabs/overview/components/VirtualMachinesOverviewTabService/VirtualMachinesOverviewTabService.tsx (3)
src/utils/resources/vm/hooks/useVMIAndPodsForVM.ts (1)
useVMIAndPodsForVM(14-37)src/multicluster/helpers/selectors.ts (1)
getCluster(6-7)src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
src/utils/components/SSHAccess/utils.ts (4)
src/utils/resources/vmi/utils/services.ts (1)
getVMILabelForServiceSelector(17-45)src/utils/components/SSHAccess/constants.ts (3)
VM_LABEL_AS_SSH_SERVICE_SELECTOR(6-6)PORT(3-3)SSH_PORT(4-4)src/utils/utils/utils.ts (1)
getRandomChars(73-78)src/utils/resources/shared.ts (1)
buildOwnerReference(157-167)
src/utils/components/SSHAccess/useSSHService.tsx (3)
src/utils/resources/vm/hooks/useVMIAndPodsForVM.ts (1)
useVMIAndPodsForVM(14-37)src/multicluster/helpers/selectors.ts (1)
getCluster(6-7)src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
src/utils/resources/vmi/utils/tests/services.test.ts (1)
src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
src/utils/components/SSHAccess/components/SSHCommand.tsx (4)
src/utils/resources/vm/hooks/useVMIAndPodsForVM.ts (1)
useVMIAndPodsForVM(14-37)src/multicluster/helpers/selectors.ts (1)
getCluster(6-7)src/utils/resources/vmi/utils/services.ts (1)
getVMILabelForServiceSelector(17-45)src/utils/components/SSHAccess/utils.ts (2)
addSSHSelectorLabelToVM(65-99)createSSHService(101-114)
src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (2)
src/utils/components/SSHAccess/constants.ts (1)
VMI_ID_LABEL(7-7)src/utils/resources/vmi/utils/services.ts (1)
VMI_ID_LABEL(8-8)
src/utils/resources/vmi/utils/services.ts (2)
src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (1)
VMI_ID_LABEL(8-8)src/utils/components/SSHAccess/constants.ts (1)
VMI_ID_LABEL(7-7)
src/utils/components/Consoles/components/DesktopViewer/Components/RDPServiceModal.tsx (1)
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (1)
createRDPService(259-329)
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (2)
src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (4)
VMI_ID_LABEL(8-8)TEMPLATE_VM_NAME_LABEL(2-2)DEFAULT_RDP_PORT(1-1)VMI_LABEL_AS_RDP_SERVICE_SELECTOR(7-7)src/utils/resources/vmi/utils/services.ts (2)
VMI_ID_LABEL(8-8)getVMILabelForServiceSelector(17-45)
src/views/virtualmachinesinstance/details/tabs/details/components/Services/Services.tsx (1)
src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: unit-test
- GitHub Check: i18n
- GitHub Check: build
🔇 Additional comments (16)
src/utils/components/SSHAccess/useSSHService.tsx (1)
27-36: LGTM! Pod-aware service resolution implemented correctly.The changes properly integrate pod context into SSH service discovery:
- Fetches VMI and pods using
useVMIAndPodsForVM- Derives the VM's pod via
getVMIPod- Passes pod context to
getServicesForVmifor label-based matchingThis enables support for the new
vmi.kubevirt.io/idlabel selector in KubeVirt v1.7+ while maintaining backward compatibility.src/views/virtualmachines/details/tabs/overview/components/VirtualMachinesOverviewTabService/VirtualMachinesOverviewTabService.tsx (1)
28-31: LGTM! Consistent pod-aware service resolution.The implementation correctly follows the same pattern as other components in this PR:
- Fetches VMI and pods
- Derives the VM's pod
- Uses pod labels for service matching
src/views/virtualmachinesinstance/details/tabs/details/components/Services/Services.tsx (1)
23-25: LGTM! Correct implementation for VMI context.The changes properly handle the VMI-only context (no VM reference available on this page). The fallback chain in
getServicesForVmiwill use pod labels when available, otherwise VMI labels.src/utils/components/Consoles/components/DesktopViewer/Components/RDPServiceModal.tsx (2)
32-33: LGTM! Pod context added to RDP service creation.The changes enable pod-aware label selection for RDP services, consistent with SSH service changes.
30-30: Minor naming improvement.Renaming
setCheckedtosetIsCheckedimproves clarity by aligning with the boolean state naming convention.src/utils/resources/vmi/utils/tests/services.test.ts (2)
13-59: Well-structured test helpers.The mock factory functions (
createMockPod,createMockVM,createMockVMI) provide clean, reusable test data construction.
112-152: Excellent test coverage for new functionality.The new test cases comprehensively verify:
vmi.kubevirt.io/idselector matching (KubeVirt v1.7+)- Fallback to VMI labels when pod unavailable
- Fallback to VM name when both pod and VMI unavailable
This ensures backward compatibility while supporting the new label selector.
src/utils/components/SSHAccess/utils.ts (2)
18-55: LGTM! Dynamic selector logic correctly implemented.The refactored
buildSSHServiceFromVMfunction now:
- Accepts an optional
podparameter- Uses
getVMILabelForServiceSelectorto derive the appropriate label key/value from pod context (prioritizingvmi.kubevirt.io/idwhen available)- Falls back to
vm.kubevirt.io/namewith VM name when pod unavailableThis enables KubeVirt v1.7+ compatibility while maintaining backward compatibility.
101-114: LGTM! Signature correctly updated.The
createSSHServicefunction signature properly propagates the optionalpodparameter through the service creation flow.src/utils/components/SSHAccess/components/SSHCommand.tsx (2)
62-64: LGTM! Proper fallback chain for label derivation.The logic correctly derives the labelValue from the pod when available (using
getVMILabelForServiceSelector) and falls back to the VM name otherwise. This aligns with the PR's goal of supporting both KubeVirt v1.7+ (withvmi.kubevirt.io/id) and older versions.
66-66: LGTM! Pod parameter correctly passed to createSSHService.The pod is now passed as the third argument to
createSSHService, enabling pod-based label selector logic in service creation.src/utils/resources/vmi/utils/services.ts (2)
17-45: LGTM! Well-structured label resolution with clear priority chain.The function correctly implements the priority chain:
vmi.kubevirt.io/idfrom pod (KubeVirt v1.7+)vm.kubevirt.io/namefrom pod (fallback)- VM name (ultimate fallback)
The inline comments clearly document the intent, and the logic handles missing pod gracefully.
60-78: LGTM! Comprehensive fallback chain for label matching.The priority chain for
labelsToMatchis well-structured:
- Pod labels (running VMs)
- VMI labels (when pod unavailable)
- VM template labels
- VM name (ultimate fallback)
This aligns with the PR's objectives to support both running and stopped VMs, with appropriate fallbacks at each level.
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (3)
79-79: LGTM! Pod parameter correctly threaded through the call chain.The pod parameter is properly passed from
findRDPServiceAndPort→findVMServiceWithPort, enabling pod-aware service matching for RDP services.
266-276: LGTM! Dynamic label selector construction with proper fallback.The logic correctly:
- Uses
getVMILabelForServiceSelector(pod, vm)when pod is available to get the optimal label (preferringvmi.kubevirt.io/id)- Falls back to
VMI_LABEL_AS_RDP_SERVICE_SELECTORwith VM template labels or VM name when pod is unavailableThis aligns with the PR's objectives for KubeVirt v1.7+ compatibility while maintaining backward compatibility.
282-282: LGTM! Correct JSON Pointer escaping for patch paths.The use of
replaceAll('/', '~1')correctly escapes forward slashes in the label key for JSON Patch paths according to RFC 6901 (JSON Pointer specification). This is necessary because label keys likevmi.kubevirt.io/idcontain forward slashes that must be escaped.Also applies to: 294-294
6606a21 to
7367b9d
Compare
|
@galkremer1: This pull request references CNV-71151 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/utils/components/SSHAccess/utils.ts (1)
65-98: addSSHSelectorLabelToVM must honor the selector key returned from the pod.
This helper still writes every update underVM_LABEL_AS_SSH_SERVICE_SELECTOR(vm.kubevirt.io/name). When the caller passes a pod-derived selector (vmi.kubevirt.io/id), we end up overwriting the VM/VMI “name” label with the pod’s ID and never set the actual selector key that the new Service expects. That breaks existing consumers ofvm.kubevirt.io/nameand leaves the Service selector unsatisfied for future pods. Please update the function (and its callers) to accept bothlabelKeyandlabelValue, and write them verbatim:-export const addSSHSelectorLabelToVM = async ( - vm: V1VirtualMachine, - vmi: V1VirtualMachineInstance, - labelValue, -) => { +export const addSSHSelectorLabelToVM = async ( + vm: V1VirtualMachine, + vmi: V1VirtualMachineInstance, + labelKey: string, + labelValue: string, +) => { const vmWithLabel = produce(vm, (draftVM) => { ensurePath(draftVM, 'spec.template.metadata.labels'); - draftVM.spec.template.metadata.labels[VM_LABEL_AS_SSH_SERVICE_SELECTOR] = labelValue; + draftVM.spec.template.metadata.labels[labelKey] = labelValue; }); if (vmi) { const vmiWithLabel = produce(vmi, (draftVMI) => { ensurePath(draftVMI, 'metadata.labels'); - draftVMI.metadata.labels[VM_LABEL_AS_SSH_SERVICE_SELECTOR] = labelValue; + draftVMI.metadata.labels[labelKey] = labelValue; });Make sure any remaining call sites pass the key as well so the VM/VMI labels stay in sync with the Service selector.
♻️ Duplicate comments (1)
src/utils/resources/vmi/utils/services.ts (1)
8-9: Centralize the VMI label constants.
We are still exportingVMI_ID_LABELandVM_NAME_LABELhere while DesktopViewer and SSHAccess carry identical definitions. Please extract these to a shared constants module (e.g.,src/utils/constants/vmiLabels.ts) and import them everywhere to avoid drift. Based on learnings.
🧹 Nitpick comments (1)
src/utils/resources/vmi/utils/tests/services.test.ts (1)
158-175: Add test case for VM template labels fallback.The fallback tests cover VMI labels (priority 2) and VM name (priority 4), but miss the VM template labels (priority 3) path. Consider adding a test where pod and VMI are undefined, but the VM has
spec.template.metadata.labelswith the matching label.Example test case:
it('Fallback to VM template labels when pod and VMI are not provided', () => { const services: IoK8sApiCoreV1Service[] = [serviceWithMatchingSelectors]; const vm: V1VirtualMachine = { ...createMockVM('fedora-proposed-rodent'), spec: { ...createMockVM('fedora-proposed-rodent').spec, template: { metadata: { labels: { 'vm.kubevirt.io/name': 'fedora-proposed-rodent' }, }, spec: { domain: { devices: {}, }, }, }, }, }; const result = getServicesForVmi(services, undefined, vm); expect(result).toEqual([serviceWithMatchingSelectors]); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/utils/components/Consoles/components/DesktopViewer/Components/RDPServiceModal.tsx(4 hunks)src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts(6 hunks)src/utils/components/SSHAccess/components/SSHCommand.tsx(4 hunks)src/utils/components/SSHAccess/useSSHService.tsx(2 hunks)src/utils/components/SSHAccess/utils.ts(3 hunks)src/utils/resources/vmi/utils/services.ts(1 hunks)src/utils/resources/vmi/utils/tests/services.test.ts(2 hunks)src/views/virtualmachines/details/tabs/overview/components/VirtualMachinesOverviewTabService/VirtualMachinesOverviewTabService.tsx(2 hunks)src/views/virtualmachinesinstance/details/tabs/details/components/Services/Services.tsx(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/views/virtualmachinesinstance/details/tabs/details/components/Services/Services.tsx
- src/utils/components/SSHAccess/useSSHService.tsx
🧰 Additional context used
🧬 Code graph analysis (6)
src/utils/components/Consoles/components/DesktopViewer/Components/RDPServiceModal.tsx (1)
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (1)
createRDPService(261-331)
src/utils/resources/vmi/utils/tests/services.test.ts (1)
src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
src/utils/components/SSHAccess/utils.ts (4)
src/utils/resources/vmi/utils/services.ts (1)
getVMILabelForServiceSelector(17-45)src/utils/components/SSHAccess/constants.ts (3)
VM_LABEL_AS_SSH_SERVICE_SELECTOR(6-6)PORT(3-3)SSH_PORT(4-4)src/utils/utils/utils.ts (1)
getRandomChars(73-78)src/utils/resources/shared.ts (1)
buildOwnerReference(157-167)
src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (2)
src/utils/resources/vmi/utils/services.ts (2)
VMI_ID_LABEL(8-8)getVMILabelForServiceSelector(17-45)src/utils/components/Consoles/components/DesktopViewer/utils/constants.ts (2)
DEFAULT_RDP_PORT(1-1)VMI_LABEL_AS_RDP_SERVICE_SELECTOR(7-7)
src/utils/components/SSHAccess/components/SSHCommand.tsx (4)
src/utils/resources/vm/hooks/useVMIAndPodsForVM.ts (1)
useVMIAndPodsForVM(14-37)src/multicluster/helpers/selectors.ts (1)
getCluster(6-7)src/utils/resources/vmi/utils/services.ts (1)
getVMILabelForServiceSelector(17-45)src/utils/components/SSHAccess/utils.ts (2)
addSSHSelectorLabelToVM(65-99)createSSHService(101-114)
src/views/virtualmachines/details/tabs/overview/components/VirtualMachinesOverviewTabService/VirtualMachinesOverviewTabService.tsx (3)
src/utils/resources/vm/hooks/useVMIAndPodsForVM.ts (1)
useVMIAndPodsForVM(14-37)src/multicluster/helpers/selectors.ts (1)
getCluster(6-7)src/utils/resources/vmi/utils/services.ts (1)
getServicesForVmi(54-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: unit-test
- GitHub Check: i18n
- GitHub Check: build
🔇 Additional comments (7)
src/utils/resources/vmi/utils/tests/services.test.ts (3)
13-59: LGTM! Clean and reusable mock helpers.The mock factory functions create minimal but complete objects that align well with the API types and support flexible test scenarios.
61-110: LGTM! Existing tests properly refactored.The existing test cases have been correctly updated to use the new API signature with pod and VM parameters while maintaining their original test intent.
112-156: LGTM! KubeVirt v1.7+ ID selector logic properly tested.These tests correctly verify the new
vmi.kubevirt.io/idselector matching with proper backward compatibility fallback tovm.kubevirt.io/name.src/utils/components/Consoles/components/DesktopViewer/utils/utils.ts (4)
39-76: Clarify the VMI name fallback logic forvm.kubevirt.io/nameselector.At line 67, when the service selector uses
vm.kubevirt.io/name, the code falls back to checkingvmiNamedirectly:if (key === TEMPLATE_VM_NAME_LABEL) { return labelValue === selectorValue || vmiName === selectorValue; }This differs from
getServicesForVmiinservices.ts, which uses the full priority chain (pod labels → VMI labels → VM template labels → VM name) without special fallback logic forvm.kubevirt.io/name. The direct VMI name fallback here bypasses the standard chain.Questions:
- Is this VMI name fallback intentional for RDP-specific backward compatibility?
- Could this cause false positives if the VMI name happens to match the selector but the pod labels don't?
Consider documenting this behavior if intentional, or aligning with the
services.tspriority chain if not.
78-138: LGTM! Pod parameter properly threaded through the call chain.The optional
podparameter is correctly passed fromgetRdpAddressPortthroughfindRDPServiceAndPorttofindVMServiceWithPort, enabling pod-aware service matching for RDP connections.
261-331: LGTM! Dynamic label selector properly implemented.The
createRDPServicefunction correctly usesgetVMILabelForServiceSelectorwhen a pod is available to prefervmi.kubevirt.io/id, with appropriate fallback tovm.kubevirt.io/namefrom template labels or VM name. The JSON patch path escaping (replaceAll('/', '~1')) correctly follows RFC 6901.
16-19: LGTM! Imports properly added.The new imports for
getVMILabelForServiceSelectorandVMI_ID_LABELare correctly added and used throughout the file to support pod-aware service selection.
…or KubeVirt v1.7+ compatibility
7367b9d to
da9afd5
Compare
|
@galkremer1: This pull request references CNV-71151 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/retest |
📝 Description
Adds VMI labels as a fallback in
getServicesForVmito improve service matching when pods are unavailable.KubeVirt v1.7+ introduces
vmi.kubevirt.io/idon pods for service matching. Labels likevm.kubevirt.io/namecan also exist on the VMI resource (e.g., manually set or inherited from templates).Checking VMI labels ensures matching when the pod is not available (stopped VMs, etc.).
Jira ticket: CNV-71151
KubeVirt PR #15783 introducing the change
🎥 Demo
In addition to adding the support for the new selector (
vmi.kubevirt.io/id), this PR also fixes a bug where the services are not listed under the VMI:Before:
Before.mov
After:
After.mov
Summary by CodeRabbit
Bug Fixes
Refactor
Tests