@@ -107,22 +107,28 @@ func (cp *CloudProvider) NodeAddressesByProviderID(ctx context.Context, provider
107107 return nil , err
108108 }
109109 addresses = append (addresses , vnicAddresses ... )
110- hostname := vnic .HostnameLabel
111- if * hostname == "" {
112- cp .logger .With ("instanceID" , providerID ).Debug ("hostname not set, instance won't be resolvable using using the Internet and VCN Resolver" )
113- return addresses , nil
114- }
115- subnet , err := cp .client .Networking ().GetSubnet (ctx , * vnic .SubnetId )
116- if err != nil {
117- return nil , errors .Wrap (err , "GetSubnetForInstance" )
118- }
119- vcn , err := cp .client .Networking ().GetVcn (ctx , * subnet .VcnId )
120- if err != nil {
121- return nil , errors .Wrap (err , "GetVcnForInstance" )
110+
111+ if vnic != nil {
112+ hostname := vnic .HostnameLabel
113+ if hostname != nil && * hostname != "" {
114+ subnet , err := cp .client .Networking ().GetSubnet (ctx , * vnic .SubnetId )
115+ if err != nil {
116+ return nil , errors .Wrap (err , "GetSubnetForInstance" )
117+ }
118+ if subnet != nil && * subnet .DnsLabel != "" {
119+ vcn , err := cp .client .Networking ().GetVcn (ctx , * subnet .VcnId )
120+ if err != nil {
121+ return nil , errors .Wrap (err , "GetVcnForInstance" )
122+ }
123+ if vcn != nil && * vcn .DnsLabel != "" {
124+ fqdn := strings .Join ([]string {* hostname , * subnet .DnsLabel , * vcn .DnsLabel , "oraclevcn.com" }, "." )
125+ addresses = append (addresses , api.NodeAddress {Type : api .NodeHostName , Address : fqdn })
126+ addresses = append (addresses , api.NodeAddress {Type : api .NodeInternalDNS , Address : fqdn })
127+ }
128+ }
129+ }
122130 }
123- fqdn := strings .Join ([]string {* hostname , * subnet .DnsLabel , * vcn .DnsLabel , "oraclevcn.com" }, "." )
124- addresses = append (addresses , api.NodeAddress {Type : api .NodeHostName , Address : fqdn })
125- addresses = append (addresses , api.NodeAddress {Type : api .NodeInternalDNS , Address : fqdn })
131+
126132 return addresses , nil
127133}
128134
0 commit comments