Open kylinsoong opened 1 month ago
Samiliar requirements in getEndpointForHub:
func (appMgr *Manager) getEndpointsForHubMode(svcName, svcNamespace string, isTenantNameServiceNamespace bool) (*v1.Endpoints, error) {
var eps *v1.Endpoints
if isTenantNameServiceNamespace {
if appInf, infFound := appMgr.getNamespaceInformer(svcNamespace); infFound {
if item, found, _ := appInf.endptInformer.GetStore().GetByKey(svcNamespace + "/" + svcName); found {
eps, _ = item.(*v1.Endpoints)
}
return eps, nil
}
}
// Leaving the old way for hubMode for now.
endpointsList, err := appMgr.kubeClient.CoreV1().Endpoints(svcNamespace).List(context.TODO(),
metav1.ListOptions{
FieldSelector: "metadata.name=" + svcName,
},
)
if err != nil {
return nil, err
}
if len(endpointsList.Items) == 0 {
return eps, nil
}
eps = &endpointsList.Items[0]
return eps, nil
}
@kylinsoong , As in the hubmode services can exist in any namespace other-than the configMap namespace hence, we need to query using kube-api server, as informer may or may not exist for the namespace, where service is residing.
If you use isTenantNameServiceNamespace label, it will use the informers and if informers are not found than fall back to kube-api server query.
Thanks @vklohiya, can we use the similar logic in appMgr's syncConfigMaps?
Currently only AS3 Manager get GetEndpoints use the IsTenantNameServiceNamespace, however the APP Manager get GetEndpoints passed false, which thoughts the IsTenantNameServiceNamespace is not set.
On the other side, periodicly syn virtual server are always against the service that has watched with informer referenced.
members, err := appMgr.getEndpoints(selector, sKey.Namespace, false)
The below is getEndpoints in AS3 Manager
if val, ok := rscCfgMap.Label[IsTenantNameServiceNamespace]; ok && val == TrueLabel {
eps, err = rscCfgMap.GetEndpoints(am.getSelector(tnt, app, pn), string(tnt), true)
} else {
eps, err = rscCfgMap.GetEndpoints(am.getSelector(tnt, app, pn), rscCfgMap.Namespace, false)
}
Created [CONTCNTR-4952] for internal tracking.
syn configmap using the old way to query api server in Hub Mode
While syn configmap, the service usually resident the watched namespce, and had appInf bounded, however getServicesForHubMode stilll use the old way, this can further enhance to performance.
The invocation of this function in syncConfigMaps looks: