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

Merged
merged 29 commits into from
Feb 11, 2025

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 72.15190% with 22 lines in your changes missing coverage. Please review.

Project coverage is 77.04%. Comparing base (faabd12) to head (6a0ad67).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
admiral/pkg/clusters/admiralDatabaseClient.go 58.00% 21 Missing ⚠️
admiral/pkg/clusters/types.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #381      +/-   ##
==========================================
- Coverage   77.06%   77.04%   -0.02%     
==========================================
  Files          75       75              
  Lines       10541    10596      +55     
==========================================
+ Hits         8123     8164      +41     
- Misses       1995     2011      +16     
+ Partials      423      421       -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

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


for range time.Tick(time.Minute * time.Duration(syncTime)) {
ReadAndUpdateSyncAdmiralConfig(dbClient)
ctxDynamicConfig, cancel := context.WithCancel(context.Background())
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 you pass the ctx as a param from where this func is getting called

Viraj Kulkarni added 17 commits February 10, 2025 16:21
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 12 commits February 10, 2025 16:21
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]>
@virajrk virajrk marked this pull request as ready for review February 11, 2025 17:31
@virajrk virajrk merged commit 94daadf into istio-ecosystem:master Feb 11, 2025
3 checks passed
@virajrk virajrk deleted the NLBMigration2 branch February 11, 2025 17:32
@virajrk virajrk restored the NLBMigration2 branch February 11, 2025 17:33
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