Skip to content

Commit

Permalink
kubevirt: dont create ssh service when using multus on primary nic
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jul 26, 2024
1 parent 16a8797 commit 44f0d5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kubevirt_infra: master
kubevirt_workloads: worker
kubevirt_ovs: false
kubevirt_featuregates: []
kubevirt_featuregates: [VMLiveUpdateFeatures]
kubevirt_tekton: false
kubevirt_tekton_namespace: default
6 changes: 3 additions & 3 deletions kvirt/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,15 +1493,15 @@ def _ssh_credentials(k, name):
user, ip, status = info.get('user', 'root'), info.get('ip'), info.get('status')
if status in ['down', 'suspended', 'unknown']:
error(f"{name} down")
if 'nodeport' in info:
if 'loadbalancerip' in info:
ip = info['loadbalancerip']
elif 'nodeport' in info:
vmport = info['nodeport']
nodehost = info.get('host')
ip = k.node_host(name=nodehost)
if ip is None:
warning(f"Connecting to {name} using node fqdn")
ip = nodehost
elif 'loadbalancerip' in info:
ip = info['loadbalancerip']
if ip is None:
error(f"No ip found for {name}")
return user, ip, vmport
Expand Down
11 changes: 7 additions & 4 deletions kvirt/providers/kubevirt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
metadata={}, securitygroups=[], vmuser=None):
owners = []
container_disk = overrides.get('container_disk', False)
guestagent = False
guest_agent = False
need_ssh_service = not tunnel and self.access_mode != 'External'
if self.exists(name):
return {'result': 'failure', 'reason': f"VM {name} already exists"}
if image is not None:
Expand Down Expand Up @@ -313,7 +314,9 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
return {'result': 'failure', 'reason': f"network {netname} not found"}
else:
newnet['multus'] = {'networkName': netname}
guestagent = True
guest_agent = True
if index == 0:
need_ssh_service = False
else:
newnet['pod'] = {}
interfaces.append(newif)
Expand Down Expand Up @@ -401,7 +404,7 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
vm['spec']['template']['spec']['domain']['devices']['disks'].append(newdisk)
vm['spec']['template']['spec']['volumes'].append(myvolume)
cloudinit = False
if guestagent:
if guest_agent:
gcmds = []
if image is not None and common.need_guest_agent(image):
gcmds.append('yum -y install qemu-guest-agent')
Expand Down Expand Up @@ -532,7 +535,7 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
'spec': {'selector': {'subdomain': newdomain}, 'clusterIP': 'None',
'ports': [{'name': 'foo', 'port': 1234, 'targetPort': 1234}]}}
core.create_namespaced_service(namespace, dnsspec)
if not tunnel and self.access_mode != 'External':
if need_ssh_service:
try:
core.read_namespaced_service(f'{name}-ssh', namespace)
except:
Expand Down

0 comments on commit 44f0d5d

Please sign in to comment.