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

MESH-5878: Admiral does not create envoy filter on client onboardings #362

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

adilfulara
Copy link
Collaborator

Task

  • Admiral should process new client onboardings for a service with a RoutingPolicy

Description

What does this change do and why?

  • Introduce RoutingPolicyProcessor interface to contain the process() api in order to expose it

Thank you!

@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 89.92806% with 14 lines in your changes missing coverage. Please review.

Project coverage is 63.74%. Comparing base (ed49448) to head (47333c9).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
admiral/pkg/clusters/routingpolicy_handler.go 88.42% 8 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #362      +/-   ##
==========================================
+ Coverage   63.25%   63.74%   +0.49%     
==========================================
  Files          91       91              
  Lines       12158    12218      +60     
==========================================
+ Hits         7690     7788      +98     
+ Misses       4053     4016      -37     
+ Partials      415      414       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adilfulara adilfulara force-pushed the MESH-5878 branch 4 times, most recently from a538076 to d2ffc07 Compare December 17, 2024 20:54
- Introduce RoutingPolicyProcessor interface
- Inject RoutingPolicyService into DependencyHandler

Tech-Debt:
- Increase coverage for routingpolicy_handler.go

Signed-off-by: Adil Fulara <[email protected]>
@adilfulara adilfulara marked this pull request as ready for review December 23, 2024 21:06
Comment on lines +57 to +60
if oldRP != nil {
oldEnv := common.GetRoutingPolicyEnv(oldRP)
r.RemoteRegistry.AdmiralCache.RoutingPolicyCache.Delete(id, oldEnv, oldRP.Name)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we deleting from the cache?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are deleting the old resource as part of the update event. Should we be retaining older resources?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we dont have routing policies in ppd or production we may not need this. Plus cache ( in memory) gets populated every time admiral restarts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason i am deleting is if the env label is changed the cache will be corrupted which could cause problems for subsequent updates. ( ex: change is admiral.io/env label value )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adilfulara is it ok to refresh the map if there are error in the above loop? For example, what if all the calls to createOrUpdateEnvoyFilter return failure. Is it ok to mutate the map?

// for each destination, identify the newRP.
for _, dependent := range newDestinations {
// if the dependent is in the mesh, then get the newRP
policies := r.RemoteRegistry.AdmiralCache.RoutingPolicyCache.GetForIdentity(dependent)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry please correct me if I'm wrong, but why are we trying to get routingPolicies of the destination/client?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newDestinations is the new service that the client onboarded to. So we need to get all routing policies associated with the destination so we can apply it at the client side.

- clean up commented code

Signed-off-by: Adil Fulara <[email protected]>
log.Warnf(LogFormat, eventType, "routingpolicy", newRP.Name, remoteController.ClusterID, "RoutingPolicy disabled for cluster")
continue
}
for _, dependent := range dependents {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think multi threading will help here, assuming there are 100's of dependents for services like QBO

Copy link
Collaborator Author

@adilfulara adilfulara Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could definitely benefit from usage of go-routines but i chose not do this for following reasons

  • currently there are no such use cases.
  • each client to service mapping will come in as a separate update due to the DependencyRecord CRD, there wont be much benefit from usage of goroutine usage.
  • only for enabled clusters.

LMK what you prefer.

Comment on lines +57 to +60
if oldRP != nil {
oldEnv := common.GetRoutingPolicyEnv(oldRP)
r.RemoteRegistry.AdmiralCache.RoutingPolicyCache.Delete(id, oldEnv, oldRP.Name)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we dont have routing policies in ppd or production we may not need this. Plus cache ( in memory) gets populated every time admiral restarts.

log.Infof(LogFormat, eventType, "routingpolicy", rp.Name, "",
fmt.Sprintf("finished processing routing policy for new destination=%s in delta update", dependent))
}
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, can this be removed?

log.Errorf(LogErrFormat, eventType, "envoyfilter", filter, rc.ClusterID, err1)
err = common.AppendError(err, err1)
} else {
log.Infof(LogFormat, eventType, "envoyfilter", filter, rc.ClusterID, "deleting from cache")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this log line message might be inaccurate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants