-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 structural OpenAPI schema to Tekton CRDs #8490
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @burigolucas. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
/kind documentation |
/ok-to-test |
Hi @vdemeester, I have identified issues with the CRDs. A few of them were invalid due to recursive fields. Following the fix proposed in this issue Generating CRD manifest for struct with recursive field, I have added the markers
in the affected fields and regenerated the CRDs. I have also disabled the embedded object meta as it does not provide useful schema in my opinion and only makes the files more bloated. AFAIK, there is still one issue to be solved, namely, the CRD for the |
Yeah, that's was the inital problem 😅 |
|
@burigolucas could we refer to another schema ? |
Are you trying |
Yeah it's what (
You mean the |
I would be fine only having the shema for the |
I have just tried to remove the pipelineSpec from the schema of the pipelineRun and it is now small enough, even with both versions of the CRD. But we might need to reduce other CRDs further if we need to support |
Removed also the schema of |
daba633
to
f1f45fb
Compare
I am "fine" with requiring things to be done using |
This would be for the CRDs only, right?
This way users could point to |
@afrittoli should it be the other way around for a while. Like next release we have a |
Sure, we can do that, I was trying to avoid too many changes :D but it's safer the way you proposed |
Should we then keep the current CRDs untouched and store the new generated CRDs with schemas in a different path? |
If possible, I would prefer to have one version of the CRDs in the repos and, at release time:
@vdemeester @burigolucas WDYT? |
I agree, but it means we need to change our CI script to use |
Thanks for your feedbacks @vdemeester and @afrittoli. I will soon review the scripts accordingly. Besides, I will have a second look on the schemas of |
- Implement POSIX script to update the OpenAPI schema to Tekton CRDs using controller-gen - Add updated CRDs with OpenAPI schema Note1: the current script 'hack/update-schemas.sh' return several errors/warnings and status code 1 from execution of the controller-gen CLI due to issues when parsing the schema from the source code. Note2: the controller-gen does not preserve the field "x-kubernetes-preserve-unknown-fields: true" in the root of the schema. This field is added by the 'hack/update-schemas.sh' script Note3: Markes were addded to avoid creating the schema for recursive types that results in invalid schemata. Related issue: kubernetes-sigs/controller-tools#585 Note4: Schema for PipelineSpec was omitted from PipelineRun to reduce size. A comment was added in the description of the field for the user to refer to the schema of Pipeline. Note5: Schema of TaskSpec was omitted from TaskRun to reduce size. A comment was added in the description of the field for the user to refer to the schema of Task.
f1f45fb
to
4604853
Compare
- Revise script to generate CRD schemas - Omit schema for Pod.spec.volumes, Pod.spec.affinity, VolumeClaimTemplate - Omit schema for TaskSpec in TaskRun - Omit schema for TaskSpec in Pipeline - Omit schema for PipelineSpec in PipelineRun - Add references to schema and API version in all omitted schemas
4604853
to
e4bbd38
Compare
@vdemeester, @afrittoli I have analyzed the schema more carefully and identified good candidates to omit from the schema (e.g., Pod.spec.volumes, Pod.spec.affinity, PersistentVolumeClaim). While omitting these schema, I have added a note in the description for the user where to locate the schema in the K8s API. With these changes, the CRDs are now significantly smaller and can be |
Thank you for this work @burigolucas - this sounds like a great solution to me |
One of the issues with the e2e is related to schema for fields which can have different types. E.g., the schema for |
- Schema for generic types are currently not supported by controller-gen, see kubernetes-sigs/controller-tools#844 - Fix bug in examples: - TaskSpec -> taskSpec - PipelineSpec -> pipelineSpec
I have added the schema for the feature flags as well and had to update unit tests and a few YAML examples due to the API server schema validation. This validation will cause breaking changes to users who were not creating CRs with a valid schema. I have updated the release notes accordingly. Besides, the schema for feature flags has changed with the fields starting with lower case instead of upper case. I am not able to run the e2e tests locally to fully test though. |
Changes
Address Issue 1461 by implementing a script to update the OpenAPI schema to Tekton CRDs using controller-gen and adding the updated CRDs with OpenAPI schema.
Revise unit tests and example YAML files to address issues caused by the now enabled API server schema validation.
Note that the current script
hack/update-schemas.sh
return several errors/warnings and status code 1 from execution of the controller-gen CLI due to issues when parsing the schema from the source code. Besides, processing multiple files at once is causing segmentation fault. Therefore, in the script, each file is processed separately. In addition, FIXME notes are added to be addressed in the future once new features become available in controller-gen.Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes