Skip to content

Introduce OpenAPI format support for k8s-short-name and k8s-long-name #132504

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

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

jpbetz
Copy link
Contributor

@jpbetz jpbetz commented Jun 24, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Kubernetes name formats are used throughout the Kubernetes native types (Pod, Deployment, ...). This enables CRDs to use the same formats in OpenAPI validations.

For example,

 apiVersion: apiextensions.k8s.io/v1                                                                                                                                                  
 kind: CustomResourceDefinition                                                                                                                                                       
 metadata:                                                                                                                                                                            
   name: crontabs.stable.example.com                                                                                                                                                  
 spec:                                                                                                                                                                                
   group: stable.example.com                                                                                                                                                          
   versions:                                                                                                                                                                          
     - name: v1                                                                                                                                                                       
       served: true                                                                                                                                                                   
       storage: true                                                                                                                                                                  
       schema:                                                                                                                                                                        
         openAPIV3Schema:                                                                                                                                                             
           type: object                                                                                                                                                               
           properties:                                                                                                                                                                
             spec:                                                                                                                                                                    
               type: object                                                                                                                                                           
               properties:                                                                                                                                                            
                 longName:                                                                                                                                                            
                   type: string                                                                                                                                                       
                   format: k8s-long-name                                                                                                                                              
                 shortName:                                                                                                                                                           
                   type: string                                                                                                                                                       
                   format: k8s-short-name

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Introduced OpenAPI format support for `k8s-short-name` and `k8s-long-name` in CustomResourceDefinition schemas.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 24, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kube-proxy area/kubectl area/kubelet kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 24, 2025
@k8s-ci-robot k8s-ci-robot added the sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. label Jun 24, 2025
@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Jun 24, 2025
@k8s-ci-robot k8s-ci-robot requested review from andrewsykim, apelisse and a team June 24, 2025 15:59
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG CLI Jun 24, 2025
@jpbetz jpbetz changed the title Bump to latest kube-openapi Introduce OpenAPI format support for k8s-short-name and k8s-long-name Jun 24, 2025
@jpbetz
Copy link
Contributor Author

jpbetz commented Jun 24, 2025

/assign @liggitt @dims
For version bump

/assign @lalitc375
For introduction of new OpenAPI formats

cc @thockin

@k8s-ci-robot
Copy link
Contributor

@jpbetz: GitHub didn't allow me to assign the following users: lalitc375.

Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @liggitt @dims
For version bump

/assign @lalitc375
For introduction of new OpenAPI formats

cc @thockin

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@@ -50,7 +50,7 @@ import (

var (
printerColumnDatatypes = sets.NewString("integer", "number", "string", "boolean", "date")
customResourceColumnDefinitionFormats = sets.NewString("int32", "int64", "float", "double", "byte", "date", "date-time", "password")
customResourceColumnDefinitionFormats = sets.NewString("int32", "int64", "float", "double", "byte", "date", "date-time", "password", "k8s-short-name", "k8s-long-name")
Copy link
Member

@liggitt liggitt Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the format on column definitions used for?

The API doc isn't very clear and also references a name format that doesn't appear to be allowed here? Are these columns appended to the standard name column? If so, it's pretty weird for these new name formats to not be usable on the name column (and I don't think we can change name on the name column since clients use it to recognize the name), and for the name printer column format to have no openapi format meaning :-/

	// format is an optional OpenAPI type definition for this column. The 'name' format is applied
	// to the primary identifier column to assist in clients identifying column is the resource name.
	// See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.
	// +optional
	Format string `json:"format,omitempty" protobuf:"bytes,3,opt,name=format"`

Copy link
Contributor Author

@jpbetz jpbetz Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the format on column definitions used for?

I think I misunderstood this. It looks like customResourceColumnDefinitionFormats enumerates the formats a printer column can be explicitly declared as.

I has mistaken this to be a filter on what fields are allowed to used as printer columns.

To fix, I've dropped the k8s names from this list and added tests showing that fields using these formats can be used as string printer columns.

I believe this is consistent with the existing behavior and doesn't add any new wrinkles. I do find the name format odd here since this format field otherwise makes consistent use of OpenAPI names. I'll think about that more.

@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@k8s-ci-robot
Copy link
Contributor

@jpbetz: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-linter-hints e1daa69 link false /test pull-kubernetes-linter-hints

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@liggitt
Copy link
Member

liggitt commented Jun 24, 2025

lgtm, will let others tagged take a look

@thockin
Copy link
Member

thockin commented Jun 25, 2025

I looked at the kube-openapi changes and have no comments.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: d0483d037b29cfe50920461b01d919b999f3709b

@liggitt
Copy link
Member

liggitt commented Jun 25, 2025

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2025
@k8s-ci-robot k8s-ci-robot merged commit 1d932bd into kubernetes:master Jun 25, 2025
13 of 14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone Jun 25, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in SIG CLI Jun 25, 2025
@github-project-automation github-project-automation bot moved this to Closed / Done in SIG Auth Jun 25, 2025
@lmktfy
Copy link

lmktfy commented Jun 26, 2025

Changelog nit

-Introduces OpenAPI format support for `k8s-short-name` and `k8s-long-name`.
+Introduced OpenAPI format support for `k8s-short-name` and `k8s-long-name` in CustomResourceDefinition schemas.

(is that right?)

@jpbetz
Copy link
Contributor Author

jpbetz commented Jun 26, 2025

Changelog nit

-Introduces OpenAPI format support for `k8s-short-name` and `k8s-long-name`.
+Introduced OpenAPI format support for `k8s-short-name` and `k8s-long-name` in CustomResourceDefinition schemas.

(is that right?)

Yes, that's a good improvement. I've updated the release note to match. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kube-proxy area/kubectl area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. wg/device-management Categorizes an issue or PR as relevant to WG Device Management.
Projects
Archived in project
Status: Closed / Done
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants