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

KubernetesMockServer does not return same List type as Kubernetes Api Server #6220

Open
rohanKanojia opened this issue Aug 5, 2024 · 1 comment
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly component/openshift-server-mock Deals with the openshift-server-mock

Comments

@rohanKanojia
Copy link
Member

Describe the bug

Related to #1601

This issue applies to scenarios when you're using Kubernetes Mock Server with clients other than Fabric8 Kubernetes Client.

When you use KubernetesMockServer in crud mode to get response of list() query operations, you'd get response like this:

{"apiVersion":"v1","kind":"List", "items": [{"kind":"Secret","apiVersion":"v1","metadata":{"name":"sh.helm.release.v1.test-project.v1",

However, with a real Kubernetes API server, we get a concrete List type

{"kind":"SecretList","apiVersion":"v1","metadata":{"resourceVersion":"225"},"items":[{"metadata":{"name":"sh.helm.release.v1.test-project.v1","namespace":"default","uid":"eeccb069-92c8-4220-9ec7-e2237d4ab660",

This is coming from here:

return String.format(
"{\"apiVersion\":\"v1\",\"kind\":\"List\", \"items\": [%s], " +
"\"metadata\": {\"resourceVersion\": \"%s\", \"selfLink\": \"\"}}",

This will work for KubernetesClient, however with other clients it causes problems in parsing list-objects.

Fabric8 Kubernetes Client version

SNAPSHOT

Steps to reproduce

Set up Kubernetes Mock Server with some other client and try doing list request, it would fail

Expected behavior

Kubernetes Mock Server list response should be same as Kubernetes Api Server

Runtime

other (please specify in additional context)

Kubernetes API Server version

1.25.3@latest

Environment

Linux

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

@rohanKanojia rohanKanojia added component/openshift-server-mock Deals with the openshift-server-mock component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly labels Aug 5, 2024
@manusa manusa added the bug label Aug 9, 2024
@manusa manusa moved this to Planned in Eclipse JKube Aug 28, 2024
@rohanKanojia rohanKanojia self-assigned this Sep 4, 2024
@manusa
Copy link
Member

manusa commented Sep 10, 2024

As reviewed internally:

  • Current state of Kubernetes Mock Server (CRUD) doesn't allow to reliably infer the list type from the path. This is required for the following cases:
    • There are no items for the resource located at the path
    • There are resources with mismatching or inconsistent kind at the specified path (this is not likely to happen, but it's still an issue)

Once we fix #6062 (Aggregated discovery of endpoints) and the Kubernetes model is completely inferred from OpenAPI (#6130), we might be able to implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly component/openshift-server-mock Deals with the openshift-server-mock
Projects
None yet
Development

No branches or pull requests

2 participants