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

LimitRange default field missing #855

Open
zabealbe opened this issue Aug 11, 2022 · 4 comments
Open

LimitRange default field missing #855

zabealbe opened this issue Aug 11, 2022 · 4 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@zabealbe
Copy link

When creating a LimitRange I found out that this wouldn't work as expected

const lr_config = {
    apiVersion: 'v1',
    kind: 'LimitRange',
    metadata: {
        name: 'default',
    },
    spec: {
        limits: [
            {
                type: 'Container',
                default: {
                    cpu: '200m',
                    memory: '800Mi',
                },
                defaultRequest: {
                    cpu: '200m',
                    memory: '800Mi',
                },
            },
        ],
    },
};
k8sApi_core.createNamespacedLimitRange("default", lr_config);

In fact the resource was deployed in the cluster without the field "default"

apiVersion: v1
kind: LimitRange
metadata:
  creationTimestamp: ***
  name: default
  namespace: default
  resourceVersion: ***
  uid: ***
spec:
  limits:
  - defaultRequest:
      cpu: 200m
      memory: 800Mi
    type: Container

Digging the source code I managed to track the issue to this file

The solution for me was to replace "deafult" with "_default" as follows:

  const lr_config = {
      apiVersion: 'v1',
      kind: 'LimitRange',
      ...
      spec: {
          limits: [
              {
                  type: 'Container',
                  _default: {
                      cpu: '200m',
                      memory: '800Mi',
                  },
                  ...
              },
          ],
      },
  };
k8sApi_core.createNamespacedLimitRange("default", lr_config);

If not possible to use the expected field name I think we should make it clear in the documentation for clarity sake

@brendandburns
Copy link
Contributor

This is happening because default is a reserved word in Javascript. In this specific context (embedded field name) it is ok to use, but it appears that the code generator is not sophisticated enough to understand that nuance.

I agree that it is subtle and confusing to an end-user, we should add this to a 'gotchas' section of the documentation.

It may be possible to fix this in the upstream code generator (https://github.com/OpenAPITools/openapi-generator) but I'm not sure if it is worth the effort, especially given that we are in the (slow) process of switching generators.

@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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 or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR 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 Nov 10, 2022
@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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 or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR 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 Dec 10, 2022
@brendandburns
Copy link
Contributor

/lifecycle freeze

@brendandburns brendandburns added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

4 participants