Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
fix(loadbalancer): prevent nil pointer by error handling (#138)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Giese <[email protected]>
  • Loading branch information
seanschneeweiss and tobiasgiese authored Jan 3, 2024
1 parent c9b22bd commit 985f6de
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/metrics/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,20 @@ func PublishLoadBalancerMetrics(client *gophercloud.ServiceClient, tenantID stri

// for the pools associated with the loadbalancer
for _, poolWithOnlyId := range lb.Pools {
pool, _ := pools.Get(client, poolWithOnlyId.ID).Extract()
pool, err := pools.Get(client, poolWithOnlyId.ID).Extract()
if err != nil {
klog.Warningf("Unable to get pool %s: %v", poolWithOnlyId.ID, err)
continue
}
publishPoolStatus(lb, *pool)

// for the pool members
for _, memberWithOnlyId := range pool.Members {
member, _ := pools.GetMember(client, pool.ID, memberWithOnlyId.ID).Extract()
member, err := pools.GetMember(client, pool.ID, memberWithOnlyId.ID).Extract()
if err != nil {
klog.Warningf("Unable to get member %s of pool %s: %v", memberWithOnlyId.ID, poolWithOnlyId.ID, err)
continue
}
publishMemberStatus(lb, *pool, *member)
}
}
Expand Down

0 comments on commit 985f6de

Please sign in to comment.