@@ -1136,11 +1136,23 @@ func getComputeNodesConnectionInfo(
11361136 if err != nil {
11371137 return []ConnectionInfo {}, err
11381138 }
1139- nodeSetGroup := inventory .Groups [secret .Labels ["openstackdataplanenodeset" ]]
1139+ nodeSetName , exists := secret .Labels ["openstackdataplanenodeset" ]
1140+ if ! exists {
1141+ continue // Skip this secret if it doesn't have the required label
1142+ }
1143+ nodeSetGroup , exists := inventory .Groups [nodeSetName ]
1144+ if ! exists {
1145+ continue // Skip if the group doesn't exist in inventory
1146+ }
11401147 containsTargetService := false
1141- for _ , svc := range nodeSetGroup .Vars ["edpm_services" ].([]interface {}) {
1142- if svc .(string ) == telemetryServiceName {
1143- containsTargetService = true
1148+ if services , ok := nodeSetGroup .Vars ["edpm_services" ].([]interface {}); ok {
1149+ for _ , svc := range services {
1150+ if svcStr , ok := svc .(string ); ok {
1151+ if svcStr == telemetryServiceName {
1152+ containsTargetService = true
1153+ break
1154+ }
1155+ }
11441156 }
11451157 }
11461158 if ! containsTargetService {
@@ -1214,7 +1226,11 @@ func getAddressFromIPSet(
12141226 item * ansible.Host ,
12151227 helper * helper.Helper ,
12161228) (string , discoveryv1.AddressType ) {
1217- ansibleHost := item .Vars ["ansible_host" ].(string )
1229+ ansibleHost , ok := item .Vars ["ansible_host" ].(string )
1230+ if ! ok {
1231+ helper .GetLogger ().Info ("ansible_host is not a string or is missing" )
1232+ return "" , ""
1233+ }
12181234 canonicalHostname , _ := getCanonicalHostname (item )
12191235 ctlplaneDNSDomain := ""
12201236
@@ -1247,15 +1263,15 @@ func getAddressFromIPSet(
12471263 return ansibleHost , discoveryv1 .AddressTypeFQDN
12481264 }
12491265 // No IP address or valid hostname found anywhere
1250- helper .GetLogger ().Info ("Did not found a valid hostname or IP address" )
1266+ helper .GetLogger ().Info ("Did not find a valid hostname or IP address" )
12511267 return "" , ""
12521268 }
12531269 }
12541270 // check that the reservations list is not empty
12551271 if len (ipset .Status .Reservation ) > 0 {
12561272 // search for the network specified in the Spec
12571273 for _ , reservation := range ipset .Status .Reservation {
1258- if reservation .Network == * instance .Spec .DataplaneNetwork {
1274+ if instance . Spec . DataplaneNetwork != nil && reservation .Network == * instance .Spec .DataplaneNetwork {
12591275 return reservation .Address , discoveryv1 .AddressTypeIPv4
12601276 }
12611277 }
@@ -1265,7 +1281,10 @@ func getAddressFromIPSet(
12651281}
12661282
12671283func getAddressFromAnsibleHost (item * ansible.Host ) (string , discoveryv1.AddressType ) {
1268- ansibleHost := item .Vars ["ansible_host" ].(string )
1284+ ansibleHost , ok := item .Vars ["ansible_host" ].(string )
1285+ if ! ok {
1286+ return "" , ""
1287+ }
12691288 // check if ansiblehost is an IP
12701289 addr := net .ParseIP (ansibleHost )
12711290 if addr != nil {
0 commit comments