Skip to content

Commit 6ef77a8

Browse files
authored
Merge pull request #4392 from Azure/bvesel/check-for-nil-properties-subnet
monitor: check that the subnet response doesn't include a nil properties
2 parents 335dbba + 63fa62d commit 6ef77a8

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pkg/monitor/cluster/cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
3333
"github.com/Azure/ARO-RP/pkg/operator/clientset/versioned/scheme"
3434
"github.com/Azure/ARO-RP/pkg/util/clienthelper"
35+
"github.com/Azure/ARO-RP/pkg/util/recover"
3536
"github.com/Azure/ARO-RP/pkg/util/steps"
3637
"github.com/Azure/ARO-RP/pkg/util/version"
3738
)
@@ -262,6 +263,7 @@ func (mon *Monitor) Monitor(ctx context.Context) error {
262263

263264
for _, f := range mon.collectors {
264265
wg.Go(func() error {
266+
defer recover.Panic(mon.log)
265267
innerErr := mon.timeCall(ctx, f)
266268
if innerErr != nil {
267269
// NOTE: The channel only has room to accommodate one error per

pkg/monitor/cluster/clusterwideproxystatus.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,27 @@ func (mon *Monitor) emitCWPStatus(ctx context.Context) error {
120120

121121
// Check worker profiles
122122
for _, workerProfile := range mon.oc.Properties.WorkerProfiles {
123-
workersubnetID, err := azure.ParseResourceID(workerProfile.SubnetID)
123+
workerSubnetResource, err := azure.ParseResourceID(workerProfile.SubnetID)
124124
if err != nil {
125-
mon.log.Errorf("failed to parse the workersubnetID: %v", err)
125+
mon.log.Errorf("failed to parse the subnetID '%s': %v", workerProfile.SubnetID, err)
126126
return err
127127
}
128-
workerVnetID, _, err := apisubnet.Split(workerProfile.SubnetID)
128+
vnetId, _, err := apisubnet.Split(workerProfile.SubnetID)
129129
if err != nil {
130-
mon.log.Errorf("failed to feth the workerVnetID: %v", err)
130+
mon.log.Errorf("failed to fetch the virtual network: %v", err)
131131
return err
132132
}
133-
workervnetId, err := azure.ParseResourceID(workerVnetID)
133+
vnetResource, err := azure.ParseResourceID(vnetId)
134134
if err != nil {
135-
mon.log.Errorf("failed to parse the workerVnetID: %v", err)
135+
mon.log.Errorf("failed to parse the vnet resource ID '%s': %v", vnetId, err)
136136
return err
137137
}
138-
workerres, err := clientFactory.NewSubnetsClient().Get(ctx, workersubnetID.ResourceGroup, workervnetId.ResourceName, workersubnetID.ResourceName, &armnetwork.SubnetsClientGetOptions{Expand: nil})
138+
workerSubnetResponse, err := clientFactory.NewSubnetsClient().Get(ctx, workerSubnetResource.ResourceGroup, vnetResource.ResourceName, workerSubnetResource.ResourceName, &armnetwork.SubnetsClientGetOptions{Expand: nil})
139139
if err != nil {
140140
mon.log.Errorf("failed to finish the request: %v", err)
141141
}
142-
if workerres.Properties.AddressPrefix != nil {
143-
workermachinesCIDR := *workerres.Properties.AddressPrefix
142+
if workerSubnetResponse.Properties != nil && workerSubnetResponse.Properties.AddressPrefix != nil {
143+
workermachinesCIDR := *workerSubnetResponse.Properties.AddressPrefix
144144
if !noProxyMap[workermachinesCIDR] {
145145
missing_no_proxy_list = append(missing_no_proxy_list, workermachinesCIDR)
146146
}
@@ -210,7 +210,7 @@ func (mon *Monitor) emitCWPStatus(ctx context.Context) error {
210210
// Infrastructure Configuration Check
211211
infraConfig, err := mon.configcli.ConfigV1().Infrastructures().Get(ctx, cluster, metav1.GetOptions{})
212212
if err != nil {
213-
mon.log.Errorf("Error in getting Infrasturcture info: %v", err)
213+
mon.log.Errorf("Error in getting Infrastructure info: %v", err)
214214
return err
215215
}
216216

0 commit comments

Comments
 (0)