-
Notifications
You must be signed in to change notification settings - Fork 83
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
Optimize GlobalTrafficPolicy fetching and endpoint generation time #206
Optimize GlobalTrafficPolicy fetching and endpoint generation time #206
Conversation
Signed-off-by: aattuluri <[email protected]>
Signed-off-by: aattuluri <[email protected]>
Signed-off-by: aattuluri <[email protected]>
Signed-off-by: aattuluri <[email protected]>
This reverts commit a9fa409.
…mmit sha if neither i) or ii)
@@ -219,6 +233,35 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s | |||
return serviceEntries | |||
} | |||
|
|||
func updateGlobalGtpCache(cache *AdmiralCache, identity, env string, gtps map[string][]*v1.GlobalTrafficPolicy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments for this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Please add more comments
@@ -1331,6 +1335,82 @@ func TestUpdateEndpointsForWeightedServices(t *testing.T) { | |||
|
|||
} | |||
|
|||
func TestUpdateGlobalGtpCache(t *testing.T) { | |||
|
|||
admiralCache := &AdmiralCache{GlobalTrafficCache: &globalTrafficCache{identityCache: make(map[string]*v13.GlobalTrafficPolicy), mutex: &sync.Mutex{}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can all the variable declaration and definition be added under a
var (
)
block.
t.Run(c.name, func(t *testing.T) { | ||
updateGlobalGtpCache(admiralCache, c.identity, c.env, c.gtps) | ||
gtp := admiralCache.GlobalTrafficCache.GetFromIdentity(c.identity, c.env) | ||
if c.expectedGtp == nil && gtp == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be use a single condition to condense all conditions.
if !reflect.DeepEqual(c.expectedGtp, gtp) {
t.Errorf("want: %v, got: %v")
}
t.Errorf("%v", err) | ||
func TestGlobalTrafficController_Updated(t *testing.T) { | ||
|
||
gth := test.MockGlobalTrafficHandler{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Can all the variable definition/declaration be added inside
var (
)
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment for TestGlobalTrafficController_Added
and TestGlobalTrafficController_Deleted
gtpController.Updated(c.gtp, gtp) | ||
gtpKey := common.GetGtpKey(c.gtp) | ||
matchedGtps := gtpController.Cache.Get(gtpKey, c.gtp.Namespace) | ||
if len(matchedGtps) != len(c.expectedGtps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use !reflect.DeepEqual
here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment for TestGlobalTrafficController_Added
and TestGlobalTrafficController_Deleted
…stio-ecosystem#206) Signed-off-by: psikka1 <[email protected]>
) Signed-off-by: sa <[email protected]>
* Tune default outlier detection parameters for remote endpoints (istio-ecosystem#207) * [bug] prevent panic when finding out rollout strategy (istio-ecosystem#210) * prevent panic when finding out rollout strategy Co-authored-by: Anubhav Aeron <[email protected]> * Optimize GlobalTrafficPolicy fetching and endpoint generation time (istio-ecosystem#206) Co-authored-by: aattuluri <[email protected]> Co-authored-by: Anubhav <[email protected]>
Current approach
Deployment/Rollout event
Step 1: Collect all GTPs from all clusters matching this deployment and save them to cache
Step 2: Iterate over all cluster caches to group deployments and generate endpoints with matching GTPs
Step 3: Write to local clusters
Step 4: Write to remote clusters
New approach (in this PR)
GTP cache is managed in the controller itself by identity+env cache key
Deployment/Rollout event
Step 1: Collect GTPs (write matched GTP to global cache for APIs etc.) from only clusters where Deployment/Rollout instances are running
Step 2: Generate mesh endpoints from what is collected in Step 1
Step 3: Write to local clusters
Step 4: Write to remote clusters