Skip to content

Commit

Permalink
openshift: use smarter logic to get coredns ip
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Oct 23, 2024
1 parent 5914db5 commit 1f6e394
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kvirt/cluster/openshift/99-forcedns
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ fi

if [ "$2" = "dhcp4-change" ] || [ "$2" = "dhcp6-change" ] || [ "$2" = "up" ] || [ "$2" = "connectivity-change" ]; then
sleep 2
IP=$(/bin/hostname -I | awk '{print $1}')
NIC={{ "$(ip -6 r | grep -v lo | head -1 | grep -oP '(?<=dev )[^ ]*')" if ipv6 else "$(ip r | grep default | head -1 | grep -oP '(?<=dev )[^ ]*')" }}
IP={{ "$(ip -o -f inet6 addr show $NIC | head -1 | grep -oP '(?<=inet6 )[^ ]*' | cut -d '/' -f 1)" if ipv6 else "$(ip -o -f inet addr show $NIC | head -1 | grep -oP '(?<=inet )[^ ]*' | cut -d '/' -f 1)" }}
if [ "$IP" != "" ] ; then
grep -q $IP /etc/resolv.conf
if [ "$?" != "0" ] ; then
Expand Down
2 changes: 1 addition & 1 deletion kvirt/providers/kvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
nic = nets[index].get('nic', 'ens3')
if needs_ignition and ip is not None and netmask is not None and gateway is not None:
nameservers = [nameserver] if isinstance(nameserver, str) else nameserver
nameservers = ' '.join([f"nameserver={nameserver}" for name in nameservers])
nameservers = ' '.join([f"nameserver={name}" for name in nameservers])
warning("Injecting static networking via cmdline")
cmdline = f'ip={ip}::{gateway}:{netmask}::{nic}:none {nameservers}'
del nets[index]['ip']
Expand Down

0 comments on commit 1f6e394

Please sign in to comment.