Skip to content

Commit dbee35f

Browse files
Merge pull request #28420 from xueqzhan/azure-metrics-throttling
TRT-1359: Ignore azure interaction errors since they are not fatal for our usage
2 parents 018cc39 + 8963c37 commit dbee35f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/monitortests/cloud/azure/metrics/monitortest.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ func fetchExtrenuousMetrics(ctx context.Context, allVMs []string, client *armmon
135135
return ret, nil
136136
}
137137

138+
// CollectData collects azure metrics. Since azure metrics are collected to facilitate debugging, some errors (like cloud throttling) are not considered fatal.
139+
// We will simply log the error and return nil to the caller.
138140
func (w *azureMetricsCollector) CollectData(ctx context.Context, storageDir string, beginning, end time.Time) (monitorapi.Intervals, []*junitapi.JUnitTestCase, error) {
139141
// Only collect if we are on azure
140142
oc := exutil.NewCLI("cloudmetrics").AsAdmin()
@@ -175,17 +177,19 @@ func (w *azureMetricsCollector) CollectData(ctx context.Context, storageDir stri
175177
}
176178
clientFactory, err := armmonitor.NewClientFactory(subscriptionID, cred, nil)
177179
if err != nil {
178-
return nil, nil, fmt.Errorf("failed to create azure metric client: %v", err)
180+
logrus.WithError(err).Error("failed to create azure metric client")
181+
return nil, nil, nil
179182
}
180183
client := clientFactory.NewMetricsClient()
181184

182185
intervals, err := fetchExtrenuousVMMetrics(ctx, oc, client, subscriptionID, resourceGroup, beginning)
183186
if err != nil {
184-
return nil, nil, err
187+
logrus.WithError(err).Error("failed to fetch azure metrics")
188+
return nil, nil, nil
185189
}
186190
ret = append(ret, intervals...)
187191

188-
return ret, nil, err
192+
return ret, nil, nil
189193
}
190194

191195
func (*azureMetricsCollector) ConstructComputedIntervals(ctx context.Context, startingIntervals monitorapi.Intervals, recordedResources monitorapi.ResourcesMap, beginning, end time.Time) (monitorapi.Intervals, error) {

0 commit comments

Comments
 (0)