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

clarify in docs to not use apiVersion for taskRef for non-customtask #6704

Merged
merged 1 commit into from
May 25, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 23, 2023

Changes

This commit closes #6682. When apiversion and kind are both set for
task, it is also considered to be a custom task. If users want to refer
to tasks or cluster tasks, apiVersion shouldn't be set. This commit
clarify this in the docs.

/kind bug

Signed-off-by: Yongxuan Zhang [email protected]

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 23, 2023
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 23, 2023
@@ -224,7 +224,7 @@ type PipelineTask struct {
func (et *EmbeddedTask) IsCustomTask() bool {
// Note that if `apiVersion` is set to `"tekton.dev/v1beta1"` and `kind` is set to `"Task"`,
// the reference will be considered a Custom Task - https://github.com/tektoncd/pipeline/issues/6457
return et != nil && et.APIVersion != "" && et.Kind != ""
return et != nil && et.APIVersion != "" && et.Kind != "" && et.Kind != string(ClusterTaskKind)
Copy link
Member Author

@Yongxuanzhang Yongxuanzhang May 23, 2023

Choose a reason for hiding this comment

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

I wonder if checking (et.APIVersion!="v1beta1"&&et.Kind != string(ClusterTaskKind)) would be better?

Copy link
Member

Choose a reason for hiding this comment

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

ah don't think we should handle ClusterTask differently from Task -- maybe what we need is better documentation?

@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review May 23, 2023 17:57
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 23, 2023
@tekton-robot tekton-robot requested review from abayer and jerop May 23, 2023 17:58
@Yongxuanzhang
Copy link
Member Author

/assign @jerop

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

Can you please add some pipelinerun reconciler unit tests for this change? It might be beneficial to have e2e tests as well but we can start with reconciler tests

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 23, 2023
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

maybe what we need is better documentation that if apiversion and kind are set, we will create a customrun -- #6457

@@ -224,7 +224,7 @@ type PipelineTask struct {
func (et *EmbeddedTask) IsCustomTask() bool {
// Note that if `apiVersion` is set to `"tekton.dev/v1beta1"` and `kind` is set to `"Task"`,
// the reference will be considered a Custom Task - https://github.com/tektoncd/pipeline/issues/6457
return et != nil && et.APIVersion != "" && et.Kind != ""
return et != nil && et.APIVersion != "" && et.Kind != "" && et.Kind != string(ClusterTaskKind)
Copy link
Member

Choose a reason for hiding this comment

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

ah don't think we should handle ClusterTask differently from Task -- maybe what we need is better documentation?

@lbernick
Copy link
Member

From the linked issue, it sounds like this used to create TaskRuns instead of CustomRuns, and this was a regression when updating to v0.44. If you can't specify "ClusterTask" as the "kind" in a TaskRef, how would you specify a cluster task?

@jerop
Copy link
Member

jerop commented May 23, 2023

To clarify, you can create a "ClusterTask" with "kind" in TaskRef -- you just can't put APIVersion as well because that creates a CustomRun -- the user removed APIVersion and this resolved their issue

@Yongxuanzhang
Copy link
Member Author

Yes, I wonder if we need to fix it in code so users can still use apiversion+kind for cluster tasks?
Or we need to document and also tell users that you shouldn't use apiversion+kind for cluster task or tasks if you want to use them normally.
It seems that this is an hidden issue but triggered by we enable the custom task by default

@jerop
Copy link
Member

jerop commented May 23, 2023

I think we should document instead of changing the implementation because some users are relying on apiversion and kind being set to create customruns -- #6457

If we make an exception for "ClusterTask", would we do the same for "Task" and "Pipeline"? What about the Custom Task controllers that depend on the existing behavior, such as Pipeline in Pipeline Custom Task?

@jerop
Copy link
Member

jerop commented May 23, 2023

@Yongxuanzhang please update the commit and PR with more context, including #6459, #6505, #6457

@Yongxuanzhang
Copy link
Member Author

Yongxuanzhang commented May 23, 2023

What confused me is the "apiversion", if it is only used for custom tasks, and we don't use it for cluster task, tasks (since the storage version in the cluster is fixed, it is not possible to refer v1 tasks and v1beta1 tasks in the same cluster), we do need to clarify it to users (docs or even rename it)

I lean to update the docs to clarify it now, since there's no need to use "apiversion"+"kind" for cluster tasks and tasks, pipelines. Though we do support it in previous versions when the custom task is not enabled by default and we should have called this out to users when we introduced this change.

@lbernick
Copy link
Member

lbernick commented May 24, 2023

To clarify, you can create a "ClusterTask" with "kind" in TaskRef -- you just can't put APIVersion as well because that creates a CustomRun -- the user removed APIVersion and this resolved their issue

Ah sorry, I missed that. However, it does still sound like the user experienced different behavior for existing CRDs when upgrading. @Yongxuanzhang I'm curious why you say this might have started happening when we enabled custom tasks by default?

I agree with Yongxuan that if we only use APIVersion for custom tasks, it would be nice to rename it in some way. (We can't remove it but can add a new field and document that instead.)

I still find it confusing that "kind=Task" or ClusterTask, Pipeline, etc creates a custom task when apiversion is used :( but I'm ok with improving docs for now

@Yongxuanzhang
Copy link
Member Author

To clarify, you can create a "ClusterTask" with "kind" in TaskRef -- you just can't put APIVersion as well because that creates a CustomRun -- the user removed APIVersion and this resolved their issue

Ah sorry, I missed that. However, it does still sound like the user experienced different behavior for existing CRDs when upgrading. @Yongxuanzhang I'm curious why you say this might have started happening when we enabled custom tasks by default?

I agree with Yongxuan that if we only use APIVersion for custom tasks, it would be nice to rename it in some way. (We can't remove it but can add a new field and document that instead.)

I still find it confusing that "kind=Task" or ClusterTask, Pipeline, etc creates a custom task when apiversion is used :( but I'm ok with improving docs for now

Previously, if custom task is not enabled, users can use apiversion+task/clustertask in taskref to refer tasks, but after we enabled it by default, the taskref will be considered as a custom task and creates customrun instead of taskrun

@tekton-robot tekton-robot added the kind/documentation Categorizes issue or PR as related to documentation. label May 24, 2023
@tekton-robot
Copy link
Collaborator

@Yongxuanzhang: The label(s) kind/cancel cannot be applied, because the repository doesn't have them.

In response to this:

/kind bug cancel

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.

@tekton-robot
Copy link
Collaborator

@Yongxuanzhang: The label(s) kind/remove cannot be applied, because the repository doesn't have them.

In response to this:

/kind bug remove

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.

@Yongxuanzhang
Copy link
Member Author

/remove-kind bug

@tekton-robot tekton-robot removed the kind/bug Categorizes issue or PR as related to a bug. label May 24, 2023
@lbernick
Copy link
Member

Yongxuan can you check if we have any examples in the docs that use APIVersion for TaskRefs that aren't custom tasks?

@lbernick lbernick self-assigned this May 24, 2023
@Yongxuanzhang Yongxuanzhang changed the title cluster task is not custom task clarify in docs to not use apiVersion for taskRef for non-customtask May 24, 2023
@Yongxuanzhang
Copy link
Member Author

Yongxuan can you check if we have any examples in the docs that use APIVersion for TaskRefs that aren't custom tasks?

I cannot find any examples in docs, but found one in unit tests, just removed it

@lbernick
Copy link
Member

Thanks, this lgtm, just two quick suggestions:

  • This is a docs update, so I don't think it needs a release note
  • Let's update the custom run docs to specify that a non-empty api version will always create a customrun, and apiversion is for customruns only

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 24, 2023
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 24, 2023
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 24, 2023
Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

I think you may need to update the PR description

docs/pipelines.md Outdated Show resolved Hide resolved
This commit closes tektoncd#6682. When apiversion and kind are both set for
task, it is also considered to be a custom task. If users want to refer
to tasks or cluster tasks, apiVersion shouldn't be set. This commit
clarify this in the docs.

Signed-off-by: Yongxuan Zhang [email protected]
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2023
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 25, 2023
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, lbernick

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

@tekton-robot tekton-robot merged commit a1036ad into tektoncd:main May 25, 2023
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. kind/documentation Categorizes issue or PR as related to documentation. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterTask creates CustomRun (v0.41.1 -> v0.44.2)
4 participants