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

AV-228204 do not add is_federated everytime in uri #269

Merged
merged 1 commit into from
Jan 28, 2025
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
6 changes: 3 additions & 3 deletions gslb/cache/controller_obj_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ func (h *AviHmCache) AviHmCachePopulate(client *clients.AviClient,

func (h *AviHmCache) AviHmObjCachePopulate(client *clients.AviClient, hmname ...string) error {
var nextPageURI string
uri := "/api/healthmonitor?include_name&page_size=100"
uri := "/api/healthmonitor?include_name&page_size=100&is_federated=true"

matchCreatedBy := gslbutils.AMKOControlConfig().CreatedByField()

// parse all pages with Health monitors till we hit the last page
for {
if len(hmname) == 1 {
uri = "/api/healthmonitor?name=" + hmname[0]
uri = "/api/healthmonitor?name=" + hmname[0] + "&is_federated=true"
} else if nextPageURI != "" {
uri = nextPageURI
}
Expand All @@ -183,7 +183,7 @@ func (h *AviHmCache) AviHmObjCachePopulate(client *clients.AviClient, hmname ...
// 3. HMs created by other AMKO instances
// Category 1 and 2 HMs are the ones that we need to store in the cache. Category 3 HMs
// must be ignored and not stored in the HM cache.
result, err := gslbutils.GetUriFromAvi(uri+"&is_federated=true", client, false)
result, err := gslbutils.GetUriFromAvi(uri, client, false)
if err != nil {
return errors.New("object: AviCache, msg: HealthMonitor get URI " + uri + " returned error: " + err.Error())
}
Expand Down
23 changes: 13 additions & 10 deletions gslb/gslbutils/gslbutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,25 @@ func GetTenant() string {
}

func GetTenantInNamespace(namespace, cname string) string {
tenant, exists := store.GetNamespaceToTenantStore().GetNSObjectByName(cname, namespace)
if !exists {
utils.AviLog.Warnf("Failed to GET the namespace details falling back to the default tenant, cluster: %s, namespace: %s", cname, namespace)
return GetTenant()
}
if tenant.(string) == "" {
tenant := GetTenantInNamespaceAnnotation(namespace, cname)
if tenant == "" {
return GetTenant()
}
return tenant.(string)
return tenant
}

func GetTenantInNamespaceAnnotation(namespace, cname string) string {
tenant, exists := store.GetNamespaceToTenantStore().GetNSObjectByName(cname, namespace)
namespaceTenantStore := store.GetNamespaceToTenantStore()
tenant, exists := namespaceTenantStore.GetNSObjectByName(cname, namespace)
if !exists {
utils.AviLog.Warnf("Failed to GET the namespace details falling back to the default tenant, cluster: %s, namespace: %s", cname, namespace)
return GetTenant()
nsObj, err := GetInformersPerCluster(cname).ClientSet.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{})
if err != nil {
utils.AviLog.Errorf("Failed to GET the namespace details falling back to the default tenant, cluster: %s, namespace: %s", cname, namespace)
return GetTenant()
}
tenant, _ := nsObj.Annotations[TenantAnnotation]
namespaceTenantStore.AddOrUpdate(cname, namespace, tenant)
return tenant
}
return tenant.(string)
}
Expand Down
Loading