karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Improve access to member-cluster resources that use pb/json protocol …

Open wangxf1987 opened this issue 1 year ago • 5 comments

…and allow users to set qps, burst values.

What type of PR is this?

/kind feature What this PR does / why we need it: In the large cluster, reasonable qps and burst values need to be set when accessing resources. to improve speed to resources.And use the pb/jsion protocol to improve the communication speed of sub-clusters for resources.

We design a compatibiity processing. when a null pointer is passed in qps and burst are not set.

Which issue(s) this PR fixes: Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

In the large cluster, reasonable qps and burst values need to be set when accessing resources. to improve speed to resources.And use the pb/jsion protocol to improve the communication speed of sub-clusters for resources.

wangxf1987 avatar May 13 '24 07:05 wangxf1987

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please assign xishanyongye-chang after the PR has been reviewed. You can assign the PR to them by writing /assign @xishanyongye-chang in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar May 13 '24 07:05 karmada-bot

Codecov Report

Attention: Patch coverage is 42.10526% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 53.17%. Comparing base (3232c52) to head (f4c8fc5). Report is 76 commits behind head on master.

Files Patch % Lines
pkg/util/membercluster_client.go 31.25% 5 Missing and 6 partials :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4936      +/-   ##
==========================================
+ Coverage   53.05%   53.17%   +0.11%     
==========================================
  Files         250      252       +2     
  Lines       20396    20520     +124     
==========================================
+ Hits        10822    10911      +89     
- Misses       8855     8884      +29     
- Partials      719      725       +6     
Flag Coverage Δ
unittests 53.17% <42.10%> (+0.11%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar May 13 '24 07:05 codecov-commenter

/retest

wangxf1987 avatar May 14 '24 13:05 wangxf1987

@wangxf1987: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

karmada-bot avatar May 14 '24 13:05 karmada-bot

Just retested it manually. Sorry for the inconvenience.

The /retest command is not working now, but we are working on it.

Another way to retrigger the test is to rebase PR and force push again.

RainbowMango avatar May 15 '24 01:05 RainbowMango

/retest

zhzhuang-zju avatar May 27 '24 09:05 zhzhuang-zju

@wangxf1987 Do you still need it?

RainbowMango avatar Jul 05 '24 07:07 RainbowMango

@wangxf1987 Do you still need it?

I need this feature. I've tried karamada-search v1.12.3, and still got the error:

E0214 08:14:12.024022       1 writers.go:122] "Unhandled Error" err="apiserver was unable to write a JSON response: object *unstructured.Unstructured does not implement the protobuf marshalling interface and cannot be encoded to a protobuf message"

ryanwuer avatar Feb 17 '25 07:02 ryanwuer

@iamyeka Hi, do you know in what scenario this log appears?

zhzhuang-zju avatar Feb 17 '25 07:02 zhzhuang-zju

@iamyeka Hi, do you know in what scenario this log appears?

  1. Install karmada-search by default config
  2. Init a clientSet by default config
	restConfig, err := config.ClientConfig()
	if err != nil {
		return err
	}
	restConfig = metadata.ConfigFor(restConfig)
	clientSet, err := kubernetes.NewForConfig(restConfig)
	if err != nil {
		return err
	}
  1. Exec a command like below
pod, err := kubeClientset.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})

If i specify the restConfig like this: restConfig.AcceptContentTypes = "application/json", the problem is gone.

The default AcceptContentTypes is like this:

// ConfigFor returns a copy of the provided config with the
// appropriate metadata client defaults set.
func ConfigFor(inConfig *rest.Config) *rest.Config {
	config := rest.CopyConfig(inConfig)
	config.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
	config.ContentType = "application/vnd.kubernetes.protobuf"
	config.NegotiatedSerializer = metainternalversionscheme.Codecs.WithoutConversion()
	if config.UserAgent == "" {
		config.UserAgent = rest.DefaultKubernetesUserAgent()
	}
	return config
}

ryanwuer avatar Feb 17 '25 07:02 ryanwuer