Skip to content

Commit 782d50d

Browse files
committed
fix(virtual-machine): guard Kube-OVN IP lookup
Assisted-By: GPT-5 <[email protected]> Signed-off-by: Loïc Fontaine <[email protected]>
1 parent dc2e427 commit 782d50d

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎packages/apps/vm-instance/templates/vm.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ spec:
3535
metadata:
3636
annotations:
3737
kubevirt.io/allow-pod-bridge-network-live-migration: "true"
38+
{{- if .Capabilities.APIVersions.Has "kubeovn.io/v1/IP" }}
3839
{{- $ovnIPName := printf "%s.%s" (include "virtual-machine.fullname" .) .Release.Namespace }}
3940
{{- $ovnIP := lookup "kubeovn.io/v1" "IP" "" $ovnIPName }}
4041
{{- if $ovnIP }}
4142
ovn.kubernetes.io/mac_address: {{ $ovnIP.spec.macAddress | quote }}
4243
ovn.kubernetes.io/ip_address: {{ $ovnIP.spec.ipAddress | quote }}
4344
{{- end }}
45+
{{- end }}
4446
labels:
4547
{{- include "virtual-machine.labels" . | nindent 8 }}
4648
spec:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
suite: vm-instance supports clusters without Kube-OVN
2+
3+
release:
4+
name: test-vm
5+
namespace: tenant-test
6+
templates:
7+
- templates/vm.yaml
8+
capabilities:
9+
apiVersions: []
10+
set:
11+
fullnameOverride: test-vm
12+
instanceType: ""
13+
instanceProfile: ""
14+
resources:
15+
cpu: 1
16+
sockets: 1
17+
memory: 1Gi
18+
_cluster:
19+
scheduling:
20+
dedicatedNodesForWindowsVMs: "false"
21+
tests:
22+
- it: renders a VirtualMachine without Kube-OVN annotations
23+
asserts:
24+
- isKind:
25+
of: VirtualMachine
26+
- notExists:
27+
path: spec.template.metadata.annotations["ovn.kubernetes.io/mac_address"]
28+
- notExists:
29+
path: spec.template.metadata.annotations["ovn.kubernetes.io/ip_address"]

0 commit comments

Comments
 (0)