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

Add missing metav1.ObjectMeta to NetworkPolicyEvaluation API type #6675

Conversation

antoninbas
Copy link
Contributor

It seems that omitting the field was a mistake when defining the API. New versions of the K8s code generators (client-gen specifically) will not work with types missing this field.
See kubernetes/code-generator@688a73a.
This is preventing us from updating to a more recent version of the K8s libraries and of the code generators.

Note that I believe that this API was modeled after the upstream TokenReview API (which like this one only supports the "create" verb, and returns a response immediately). The TokenReview type does include a metav1.ObjectMeta field.

Unfortunately, for backwards-compatibility, we need to use Protobuf field number 3 for the metadata field, while K8s always uses 1. This is a bit surprising, but it should only affect the wire format, and nothing else.

It seems that omitting the field was a mistake when defining the API.
New versions of the K8s code generators (client-gen specifically) will
not work with types missing this field.
See kubernetes/code-generator@688a73a
This is preventing us from updating to a more recent version of the K8s
libraries and of the code generators.

Note that I believe that this API was modeled after the upstream
TokenReview API (which like this one only supports the "create" verb,
and returns a response immediately). The TokenReview type does include a
metav1.ObjectMeta field.

Unfortunately, for backwards-compatibility, we need to use Protobuf
field number 3 for the metadata field, while K8s always uses 1. This is
a bit surprising, but it should only affect the wire format, and nothing
else.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
@antoninbas antoninbas added api-review Categorizes an issue or PR as actively needing an API review. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API. kind/bug Categorizes issue or PR as related to a bug. labels Sep 17, 2024
@Dyanngg
Copy link
Contributor

Dyanngg commented Sep 17, 2024

Thanks for catching this issue. LGTM except that codegen seemingly needs update

@qiyueyao
Copy link
Contributor

Thanks! Codegen test +1

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
@antoninbas
Copy link
Contributor Author

@Dyanngg @qiyueyao thanks, I have generated the code

qiyueyao
qiyueyao previously approved these changes Sep 17, 2024
@antoninbas
Copy link
Contributor Author

/test-all

Dyanngg
Dyanngg previously approved these changes Sep 17, 2024
Copy link
Contributor

@Dyanngg Dyanngg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM, one minor comment

Request *NetworkPolicyEvaluationRequest `json:"request,omitempty" protobuf:"bytes,1,opt,name=request"`
Response *NetworkPolicyEvaluationResponse `json:"response,omitempty" protobuf:"bytes,2,opt,name=response"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,3,opt,name=metadata"`
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a comment inline why this is 3 to avoid it to be “corrected” by accident?

Could this be fixed when we introduce a new version for NetworkPolicyEvaluation API? I suppose yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Could this be fixed when we introduce a new version for NetworkPolicyEvaluation API? I suppose yes.

Yes I also believe that this can be fixed in a future version, without any negative impact. Protobuf message types are completely independent across versions.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
@antoninbas antoninbas dismissed stale reviews from Dyanngg and qiyueyao via 630f8d0 September 19, 2024 04:05
tnqn
tnqn previously approved these changes Sep 19, 2024
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
@antoninbas
Copy link
Contributor Author

/test-all

@antoninbas antoninbas merged commit cf16884 into antrea-io:main Sep 19, 2024
54 of 58 checks passed
@antoninbas antoninbas deleted the add-missing-objectmeta-to-networkpolicyevaluation-type branch September 19, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants