Skip to content

Error from karmada-search: apiserver was unable to write a JSON response #6129

Open
@ryanwuer

Description

@ryanwuer

Please provide an in-depth description of the question you have:

Guided by the blog: https://karmada.io/docs/tutorials/karmada-search/, i want to get pod from the true K8s.
What i did:

  1. Install karmada-search with default configs by helm chart
  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{})
  1. Error log printed in kramada-search
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"

If i specify the restConfig of the clientSet 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
}

What do you think about this question?:

Environment:

  • Karmada version: 1.12.3
  • Kubernetes version: 1.19.3
  • Others: Installed by helm chart, with all default configs

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.kind/questionIndicates an issue that is a support question.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions