-
Notifications
You must be signed in to change notification settings - Fork 222
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
[TEP-0143] Concise Parameters and Results - proposed #1071
[TEP-0143] Concise Parameters and Results - proposed #1071
Conversation
3e10b78
to
de6e695
Compare
de6e695
to
0459f31
Compare
Hi @tektoncd/core-maintainers, ptal at this proposal, looking forward to your thoughts! Thanks! |
cc @khrm @pritidesai |
/kind tep |
/assign @pritidesai |
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 like the idea of that proposal (@abayer knows how often I bugged him about this param/result syntax 😛), but I don't see a way to have it in v1
. I would see this as the basis of a v2
API work.
|
||
Tekton is a cloud-native platform that aims to be the industry standard for CI/CD. However, its syntax is complex and verbose, making it tedious to use. This is one of the barriers to its adoption. To make Tekton more user-friendly, we need to simplify and concise its syntax. This will make it easier to author, read and adopt Tekton. | ||
|
||
This document proposes improving the syntax for `Parameters` and `Results`. Take a look at the release `Pipeline` as an example. Users need to repeatedly write name and value for the `Parameters` and `Results`, which is not necessary and very lengthy. |
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.
"Users need to repeatedly write name and value […]" applies on PipelineRun
am I right ?
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.
Yes! The proposal includs pipelinerun, taskrun, and pipeline, task
|
||
#### Parameters | ||
|
||
At authoring time, users declare string, array and object `Parameters` for `Tasks` and `Pipelines`. It is tedious to specify these fields because they are defined as sub-objects. We propose using maps instead of sub-objects to declare `Parameters`. The new syntax of `Params` will go under a new api field `Inputs.Params`. This is because we cannot modify the existing `Params` field because of our [Go compatibility policy][cp]. |
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.
We used to have inputs
as well, so I would be very caution re-introducing it.
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 think we will introduce them back in #1044, cc @jerop @afrittoli to confirm.
The main reason is that we can not change the current params and results, and we need to put them under a new api field, and tep-0139 will introduce artifacts with input and output, so it makes sense to add params and results there
### Create v2alpha1 API | ||
|
||
Create v2alpha1 API, change the `Param` and `Results` to use the new syntax without introducing new fields. However, this means that we have to maintain one more API version with minimal change from the current version. |
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 would definitely want to go that way for that proposal (aka going towards a v2…
API). If we do not, we are going to make the v1
API more convoluted as we go. And we cannot ever remove fields from v1
so.. having 2 ways to provide the same information on a API is generally not really ideal, and will be very confusing and very tricky to achieve implementation wise (what do we do if both are used, …)
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.
Yes that's a very good point and we have also discussed it as well!
From the implementation wise, 1) this will be an alpha feature gated by dedicated feature flag, this can make sure that users won't accidentally define both. 2) we will add validation to the webhook to make sure that only one of them is defined.
I agree that it is not ideal that users can define the same thing in 2 places, the way we mitigate it is to use feature flag, documentation.
And the main reason we propose to add in v1 is that v1 users can try out this new syntax and provide early feedback. Another reason is introducing v2alpha1 will introduce more maintaining efforts to tekton pipeline (not sure if this is a valid concern).
I think we're always open change the proposal to what's best for tekton 😄 .
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.
Hi @vdemeester @afrittoli, just want to learn more about your thoughts on getting early feedback from users by adding them in v1 api.
From the implementation perspective, if we add v2alpha1, we will need more efforts, e.g.:
- we need to consider conversion among v2alpha1, v1, v1beta1.
- developers making api changes to v1 will update v2alpha1.
So I don't think this is a good timing to introduce v2alpha1 considering that we just have v1 this year, and there are not many features we can introduce in v2alpha1.
If you think this proposal is not a good fit to v1(duplicate with current params and results). We may just change this proposal to add it to v2 in the future and don't work on it now.
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.
+1 this is not ideal UX in v1
. To me, the most valuable part to introduce this feature now but not in v2 is that we can collect some early feedback/data points which can help us make the right decision when moving to v2
.
I think gating it under a dedicated feature flag can mitigate the confusion to user. However, we may need to be more careful to promote this feature to beta
or stable
where the feature will be opted in by default (as part of the reason to support the feature in v1
is to collect early feedback).
We also need clear documentation to explain the context.
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.
Having 2 different ways to solve the same problems in the same API is, in my opinion, also not necessarily a good UX
.
Looking back, we even moved from inputs.params
to params
while bumping API version (v1alpha1
to v1beta1
) even though we could have done breaking changes in v1alpha1
.
The proposal of adding this to v1
, and in general to add a lot of new fields in v1
seems like we don't treat v1
as stable, or as complete enough to be considered as is. This is fine, but v1
is there, and is there for a while, and is considered stable from our user's perspective. We have to be very careful when adding new fields to v1
.
Any field we add to v1
(even behind a feature-flag) are there to stay (they can't be removed). Any field we add to v1
need to be documented (and would automatically be if we fix tektoncd/pipeline#1461 (and tektoncd/pipeline#3416 at the same time) — and for each "alpha" or experimental ones, we need to make it show as it in the doc, etc..
Other question arrives : kubectl
(and Kubernetes in general) is merging objects with kubectl apply
for example. This lead to problems between v1alpha1
and v1beta1
as it was merging inputs.params
with params
. Having both on the same object would also be an issue — I created my object with params
, I now want to try that new consice thing, I switch to inputs.params
and I apply, it breaks. But because it's on v1
, this issue could never be fixed for the v1
API as we cannot remove fields — we would be stuck with this issue until v2
(the stable one) and v1
gone and out of support (which would be.. in a really long time, years and years from now).
Having a v2alpha1
or a feature-flag is similar in that they require the user to do something. But one is way more explicit in its "experimental" nature, as you are using v2alphaX
API, so you know you shouldn't use it in production, you know it could break tomorrow.
From the implementation perspective, if we add v2alpha1, we will need more efforts, e.g.:
For me, this is not a concern. The aim is end-user consumption, happyness, etc. If we need to do more effort to make a better user experience, I'll choose this over and over.
- we need to consider conversion among v2alpha1, v1, v1beta1.
- developers making api changes to v1 will update v2alpha1.
That's the thing about v2alpha1
, it could be "incomplete" in way, as it's alpha, it's there for exploration.
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!
Having 2 different ways to solve the same problems in the same API is not a good UX.
Yes I agree, even if it is gated by a feature flag, users may get confused.
we need to be very careful to add new api into v1.
Yes I agree. Trusted artifacts is proposing to add inputs.artifacts
and outputs.artifacts
, so for tep-0143 we just need to add params and results to them.
Having both on the same object would also be an issue ...
I think this can be avoided by how we implement this? My current PoC is using mutation webhook to populate current params
with the inputs.params
, and we don't need to change the reconciler code. So if there is existing pipelinerun with params
, the new object would just have both inputs.params
and params
and won't break.
So I think "having 2 different ways of defining the same thing in api" is a valid reason that we should not add it to v1
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.
Having 2 different ways to solve the same problems in the same API is not a good UX.
Yes I agree, even if it is gated by a feature flag, users may get confused.
Indeed, so maybe we shouldn't do it?
we need to be very careful to add new api into v1.
Yes I agree. Trusted artifacts is proposing to add
inputs.artifacts
andoutputs.artifacts
, so for tep-0143 we just need to add params and results to them.
That's not the API I proposed for trusted artifacts.
It was later proposed to adopt inputs.artifacts
and outputs.artifacts
to match this proposal, not the other way around.
I'm still unsure whether we need the extra level of indentation with inputs
and outputs
. Do you have any more insights on the advantages of that?
I would argue that a v1alpha1
might be more easily adopted by users, because unless operators explicitly disable v1alpha1
, users can experiment with it. Feature flags instead are controller by the operator.
Using a different API version would mean that users could try and query existing resources via the v1alpha1
endpoint, to see how existing resources would look like in v1alpha1
format.
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! @afrittoli are you suggesting v1alpha1
or v2alpha1
?
It was later proposed to adopt inputs.artifacts and outputs.artifacts to match this proposal, not the other way around.
I'm still unsure whether we need the extra level of indentation with inputs and outputs. Do you have any more insights on the advantages of that?
Oh if so, I think we can just don't use inputs
and outputs
. I will update this PR to propose the change in a new api version
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.
We lose Type safety with this TEP.
Thanks! We have discussed this a bit in the thread of this doc. And we have also mentioned that this is a drawback in this proposal, I don't think there is a way to really solve it (e.g. we cannot really tell users that they have defined duplicate params with the map syntax) We can provide explicit documentation, yaml syntax check tools to mitigate this issue and I believe this is the trade-off we can make. Or there might be more severe type safety issues we miss? Please let us know, and if the proposal cannot address it, I think we can seek other alternatives. |
@Yongxuanzhang Yes, I didn't get time to discuss that further. |
# after | ||
inputs: | ||
params: | ||
hello: |
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.
This is fine and safe. It will be validated easily during the creation. It will be put to
map[string]struct.
# after | ||
inputs: | ||
params: | ||
hello: world |
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.
This is unsafe. I assume it will be decoded/unmarshal to:
map[string]interface{}
? Isn't it so?
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.
What happens is that we might need to have some reserved keywords for the string key
.
What happens if someone mistakenly indents serviceAccountName at the same level? Or some other top elements.
The present API won't let you create these.
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.
but the all these key: value
, fields defined under params
right?
serviceAccountName
comes under params
?
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.
serviceAccountName
doesn't come under params
. It's on a different level but here we don't know whether key serviceAccountName
is some params or spec.serviceAccountName . So we can't validate. We will need to reserve this.
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.
On a side note, we shouldn't think of this from trying to solve validation via Go code. Is it easier to validate in 1.26+ k8s using CEL Validating admission policies?
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.
This is unsafe. I assume it will be decoded/unmarshal to:
map[string]interface{}
? Isn't it so?
We will still use this function to unmarshal it, it will be map[string]ParamValue, so it is not interface{}
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.
What happens is that we might need to have some reserved keywords for the string
key
. What happens if someone mistakenly indents serviceAccountName at the same level? Or some other top elements.The present API won't let you create these.
Are you saying that the proposal won't work with reserved param? Let's say is a "paramA" is reserved, we can just add function to validation webhook to check if the map[string]ParamValue has a key of "paramA"?
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.
@khrm @Yongxuanzhang I'm not 100% I got it right, this is my understanding of the issue.
Current TaskRun
spec:
spec:
params:
- name: example
value: foo
serviceAccountName: default
New TaskRun
spec:
spec:
input:
params:
example: foo
serviceAccountName: default
With the new spec, if serviceAccountName
was not indented properly, you could have:
spec:
input:
params:
example: foo
serviceAccountName: default
Which would not fail validation if the Task
in question had a parameter called serviceAccountName
.
This could not happen with the current API. This could be prevented in the new syntax by forbidding serviceAccountName
as a parameter name.
@afrittoli Thanks! This could be a trade off we make and I think we need to collect users feedback as well. We cannot propose something we think good for users but actually causes confusions. So I will change this proposal to |
d2c04e9
to
29d34e2
Compare
Hi @vdemeester, @afrittoli, @pritidesai I have updated the proposal to proposed status, and change it to suggest adding in v2alpha1. Please take a look. Thanks! 🙏 |
07500ba
to
8f9f8e5
Compare
commit: {} | ||
``` | ||
|
||
At runtime, `Results` are stored in the status of `TaskRuns`, `PipelineRuns` and `CustomRuns` as sub-objects. We propose using maps instead of sub-objects to produce `Results` at runtime. We also propose removing the type field that’s added by default to all `Results` in status. |
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.
About the removal of type
, I guess that's because it can be inferred from the format of the result?
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 update, it looks good to me.
I still have a couple of comments, but nothing blocking the "proposed" state for me.
/approve
8f9f8e5
to
891178e
Compare
891178e
to
5b587ce
Compare
/assign @khrm |
This commit adds the proposal of concise params and results. Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
5b587ce
to
826083b
Compare
@dibyom @khrm @pritidesai can we please merge this as proposed? we will continue to discuss as we work towards making this proposal |
Merging as proposed sounds fine to me |
/approve Yes. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: afrittoli, dibyom, khrm, vdemeester 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 |
Thank you! /lgtm |
This commit adds the proposal of concise parameters and results.
Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com