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

Support for migration to NLB from CLB #381

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

virajrk
Copy link
Collaborator

@virajrk virajrk commented Jan 30, 2025

Adding support for migration to NLB from CLB.
Support this phase by phase.

@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 78.57143% with 12 lines in your changes missing coverage. Please review.

Project coverage is 77.13%. Comparing base (08133eb) to head (bfd426d).

Files with missing lines Patch % Lines
admiral/pkg/clusters/admiralDatabaseClient.go 71.05% 11 Missing ⚠️
admiral/pkg/clusters/types.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #381      +/-   ##
==========================================
+ Coverage   77.08%   77.13%   +0.04%     
==========================================
  Files          75       75              
  Lines       10523    10567      +44     
==========================================
+ Hits         8112     8151      +39     
- Misses       1989     1996       +7     
+ Partials      422      420       -2     

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

@@ -281,6 +281,7 @@ func GetRootCmd(args []string) *cobra.Command {
rootCmd.PersistentFlags().StringSliceVar(&params.NLBEnabledClusters, "nlb_enabled_clusters", []string{}, "Comma seperated list of enabled clusters to be enabled for NLB")
rootCmd.PersistentFlags().StringSliceVar(&params.NLBEnabledIdentityList, "nlb_enabled_identity_list", []string{}, "Comma seperated list of enabled idenity list to be enabled for NLB")
rootCmd.PersistentFlags().StringSliceVar(&params.CLBEnabledClusters, "clb_enabled_clusters", []string{}, "Comma seperated list of enabled clusters to be enabled for CLB")
rootCmd.PersistentFlags().StringVar(&params.NLBIngressLabel, "nlb_ingress_label", common.NLBIstioIngressGatewayLabelValue, "The the value of the `app` label to use to match and find the service that represents the NLB ingress for cross cluster traffic")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick - 2 the

@@ -88,9 +90,27 @@ func (dynamicConfigDatabaseClient *DynamicConfigDatabaseClient) Delete(data inte

func (dynamicConfigDatabaseClient *DynamicConfigDatabaseClient) Get(env, identity string) (interface{}, error) {
//Variable renaming is done to re-purpose existing interface
err := checkIfDynamicConfigDatabaseClientIsInitialize(dynamicConfigDatabaseClient)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: checkIfDynamicConfigDatabaseClientIsInitialized

admiral/pkg/clusters/serviceentry.go Show resolved Hide resolved
for _, fetchService := range rr.remoteControllers[cluster].ServiceController.Cache.Get(common.NamespaceIstioSystem) {
if fetchService.Labels[common.App] == lbLabel {
log.Infof("task=%s, Processing LB migration for Cluster : %s", common.LBUpdateProcessor, cluster)
go handleServiceEventForDeployment(ctx, fetchService, rr, cluster, rr.GetRemoteController(cluster).DeploymentController, rr.GetRemoteController(cluster).ServiceController, HandleEventForDeployment)
Copy link
Collaborator

Choose a reason for hiding this comment

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

would this cause CPU issues if many clusters are added/removed ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Slightly uptick. Mainly idea is -

  1. Migrate few clusters NLB
  2. More clusters to NLB (Optional)
  3. Migrate all clusters to NLB. In this case will flip label.

@@ -158,16 +178,16 @@ func NewDynamicConfigDatabaseClient(path string, dynamoClientInitFunc func(role
return &dynamicConfigClient, nil
}

func UpdateASyncAdmiralConfig(dbClient AdmiralDatabaseManager, syncTime int) {
func UpdateASyncAdmiralConfig(rr *RemoteRegistry, syncTime int) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this func is running in a goroutine but we are not gracefully exiting it. Can we pass in the ctx and return gracefully when the program exits?

var clusersToProcess []string
if cache == nil || len(*cache) == 0 {
*cache = updatedLB
clusersToProcess = updatedLB
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, this variable assignment is not needed. we can just return updatedLB

*cache = updatedLB
clusersToProcess = updatedLB
return clusersToProcess
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, we can remove this else

}
}

func getLBToProcess(updatedLB []string, cache *[]string) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'm unable to follow this.
If NLB Cluster param has c1, c2 and NLB Cache has c1, c2, c3. This func returns c3
Why do we need to process c3 with NLBIngressLabel?
Sorry if I'm misunderstanding

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This method little generic. It gets invoked for CLB as well as NLB.
For example if we remove cluster from NLB and add it CLB then this will take care.

log.Infof("task=%s, Processing LB migration for %s. UpdateReceived=%s, ExistingCache=%s, ", common.LBUpdateProcessor, lbLabel, updatedLBs, existingCache)

for _, cluster := range getLBToProcess(updatedLBs, existingCache) {
for _, fetchService := range rr.remoteControllers[cluster].ServiceController.Cache.Get(common.NamespaceIstioSystem) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add some nil checks to avoid panics?

//Validate if New ClusterAdded
for _, clusterFromAdmiralParam := range updatedLB {
if !slices.Contains(*cache, clusterFromAdmiralParam) {
clusersToProcess = append(clusersToProcess, clusterFromAdmiralParam)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add the new cluster in the cache, or is it being added somewhere else?

//Validate if cluster Removed
for _, clusterFromCache := range *cache {
if !slices.Contains(updatedLB, clusterFromCache) {
clusersToProcess = append(clusersToProcess, clusterFromCache)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same, we may need to remove it from the cache

Viraj Kulkarni added 20 commits February 4, 2025 16:37
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Viraj Kulkarni added 4 commits February 4, 2025 16:41
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
Signed-off-by: Viraj Kulkarni <[email protected]>
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