8000 Clarify ordering requirements of client-gen --input by jpbetz · Pull Request #130506 · kubernetes/kubernetes · GitHub
[go: up one dir, main page]

Skip to content

Conversation

jpbetz
Copy link
Contributor
@jpbetz jpbetz commented Mar 1, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

A "generated code keeps changing order" problem for API gateway was traced down to this. xref: kubernetes-sigs/gateway-api#3652

Which issue(s) this PR fixes:

Ideally, client-gen would sort it's --input argument after receiving it to enforce consistent order.

Problem is, there are many build pipelines already using client-gen, and changing client-gen to sort after receiving the list would impact their code generation (could be breaking to those pipelines).

So let's at least document that a sorted --input is expected.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 1, 2025
@k8s-ci-robot k8s-ci-robot added area/code-generation approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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. labels Mar 1, 2025
@jpbetz
Copy link
Contributor Author
jpbetz commented Mar 1, 2025

/assign @BenTheElder

Copy link
Member
@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

thanks!

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

LGTM label has been added.

Git tree hash: 3f680aa66f1ad0921129a1d8e1c5846841c12a72

@dprotaso
Copy link
Contributor
dprotaso commented Mar 1, 2025

Hi - how would sorting the input break the pipeline?

@jpbetz
Copy link
Contributor Author
jpbetz commented Mar 1, 2025

Hi - how would sorting the input break the pipeline?

Dep bump to code-generator would cause any build to fail that checks the generated code didn't change. It's fixable by running the code generator when preparing the PR that bumps code-generator dep, but it's arguably a breaking change -- "I didn't change the input of the code generator, why is there a diff in the generated code?"

@dprotaso
Copy link
Contributor
dprotaso commented Mar 1, 2025

But there’s never been any compatibility guarantee with these codegen tools and client sets - eg. when context was added to the API surface, gengo => gengov2 etc

FWIW I think clientgen doing the sorting will solve more grief than it causes

@jpbetz
Copy link
Contributor Author
jpbetz commented Mar 1, 2025

But there’s never been any compatibility guarantee with these codegen tools and client sets - eg. when context was added to the API surface, gengo => gengov2 etc

Adding context was extremely painful for the community and not something I'd like to repeat.

FWIW I think clientgen doing the sorting will solve more grief than it causes

I hear you. I'm considering it for this case. In the short term I'd like to at least doc the problem.

EDIT: Long term we should probably audit all our codegen inputs. There might be other unsorted inputs.

@dprotaso
Copy link
Contributor
dprotaso commented Mar 1, 2025

Yeah sounds good I just want to push back that things can’t change in the clientgen code due to pipelines breaking and don’t perform code generation.

then we’d never be able to add new methods/features to clients which seems like an odd restriction.

@k8s-ci-robot k8s-ci-robot merged commit 75633d0 into kubernetes:master Mar 1, 2025
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.33 milestone Mar 1, 2025
@yongruilin
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 6, 2025
@BenTheElder
Copy link
Member

Adding context was extremely painful for the community and not something I'd like to repeat.

I do think this one wouldn't be that painful, you'd have to one-time regenerate on upgrading IF your previous input wasn't sorted.

I've been thinking about this and I think it would be better to start sorting it, WIP: #130626

@jpbetz
Copy link
Contributor Author
jpbetz commented Mar 6, 2025

Adding context was extremely painful for the community and not something I'd like to repeat.

I do think this one wouldn't be that painful, you'd have to one-time regenerate on upgrading IF your previous input wasn't sorted.

I've been thinking about this and I think it would be better to start sorting it, WIP: #130626

I agree. We do need to retain golang backward compatibility of the genereated code (apidiff passes basically). This has become a stated goal of this client, to avoid repeating pain caused to the community by changes like adding context. But this is different. Here we're just generating the code differently, but in a way that is stable and good for users.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, hashim21223445, jpbetz

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

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/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

0