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

Separate v1beta1.TaskObject to Task and ClusterTask in TaskRun Reconciler #6452

Closed
wants to merge 1 commit into from

Conversation

JeromeJu
Copy link
Member

@JeromeJu JeromeJu commented Mar 29, 2023

Changes

This commit is WIP.
This commit separates v1beta1.TaskObject to Task and ClusterTask to get prepared for v1 storage swap.

part of #5979
/kind misc

I wish I did have a nicer way of breaking up v1beta1.TaskObject instead of returning one of the two CRDs. Any suggestions would be much appreciated

Submitter Checklist

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

  • [n/a] Has Docs included if any changes are user facing
  • 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
  • [n/a] Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • [n/a] 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-none Denotes a PR that doesnt merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 29, 2023
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign pritidesai after the PR has been reviewed.
You can assign the PR to them by writing /assign @pritidesai in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 29, 2023
@tekton-robot tekton-robot added kind/misc Categorizes issue or PR as a miscellaneuous one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. labels Mar 29, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 86.8% -2.2
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 76.7% -23.3
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 86.8% -2.2
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 76.7% -23.3
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

return
}

if d := cmp.Diff(resolvedTask, tc.expected); d != "" {
Copy link
Member Author

Choose a reason for hiding this comment

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

Could you please help me to understand why the nil pointers here are not asserted equal with nil tc.expected here even with the cmpopts.EquateEmpty?
cc @Yongxuanzhang

Copy link
Member

Choose a reason for hiding this comment

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

the previous test cases are all comparing with nil, so I think it should work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

need to change the expected from runtime.Object to *v1beta1.Task

Copy link
Member Author

@JeromeJu JeromeJu Mar 30, 2023

Choose a reason for hiding this comment

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

Could we check if it makes sense to cast the expected nil as (*v1beta1.Task)(nil) while keeping the expected as runtime.Object for being more generic in the test case struct?

Copy link
Member

Choose a reason for hiding this comment

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

I think we could just use *v1beta1.Task

Copy link
Member Author

Choose a reason for hiding this comment

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

Taking a second look on this, I personally feel that maybe we should keep runtime.Object since tc.expected could also be a ClusterTaskKind even though that we do not necessarily need it since trustedResources won't verify ClusterTask. 🤔 please feel free to help correct if I'm mistaken

Copy link
Member

Choose a reason for hiding this comment

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

We changed VerifyTask's in this PR to pass task not taskobject, so in tests we should test task

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the pointer! updated.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 89.2% 0.1
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 76.7% -23.3
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 89.2% 0.1
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 86.7% -13.3
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 89.2% 0.1
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 86.7% -13.3
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 89.2% 0.1
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 93.3% -6.7
pkg/trustedresources/verify.go 95.2% 94.4% -0.9

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/reconciler/taskrun/resources/taskspec.go 100.0% 93.3% -6.7
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@JeromeJu
Copy link
Member Author

The test coverage drop was resulted from separating the TaskObject, while since ClusterTask won't get verified as trustedResources, it would not be necessary to restore it with new ClusterTask test case?

@JeromeJu JeromeJu changed the title [WIP] Separate v1beta1.TaskObject to Task and ClusterTask in Reconciler Separate v1beta1.TaskObject to Task and ClusterTask in TaskRun Reconciler Mar 30, 2023
@JeromeJu JeromeJu marked this pull request as ready for review March 30, 2023 13:01
@JeromeJu JeromeJu removed the request for review from vdemeester March 30, 2023 13:01
@JeromeJu JeromeJu requested review from Yongxuanzhang and removed request for lbernick March 30, 2023 13:01
@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 Mar 30, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

// v1beta1.TaskObject.
func resolveTask(ctx context.Context, resolver remote.Resolver, name string, kind v1beta1.TaskKind, k8s kubernetes.Interface) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) {
// v1beta1.Task or v1beta1.ClusterTask
func resolveTask(ctx context.Context, resolver remote.Resolver, name string, kind v1beta1.TaskKind, k8s kubernetes.Interface) (*v1beta1.Task, *v1beta1.ClusterTask, *v1beta1.ConfigSource, error) {
Copy link
Member

Choose a reason for hiding this comment

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

instead of returning a task and a clusterTask, could we instead convert a clusterTask definition into a Task and just return the Task?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I also wanted to do so but I am not sure if there is a way to convert it back to a ClusterTask as specified at

return resolveTask(ctx, resolver, name, kind, k8s)
without any extra flags?

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to convert back into a clustertask?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think for the case of a remote-cluster-task, https://github.com/tektoncd/pipeline/blob/main/pkg/reconciler/taskrun/resources/taskref_test.go#L376-L407 the resolveTask and the upstream of its caller GetTaskFunc shall return a ClusterTask at the end?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about those tests, but we just need to fetch the task definition from the cluster, store the task spec in the taskrun status, and execute it. we don't need to keep track of the fact that it's a clustertask. If you take a look at resolveTask, only the name and task spec (not the task kind) are used from the results of getTask.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @lbernick , I updated the alternative at #6471, would be happy to close the current PR if #6471 is clearer.

One concern was that I am not fully sure when we swap all v1beta1 to v1, if it is still ideal handling ClusterTask? Would be more explicit having one more return value in the getTaskFunc while we are also converting it to v1.Task?

Copy link
Member

Choose a reason for hiding this comment

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

We can probably convert a v1beta1 ClusterTask spec to a v1 TaskSpec, so I'm not concerned about the proposed solution after swapping to v1.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 95.4% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

…iler

This commit separates v1beta1.TaskObject to Task and ClusterTask to get prepared for v1 storage swap.
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 95.8% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.3% 95.8% -0.5
pkg/reconciler/taskrun/resources/taskref.go 89.0% 88.2% -0.9
pkg/trustedresources/verify.go 95.2% 95.3% 0.1

@JeromeJu
Copy link
Member Author

closing #6471 as the alternative that is cleaner than the current PR
Thanks to the reviews @lbernick and @Yongxuanzhang .

@JeromeJu JeromeJu closed this Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/misc Categorizes issue or PR as a miscellaneuous one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants