Skip to content

Unable to deserialize duplicated resource names #2384

Open
@schrodit

Description

@schrodit

Describe the bug

The generic client is unable to correctly deserialize resources correctly that overlap the kind name.
E.g. querying a custom resource of kind Probe with group monitoring.coreos.com/v1 results in an empty class of type V1Probe.
This is because the serializer does not take the group into account while deserializing.

Client Version
e.g. 1.1.2

Server Version
e.g. 1.30.1

To Reproduce

  1. Create a custom resource with an overlapping name (e.g. install the prometheus operator).
  2. create an instance
  3. try to query that instance: see code snippet

Expected behavior

The client should return the plane K8s object when the type is unknown.

Example Code

const kc = new KubeConfig();
kc.loadFromDefault();
const client = new KubernetesObjectApi(kc);
const p = await client.read({
    apiVersion: 'monitoring.coreos.com/v1',
    kind: 'Probe',
    metadata: {
        name: 'my-probe',
        namespace: 'default',
    },
});

Environment (please complete the following information):

  • OS: Linux
  • Node.js version: 20

Additional context

I think to correctly fix this, the ObjectSerializer has to use the whole unique name of a resource (group version and kind) to identify an object.
The group information is currently not available so I guess the converter has to be adapted to provide that info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions