Skip to content

Commit 8929f89

Browse files
authored
perf: move snapshot update above status update in xds layer (#7423)
Signed-off-by: Arko Dasgupta <[email protected]>
1 parent 5ebd539 commit 8929f89

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

internal/xds/runner/runner.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,24 @@ func (r *Runner) translateFromSubscription(sub <-chan watchable.Snapshot[string,
310310
return
311311
}
312312

313+
// Update snapshot cache
314+
if err == nil {
315+
if result.XdsResources != nil {
316+
if r.cache == nil {
317+
r.Logger.Error(err, "failed to init snapshot cache")
318+
errChan <- err
319+
} else {
320+
// Update snapshot cache
321+
if err := r.cache.GenerateNewSnapshot(key, result.XdsResources); err != nil {
322+
r.Logger.Error(err, "failed to generate a snapshot")
323+
errChan <- err
324+
}
325+
}
326+
} else {
327+
r.Logger.Error(err, "skipped publishing xds resources")
328+
}
329+
}
330+
313331
// Get all status keys from watchable and save them in the map statusesToDelete.
314332
// Iterating through result.EnvoyPatchPolicyStatuses, any valid keys will be removed from statusesToDelete.
315333
// Remaining keys will be deleted from watchable before we exit this function.
@@ -335,24 +353,6 @@ func (r *Runner) translateFromSubscription(sub <-chan watchable.Snapshot[string,
335353
// Discard the EnvoyPatchPolicyStatuses to reduce memory footprint
336354
result.EnvoyPatchPolicyStatuses = nil
337355

338-
// Update snapshot cache
339-
if err == nil {
340-
if result.XdsResources != nil {
341-
if r.cache == nil {
342-
r.Logger.Error(err, "failed to init snapshot cache")
343-
errChan <- err
344-
} else {
345-
// Update snapshot cache
346-
if err := r.cache.GenerateNewSnapshot(key, result.XdsResources); err != nil {
347-
r.Logger.Error(err, "failed to generate a snapshot")
348-
errChan <- err
349-
}
350-
}
351-
} else {
352-
r.Logger.Error(err, "skipped publishing xds resources")
353-
}
354-
}
355-
356356
// Delete all the deletable status keys
357357
for key := range statusesToDelete {
358358
r.ProviderResources.EnvoyPatchPolicyStatuses.Delete(key)

0 commit comments

Comments
 (0)