From f4b0b616164b254ec11944a201d15fdd2cd83945 Mon Sep 17 00:00:00 2001 From: Matthew Arnold Date: Fri, 20 Dec 2024 10:47:08 -0500 Subject: [PATCH] Avoid nil dereference on IP stack DNS. Signed-off-by: Matthew Arnold --- pkg/controller/provider/container/vsphere/model.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/controller/provider/container/vsphere/model.go b/pkg/controller/provider/container/vsphere/model.go index c09c53b8a..1c40ba047 100644 --- a/pkg/controller/provider/container/vsphere/model.go +++ b/pkg/controller/provider/container/vsphere/model.go @@ -685,10 +685,14 @@ func (v *VmAdapter) Apply(u types.ObjectUpdate) { for _, ipa := range ipas.GuestStackInfo { routes := ipa.IpRouteConfig.IpRoute for _, route := range routes { + var dnsList []string + if ipa.DnsConfig != nil { + dnsList = ipa.DnsConfig.IpAddress + } if len(route.Gateway.IpAddress) > 0 { guestIpStackList = append(guestIpStackList, model.GuestIpStack{ Gateway: route.Gateway.IpAddress, - DNS: ipa.DnsConfig.IpAddress, + DNS: dnsList, }) } }