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

Should metav1.Time CRD generation specify nullable if the field is optional? #812

Open
vsliouniaev opened this issue May 11, 2023 · 6 comments

Comments

@vsliouniaev
Copy link

  1. Create a CRD with a time field. For example ReleaseTime *metav1.Time json:"releaseTime,omitempty
  2. The spec which gets generated doesn’t have releaseTime in the required section, which is as expected
  3. Using k8s.io/code-generator v0.27.1 generate a client.
  4. Use the Apply method to try patch the resource, clearing the releaseTime field.
  5. The MarshalJson for time specifies that zero-value time will get marshalled to null
  6. When the apply call is made to api the request is rejected with spec.releaseTime: Invalid value: "null": spec.releaseTime in body must be of type string: "null"
  7. The solution to this appears to be to add the extra //+nullable marker to the field to get the schema to become
spec:
  properties:
    releaseTime:
      format: date-time
      nullable: true
      type: string

Seems like this should happen by default if the field is optional.

@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 Jan 20, 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 Feb 19, 2024
@vsliouniaev
Copy link
Author

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Mar 8, 2024
@sbueringer
Copy link
Member

Not sure if we want to start inferring additional markers based on types.

@vsliouniaev
Copy link
Author

That's fair - thanks for the info. Feel free to close this if you feel like the behaviour is intentional.

@sbueringer
Copy link
Member

sbueringer commented Apr 10, 2024

Really not sure :), let's see if others have opinions.

(cc @vincepri @alvaroaleman)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants