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

TEP-0142: Introduce StepResults in Steps, StepActions #7382

Merged

Conversation

chitrangpatel
Copy link
Member

@chitrangpatel chitrangpatel commented Nov 17, 2023

This PR introduces StepResult in Steps. This will allow us to hold StepAction's result declarations and use it later for replacements and other logic that happens later down the chain. It will be populated by the controller when it fetches StepActions in a followup PR.

Mostly this is auto-generated and refactored code.

Changes

Refactoring:

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

[WIP] Introduce StepResults in Steps for StepAction's Result storage.

/kind feature

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Nov 17, 2023
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 17, 2023
@chitrangpatel chitrangpatel requested review from Yongxuanzhang and removed request for vdemeester and bobcatfish November 17, 2023 02:31
@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Nov 17, 2023
@chitrangpatel
Copy link
Member Author

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@chitrangpatel: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-beta-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test pull-tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test check-pr-has-kind-label

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

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/v1/result_validation.go 100.0% 98.1% -1.9
pkg/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/result_validation.go 100.0% 97.9% -2.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

@chitrangpatel chitrangpatel changed the title TEP-0142: Introduce StepResults in Steps TEP-0142: Introduce StepResults in Steps, StepActions Nov 17, 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/apis/pipeline/v1/result_validation.go 100.0% 98.1% -1.9
pkg/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/result_validation.go 100.0% 97.9% -2.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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 to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

@chitrangpatel
Copy link
Member Author

/retest

@chitrangpatel
Copy link
Member Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 17, 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/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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 to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

pkg/apis/pipeline/v1/container_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/result_validation.go Outdated Show resolved Hide resolved
} else {
if len(s.Params) > 0 {
errs = errs.Also(&apis.FieldError{
Message: "params cannot be used without Ref",
Paths: []string{"params"},
})
}
if len(s.Results) > 0 {
if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableStepActions {
return apis.ErrGeneric("feature flag %s should be set to true in order to use Results in Steps.", config.EnableStepActions)
Copy link
Member

Choose a reason for hiding this comment

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

You only want to fail if it's a Create, or an Update where the field was originally empty. Otherwise you can cause an object to get stuck because reconcilers can't update the object to remove finalizers if the flag gets disabled mid-execution.

Knative has some helper funcs here to help you extract this data - i.e. https://pkg.go.dev/knative.dev/pkg@v0.0.0-20231115001034-97c7258e3a98/apis#GetBaseline

Copy link
Member Author

Choose a reason for hiding this comment

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

So the original field can be non-empty.
i.e. if Users choose to use results for inlined steps.

They just need to enable-step-actions for this, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

done. I made use of IsInCreate and IsInUpdate for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

The controller context has these both set to false. But for web hook events, these are set appropriately. This means that during web hook validation, we can enforce this. In the controller logic, this does not really need to be validated since it made it past the web hook.

Copy link
Member

Choose a reason for hiding this comment

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

Mostly sgtm, but apis.IsInUpdate(ctx) isn't sufficient, since it would still reject updates to unrelated fields / finalizers if the flag was disabled. :(

We also need to check if the field we want to check has changed - you can grab the old object via GetBaseline

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it. I implemented the fix. If an update event, we compare with the baseline and check if the step results have diverged. Only then we check if the feature flag is enabled.

pkg/apis/pipeline/v1/result_validation.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/result_validation.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/result_validation.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/result_validation.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1beta1/result_types.go Outdated Show resolved Hide resolved
@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/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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/apis/pipeline/v1/task_validation.go 98.2% 98.3% 0.1
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

pkg/apis/pipeline/v1/result_types.go Show resolved Hide resolved
pkg/apis/pipeline/v1/container_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/container_types.go Outdated Show resolved Hide resolved
@chitrangpatel
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 21, 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/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.4% 0.2

@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/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.4% 0.2

pkg/apis/pipeline/v1/container_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/result_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/task_validation_test.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1beta1/container_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1beta1/result_types.go Outdated Show resolved Hide resolved
@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/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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 to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2023
pkg/apis/pipeline/v1/result_types.go Outdated Show resolved Hide resolved
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [Yongxuanzhang,jerop]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

This PR introduces `StepResults` in Steps.
Copy link
Member

@Yongxuanzhang Yongxuanzhang 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 Nov 22, 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/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.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/apis/pipeline/v1/task_validation.go 98.2% 98.4% 0.2
pkg/apis/pipeline/v1alpha1/stepaction_validation.go 99.0% 98.9% -0.1
pkg/apis/pipeline/v1beta1/task_validation.go 98.2% 98.3% 0.1

@tekton-robot tekton-robot merged commit 140b633 into tektoncd:main Nov 22, 2023
12 of 13 checks passed
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/feature Categorizes issue or PR as related to a new feature. 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.

None yet

5 participants