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

read returns wrong struct for custom k8s objects, if name matches core API object #1747

Open
gnarlex opened this issue Jun 23, 2024 · 3 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@gnarlex
Copy link

gnarlex commented Jun 23, 2024

Describe the bug
When read()ing a custom k8s object, whose kind matches one of the core API object kinds, it constructs an object matching the core v1 type.

Example: monitoring.coreos.com/v1:Probe matches core/v1:Probe

Client Version
0.21.0

Server Version
v1.28.4

To Reproduce
Steps to reproduce the behavior:

  • Keep a custom k8s object in your cluster, with apiVersion monitoring.coreos.com/v1, and kind Probe, metadata.name="foo".
  • read probe "foo".

Expected behavior
The correct, entire monitoring../v1:Probe object is returned.

Example Code

const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const client = kc.makeApiClient(k8s.KubernetesObjectApi);

const main = async () => {
    let {body: listRes} = await client
        .list('monitoring.coreos.com/v1', 'Probe', 'default');
    console.log(Object.entries(listRes.items[0]));
    /* monitoring.coreos.com/v1:Probe ✅
    [
      [ 'apiVersion', 'monitoring.coreos.com/v1' ],
      [ 'kind', 'Probe' ],
      [ 'metadata', {...} ],
      [ 'spec', {...} ],
    ]
    */

    let {body: readRes} = await client.read({
        apiVersion: 'monitoring.coreos.com/v1',
        kind: 'Probe',
        metadata: {
            name: 'foo',
            namespace: 'default'
        },
    });
    console.log(Object.entries(readRes));
    /* core/v1:Probe ❌
    [
      [ 'exec', undefined ],
      [ 'failureThreshold', undefined ],
      [ 'grpc', undefined ],
      [ 'httpGet', undefined ],
      [ 'initialDelaySeconds', undefined ],
      [ 'periodSeconds', undefined ],
      [ 'successThreshold', undefined ],
      [ 'tcpSocket', undefined ],
      [ 'terminationGracePeriodSeconds', undefined ],
      [ 'timeoutSeconds', undefined ]
    ]
    */
}

main();

Environment (please complete the following information):

  • OS: MacOs
  • NodeJS Version: 18.5.0

Additional context
list() correctly returns the object as-is for custom object types. I suppose it matches the full version string, instead of just the v1 part.

@brendandburns
Copy link
Contributor

I'll see if I can reproduce this. I suspect that there is some special casing for v1 APIs which is messing this up.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 23, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants