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

feat: support forward requests to leader hub for sharing pool scope metadata in nodepool #2325

Merged

Conversation

rambohe-ch
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage

/kind feature

What this PR does / why we need it:

  1. Add a secure server(nodeIP:10269) in yurthub for serving multiplexer requests from follower yurthub.
  2. Yurthub needs to list/watch two configmaps: yurt-hub-cfg and leader-hub-{pool-name}, in order to improve configmap list/watch, we use labelSelector to select these two configmaps in one list/watch, so a new label: openyurt.io/configmap-name: {configmap-name} is added to these two configmaps.
  3. NodePool name should be specified for yurthub, otherwise yurthub will fail to startup.
  4. Support forward requests for pool scope metadata to leader yurthub.
  5. improve cluster which created by make local-up-openyurt as following:
  • initialize 3 nodepools:
    • yurt-pool1: Type: Cloud, EnableLeaderElection: false
    • yurt-pool2: Type: Edge, EnableLeaderElection: true, LeaderReplicas: 1
    • yurt-pool3: Type: Edge, EnableLeaderElection: false
  • add openyurt-e2e-test-control-plane node into yurt-pool1
  • add openyurt-e2e-test-worker and openyurt-e2e-test-worker2 nodes into yurt-pool2
  • add openyurt-e2e-test-worker3 and openyurt-e2e-test-worker4 nodes into yurt-pool3

Which issue(s) this PR fixes:

Fixes #2261

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Yurthub parameter: `--nodepool-name` should not be empty. this means end user need to create nodepool before joining nodes.

other Note

@rambohe-ch rambohe-ch requested a review from a team as a code owner February 16, 2025 14:26
@rambohe-ch
Copy link
Member Author

@rambohe-ch rambohe-ch force-pushed the support-pool-scope-metadata-in-pool branch 2 times, most recently from 8f25132 to 2e41ba9 Compare February 17, 2025 00:25
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 56.16438% with 128 lines in your changes missing coverage. Please review.

Project coverage is 45.97%. Comparing base (6676fa3) to head (be43355).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/yurthub/proxy/proxy.go 0.00% 43 Missing ⚠️
pkg/yurthub/multiplexer/multiplexer.go 81.15% 14 Missing and 12 partials ⚠️
cmd/yurthub/app/start.go 0.00% 16 Missing ⚠️
pkg/yurthub/proxy/remote/loadbalancer.go 16.66% 15 Missing ⚠️
cmd/yurthub/app/config/config.go 73.91% 5 Missing and 1 partial ⚠️
cmd/yurthub/app/options/options.go 63.63% 2 Missing and 2 partials ⚠️
pkg/node-servant/components/yurthub.go 0.00% 4 Missing ⚠️
pkg/node-servant/convert/options.go 0.00% 3 Missing ⚠️
pkg/yurthub/server/server.go 0.00% 3 Missing ⚠️
pkg/node-servant/convert/convert.go 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2325      +/-   ##
==========================================
+ Coverage   45.70%   45.97%   +0.26%     
==========================================
  Files         394      394              
  Lines       25953    26103     +150     
==========================================
+ Hits        11861    12000     +139     
- Misses      12946    12952       +6     
- Partials     1146     1151       +5     
Flag Coverage Δ
unittests 45.97% <56.16%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@rambohe-ch rambohe-ch force-pushed the support-pool-scope-metadata-in-pool branch 3 times, most recently from 4514d42 to cbef4f1 Compare February 17, 2025 01:41
@@ -167,6 +171,19 @@ func (options *YurtHubOptions) Validate() error {
if len(options.CACertHashes) == 0 && !options.UnsafeSkipCAVerification {
return fmt.Errorf("set --discovery-token-unsafe-skip-ca-verification flag as true or pass CACertHashes to continue")
}

if len(options.NodePoolName) == 0 {
return fmt.Errorf("node-pool-name is empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("node-pool-name is empty")
return errors.New("node-pool-name is empty")

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

if !ok {
return
}
oldCfg, _ := oldObj.(*corev1.ConfigMap)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not check the "ok" value still?

Copy link
Member Author

Choose a reason for hiding this comment

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

because FilterFunc in configmap informer as following can ensure only configmap object is transferred to event handlers.

	configmapInformer.AddEventHandler(cache.FilteringResourceEventHandler{
		FilterFunc: func(obj interface{}) bool {
			cfg, ok := obj.(*corev1.ConfigMap)
			if ok && cfg.Name == util.YurthubConfigMapName {
				return true
			}
			return false
		},
		Handler: cache.ResourceEventHandlerFuncs{
			AddFunc:    m.addConfigmap,
			UpdateFunc: m.updateConfigmap,
			DeleteFunc: m.deleteConfigmap,
		},
	})

oldCM, _ := oldObj.(*corev1.ConfigMap)
newCM, _ := newObj.(*corev1.ConfigMap)

if reflect.DeepEqual(oldCM.Data, newCM.Data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maps.Equal(...) is a new std lib for comparing maps.

https://pkg.go.dev/maps#Equal

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@rambohe-ch rambohe-ch force-pushed the support-pool-scope-metadata-in-pool branch 3 times, most recently from f2e80fc to c86a55a Compare February 19, 2025 00:32
@rambohe-ch rambohe-ch force-pushed the support-pool-scope-metadata-in-pool branch from c86a55a to be43355 Compare February 19, 2025 06:59
@zyjhtangtang
Copy link
Contributor

/LGTM

@zyjhtangtang zyjhtangtang merged commit 13f0dbd into openyurtio:master Feb 19, 2025
14 checks passed
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.

[feature request]Yurthub proxy pool scope metadata list/watch requests to Leader Yurthub.
3 participants