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

Add Tekton-owned Step, StepTemplate, and Sidecar #4778

Merged
merged 1 commit into from
May 3, 2022

Conversation

lbernick
Copy link
Member

@lbernick lbernick commented Apr 19, 2022

Changes

This commit copies the Container struct from Kubernetes into Tekton into the
existing structs Task.Step.Container, Task.Sidecar.Container, and Task.StepTemplate.
This change breaks the Tekton Go libraries, but does not require any changes to the yaml
that users provide. This should not change anything for users who do not use the Go libraries.

The reason for this change is to have more control over our Task API. For example,
we may want to modify the Container fields we support (e.g. #4737), or change fields to string types
to allow them to be parameterized (e.g. #4080). This commit is the first step towards being able to make changes
to parts of the Task API embedded in Container.

Part 1 of #4737

/kind misc

Submitter Checklist

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

  • n/a Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

[Change to Go libraries]: Task.Step, Task.StepTemplate, and Task.Sidecar use Container fields directly instead of embedding the Container struct

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/misc Categorizes issue or PR as a miscellaneuous one. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 19, 2022
@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@lbernick lbernick force-pushed the container branch 2 times, most recently from 595e908 to a0e12f2 Compare April 19, 2022 21:11
@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Really quick review but few questions:

  • Would it make sense to have two different struct for sidecars and steps ? (sidecars container would be step container + some things like readinessprobe, *probe …)
  • I see v1alpha1.Container, any reason for changing code in v1alpha1 ? (I guess it might be because we "share" the Step struct)

@lbernick
Copy link
Member Author

  • Would it make sense to have two different struct for sidecars and steps ? (sidecars container would be step container + some things like readinessprobe, *probe …)

Yes that's definitely where I see this going but I didn't want to remove any fields of the Step container yet (might need a TEP). But I can create two identical structs for sidecars and steps that we can later change, what do you think?

  • I see v1alpha1.Container, any reason for changing code in v1alpha1 ? (I guess it might be because we "share" the Step struct)

Yeah pretty much because we share the Step struct. I could update the v1alpha1 Step to just copy over all the fields of the v1beta1 step but then we have to keep them in sync. Open to doing that though.

@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@abayer
Copy link
Contributor

abayer commented Apr 22, 2022

fwiw, I'd lean towards copying over to v1alpha1 normally, but I'm not sure if it's worth it given that TEP-0105 is starting to come together for actually removing v1alpha1. Given that, the additional work involved in copying over and keeping in sync for the time being may not be worth it.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2022
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2022
@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/apis/pipeline/v1beta1/container_types.go Do not exist 0.0%

@imjasonh
Copy link
Member

I didn't want to remove any fields of the Step container yet (might need a TEP)

Happy to discuss if folks disagree, but in general I don't think deprecating a "feature" like, e.g., readinessProbes on a step container, should require a TEP. We should signal deprecations of these fields, wait 1+ release, and remove them. Especially so for things like terminationMessage which just silently don't do anything -- there's no way to use that correctly today.

If we think eventually we'd like to get to a spot where the Step and Sidecar types just have all the fields they reasonably could need and don't embed a Container type (even if it's owned by us), then I think we should just go straight to that and not incur the churn on ourselves and Go-API-consumers in having to account for two breaking type changes.

@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%

@lbernick
Copy link
Member Author

fwiw, I'd lean towards copying over to v1alpha1 normally, but I'm not sure if it's worth it given that TEP-0105 is starting to come together for actually removing v1alpha1. Given that, the additional work involved in copying over and keeping in sync for the time being may not be worth it.

That's fair-- I wasn't sure if it would be more work to continue to alias v1alpha1 types to v1beta1 types, or to copy the old v1beta1 struct over to v1alpha1 so I wouldn't have to modify the v1alpha1 tests. I already did most of the grunt work though for pipelines -- when you're talking about the work to support this are you anticipating that this will be more difficult for the CLI team?

I didn't want to remove any fields of the Step container yet (might need a TEP)

Happy to discuss if folks disagree, but in general I don't think deprecating a "feature" like, e.g., readinessProbes on a step container, should require a TEP. We should signal deprecations of these fields, wait 1+ release, and remove them. Especially so for things like terminationMessage which just silently don't do anything -- there's no way to use that correctly today.

If we think eventually we'd like to get to a spot where the Step and Sidecar types just have all the fields they reasonably could need and don't embed a Container type (even if it's owned by us), then I think we should just go straight to that and not incur the churn on ourselves and Go-API-consumers in having to account for two breaking type changes.

Point taken! I'd like to keep the scope of this PR to just swapping over the type definitions, and not deprecating anything. However, I created separate structs for Step and Sidecar containers to hopefully minimize churn. There's still a lot of copypasta so LMK if you'd prefer to see it done differently.

@lbernick
Copy link
Member Author

tests pass! 💪

/assign @vdemeester
/assign @imjasonh

@lbernick
Copy link
Member Author

sounds good-- I think this PR should be good to go then!

@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%

@imjasonh
Copy link
Member

sounds good-- I think this PR should be good to go then!

I think with this latest change we should just drop the StepContainer and SidecarContainer structs, and move the fields directly into Step and Sidecar. WDYT?

@lbernick
Copy link
Member Author

sounds good-- I think this PR should be good to go then!

I think with this latest change we should just drop the StepContainer and SidecarContainer structs, and move the fields directly into Step and Sidecar. WDYT?

Oh my bad, I understand now what you were suggesting. Will do, I'll comment here when I've made that change.

@lbernick
Copy link
Member Author

I'm thinking of keeping StepContainer so it can be reused in StepTemplate, but copying the container fields into sidecar as well, thoughts?

@imjasonh
Copy link
Member

I'm thinking of keeping StepContainer so it can be reused in StepTemplate, but copying the container fields into sidecar as well, thoughts?

Good question. Are there fields that make sense in a Step but not a StepTemplate, or vice versa? Can the type of StepTemplate just be Step?

@@ -139,7 +139,7 @@ type TaskResult struct {
// Step embeds the Container type, which allows it to include fields not
// provided by Container.
type Step struct {
corev1.Container `json:",inline"`
StepContainer `json:",inline"`
Copy link
Member

Choose a reason for hiding this comment

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

The idea was to move all that is to not have this inlined/embedded struct but have the field directly in. So no need for StepContainer.

@@ -172,7 +172,7 @@ type Step struct {

// Sidecar has nearly the same data structure as Step, consisting of a Container and an optional Script, but does not have the ability to timeout.
type Sidecar struct {
corev1.Container `json:",inline"`
SidecarContainer `json:",inline"`
Copy link
Member

Choose a reason for hiding this comment

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

The idea was to move all that is to not have this inlined/embedded struct but have the field directly in. So no need for SidecarContainer.

@lbernick
Copy link
Member Author

I'm thinking of keeping StepContainer so it can be reused in StepTemplate, but copying the container fields into sidecar as well, thoughts?

Good question. Are there fields that make sense in a Step but not a StepTemplate, or vice versa? Can the type of StepTemplate just be Step?

I think "Name" wouldn't make sense in StepTemplate since steps can't have the same name. In addition, "timeout" is not currently present in StepTemplate, but it could make sense. so maybe these fields should be directly copied into stepTemplate as well, thoughts?

@imjasonh
Copy link
Member

I think "Name" wouldn't make sense in StepTemplate since steps can't have the same name. In addition, "timeout" is not currently present in StepTemplate, but it could make sense. so maybe these fields should be directly copied into stepTemplate as well, thoughts?

Thanks for looking into it. It sounds like we should just copy these between the types that need them. I'm not sure we should add timeout to StepTemplate in this PR, but it's something worth keeping in mind for a future change.

@lbernick
Copy link
Member Author

I think "Name" wouldn't make sense in StepTemplate since steps can't have the same name. In addition, "timeout" is not currently present in StepTemplate, but it could make sense. so maybe these fields should be directly copied into stepTemplate as well, thoughts?

Thanks for looking into it. It sounds like we should just copy these between the types that need them. I'm not sure we should add timeout to StepTemplate in this PR, but it's something worth keeping in mind for a future change.

Agreed! I don't want to change the user facing API at all with this PR-- just mentioning timeout as something that could be added in the future.

@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/merge.go 81.8% 82.4% 0.5
pkg/reconciler/taskrun/resources/apply.go 99.2% 99.2% 0.0

@lbernick lbernick changed the title Add Tekton-owned Container struct Add Tekton-owned Step, StepTemplate, and Sidecar Apr 29, 2022
@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/merge.go 81.8% 82.4% 0.5
pkg/reconciler/taskrun/resources/apply.go 99.2% 99.2% 0.0

@lbernick
Copy link
Member Author

@vdemeester @imjasonh I've addressed your feedback

@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/merge.go 81.8% 82.4% 0.5
pkg/reconciler/taskrun/resources/apply.go 99.2% 99.2% 0.0

This commit copies the Container struct from Kubernetes into Tekton into the
existing structs Task.Step.Container, Task.Sidecar.Container, and Task.StepTemplate.
This change breaks the Tekton Go libraries, but does not require any changes to the yaml
that users provide. This should not change anything for users who do not use the Go libraries.

The reason for this change is to have more control over our Task API. For example,
we may want to modify the Container fields we support, or change fields to string types
to allow them to be parameterized. This commit is the first step towards being able to make changes
to parts of the Task API embedded in Container.
@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/apis/pipeline/v1beta1/container_types.go Do not exist 100.0%
pkg/apis/pipeline/v1beta1/merge.go 81.8% 82.4% 0.5
pkg/reconciler/taskrun/resources/apply.go 99.2% 99.2% 0.0

Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks for this!

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 30, 2022
@lbernick
Copy link
Member Author

lbernick commented May 2, 2022

Thanks for this!

Happy to help!

/test pull-tekton-pipeline-alpha-integration-tests
/test pull-tekton-pipeline-integration-tests

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/meow

@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

/meow

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 3, 2022
@tekton-robot tekton-robot merged commit 7de70f1 into tektoncd:main May 3, 2022
@lbernick lbernick deleted the container branch August 15, 2022 13:33
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/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants