From 002ceb723299286b943185486ff765b6cef999d3 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Fri, 11 Feb 2022 20:26:28 +0100 Subject: [PATCH] Fix panic in Azure SD when no public interface is set. Signed-off-by: Julien Pivotto --- discovery/azure/azure.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discovery/azure/azure.go b/discovery/azure/azure.go index 4a70416bb..d668a5a2b 100644 --- a/discovery/azure/azure.go +++ b/discovery/azure/azure.go @@ -361,7 +361,9 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { if *networkInterface.Primary { for _, ip := range *networkInterface.IPConfigurations { - if ip.PublicIPAddress != nil && ip.PublicIPAddress.IPAddress != nil { + // IPAddress is a field defined in PublicIPAddressPropertiesFormat, + // therefore we need to validate that both are not nil. + if ip.PublicIPAddress != nil && ip.PublicIPAddress.PublicIPAddressPropertiesFormat != nil && ip.PublicIPAddress.IPAddress != nil { labels[azureLabelMachinePublicIP] = model.LabelValue(*ip.PublicIPAddress.IPAddress) } if ip.PrivateIPAddress != nil {