Skip to content

Commit 30a4074

Browse files
Challa ReddyHarness
authored andcommitted
fix: [CCM-32115]: Updated error log handing for errors while scraping (#47)
* 201a0a fix: [CCM-32115]: Using logger with fields * f23259 fix: [CCM-32115]: Restricting fetching price for the me-south-1 reagion due to middle-ease crisis * 3a3ef1 fix: [CCM-32115]: Updated error log handing for errors while scraping
1 parent 3eb0485 commit 30a4074

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

internal/cloudinfo/providers/amazon/cloudinfo.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ import (
3939
)
4040

4141
const (
42-
svcEks = "eks"
43-
svcPKE = "pke"
42+
svcEks = "eks"
43+
svcPKE = "pke"
44+
restrictedRegion = "me-south-1"
4445
)
4546

4647
// Ec2Infoer encapsulates the data and operations needed to access external resources
@@ -512,6 +513,10 @@ func (e *Ec2Infoer) getCurrentSpotPrices(region string) (map[string]types.SpotPr
512513

513514
// GetCurrentPrices returns the current spot prices of every instance type in every availability zone in a given region
514515
func (e *Ec2Infoer) GetCurrentPrices(region string) (map[string]types.Price, error) {
516+
if region == restrictedRegion {
517+
log.WithFields(e.log, map[string]any{"region": region}).Info("skipping region due to connectivity restrictions")
518+
return nil, nil
519+
}
515520
logger := log.WithFields(e.log, map[string]interface{}{"region": region})
516521
var spotPrices map[string]types.SpotPriceInfo
517522
var err error
@@ -526,7 +531,6 @@ func (e *Ec2Infoer) GetCurrentPrices(region string) (map[string]types.Price, err
526531
logger.Debug("getting current spot prices directly from the AWS API")
527532
spotPrices, err = e.getCurrentSpotPrices(region)
528533
if err != nil {
529-
logger.Error("failed to retrieve current spot prices")
530534
return nil, err
531535
}
532536
}

internal/cloudinfo/scrape.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ func (sm *scrapingManager) scrapeServiceInformation(ctx context.Context) {
250250

251251
err := sm.scrapeServiceRegionInfo(ctx, storedServices)
252252
if err != nil {
253-
sm.log.Error("failed to load service region information")
254-
sm.errorHandler.Handle(err)
255253
return
256254
}
257255

@@ -266,8 +264,7 @@ func (sm *scrapingManager) scrapePricesInRegion(ctx context.Context, region stri
266264
prices, err := sm.infoer.GetCurrentPrices(region)
267265
if err != nil {
268266
sm.metrics.ReportScrapeShortLivedFailure(sm.provider, region)
269-
sm.log.Error("failed to scrape spot prices in region")
270-
sm.errorHandler.Handle(err)
267+
sm.log.WithFields(map[string]interface{}{"error": err, "provider": sm.provider, "region": region}).Error("failed to scrape spot prices in region")
271268
}
272269

273270
for instType, price := range prices {
@@ -288,8 +285,7 @@ func (sm *scrapingManager) scrapePricesInAllRegions(ctx context.Context) {
288285
start := time.Now()
289286
regions, err := sm.infoer.GetRegions("compute")
290287
if err != nil {
291-
sm.log.Error("failed to retrieve regions")
292-
sm.errorHandler.Handle(err)
288+
sm.log.WithFields(map[string]interface{}{"error": err, "provider": sm.provider}).Error("failed to retrieve regions")
293289
}
294290

295291
for regionId := range regions {

0 commit comments

Comments
 (0)