Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [CCM-9806]: cache re-population fixed #681

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading