Skip to content

Commit

Permalink
fix: [CCM-9806]: cache re-population fixed
Browse files Browse the repository at this point in the history
fix: [CCM-9806]: cache re-population fixed
  • Loading branch information
Trunapushpa authored Jan 12, 2024
2 parents c68cfb2 + 3153a70 commit 1513588
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/app/cloudinfo/cistore/go-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func (cis *cacheProductStore) DeleteVm(provider, service, region string) {
}

func (cis *cacheProductStore) StoreServices(provider string, services []types.Service) {
cis.Set(cis.getKey(cloudinfo.ServicesKeyTemplate, provider), services, cis.itemExpiry)
// Service info never expires hence -1 expiry.
// With expiry set cache doesn't get repopulated because service info is the basic info that is always required
cis.Set(cis.getKey(cloudinfo.ServicesKeyTemplate, provider), services, -1)
}

func (cis *cacheProductStore) GetServices(provider string) ([]types.Service, bool) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cloudinfo/providers/azure/cloudinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"emperror.dev/emperror"
"emperror.dev/errors"
Expand Down Expand Up @@ -209,7 +210,11 @@ func (a *AzureInfoer) Initialize() (map[string]map[string]types.Price, error) {
}

rateCardFilter := "OfferDurableId eq 'MS-AZR-0003p' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'"
// ResourceRateCardInfo is a huge object, it takes around 3-5 minutes to fetch this
startTime := time.Now()
a.log.Info("Fetching Azure ResourceRateCardInfo")
result, err := a.rateCardClient.Get(context.TODO(), rateCardFilter)
a.log.Info("Fetched Azure ResourceRateCardInfo", map[string]interface{}{"minutesTaken": time.Since(startTime).Minutes()})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.10400
version=1.0.10401

0 comments on commit 1513588

Please sign in to comment.