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
bgpv1: Consolidate CRD API to follow K8s API Conventions #26040
Conversation
cc @danehans |
9789bd6
to
a811886
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for woking on this! Now our API design looks very consistent. I left some nit picking comments.
4a064eb
to
aa3458d
Compare
e7faf37
to
3fa6902
Compare
Thanks for all the comments so far @YutaroHayakawa & @harsimran-pabla! As I addressed them, I squashed relevant commits and moved this PR out of draft - ready for the final review! |
72f1cdd
to
bc81751
Compare
68c2603
to
7d9c4e0
Compare
/test (rebased to fetch latest CI changes/fixes) |
API change is a bit of description changes. I think it's ready to merge. |
Modifies the type of recently added CRD fields of type `meta/v1.Duration` to integer type and their name to follow the K8s API Conventions rule: "Duration fields must be represented as integer fields with units being part of the field name (e.g. leaseDurationSeconds). We don't use Duration in the API since that would require clients to implement go-compatible parsing." Also enables defaulting for these fields on apiserver by using the kubebuilder:default tags (for static defaults). This includes the KeepaliveTimeSeconds field, which was defaulted at runtime to 1/3 of HoldTimeSeconds. As per K8s API Conventions, static defaults are preferred. It also makes the value more transparent to the user. Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
This allows the default value to be versioned with the API. It also provides consistency with the kubebuilder tags that define the default values - both are kept in the same source file. Also moves timers validation logic to API package to co-locate the validation logic for API constraints that cannot be expressed with kubebuilder markers with the API itself. Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
Modifies the types of CRD fileds to follow the K8s API Conventions rules: - "Use pointer types for all optional fields that do not have built-in nil value" - "Do not use unsigned integers, due to inconsistent support across languages and libraries" - "All public integer fields MUST use the Go (u)int32 or Go (u)int64 types, not (u)int" Also changes the types of the existing ASN CRD fileds to int64 to satisfy the above rules. Defaults ExportPodCIDR field of CiliumBGPVirtualRouter to false explicitly for consistency with other optional fields. As the default behavior remains the same, this is a backward-compatible change. Pointer types can be directly dereferenced in the reconcilers code. To allow that we provide defaulting methods for our API types, that can be used from the controllers / unit tests. Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
7d9c4e0
to
d857bb1
Compare
Add unit tests to newly added SetDefaults() and Validate() methods of the BGP CRD types. Do not perform detailed defaulting / validation checks in unit tests of other packages, to have that testing logic co-located within a single package. Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
d857bb1
to
ff34296
Compare
/test |
Rebased due to a conflicting change in the main branch. All green after the rebase - marking as ready to merge again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did an overall review on the PR. It looks that pkg/k8s/apis/cilium.io/v2alpha1/bgpp_types.go got a lot of modifications, did we consider on using v2alpha2
with a new CRD? If not, is there any upgrade path from users using v2alpha1 bgp?
I believe this PR does not introduce any breaking change to the types that were already released in Cilium 1.13. Most of the changes in this PR are on the fields that were added as recent "to be released" features in the past weeks (listed in the PR description). There are only 3 backward compatible changes on the previously released CRD fields - copying from this PR's description:
EDIT: so there is no need for any upgrade path, this change is transparent for existing users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification
This PR aims to consolidate the BGP control plane k8s API to follow the K8s API Conventions.
Although it modifies some filed names, it does it only for fields that have been added recently (not yet released in any Cilium version) as part of:
Already released API fields are modified only in a backward compatible way (e.g. changed internal type to a pointer, but no type change in the generated
CustomResourceDefinition
). The only changes of already released API in the generated ciliumbgppeeringpolicies.yaml are:exportPodCIDR
: added default value (false
, so not changing the default behaviour)localASN
+peerASN
: addedformat
annotation, but without the change of the underlyingtype
The changes are described in more detail in individual commits.
Although the diff looks pretty big, most of the changes are in the unit / component tests, where the API is actually used.
Fixes #25871