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

check beta feature flag for v1 TaskSpec's ValidateParamArrayIndex #6613

Merged
merged 1 commit into from
May 9, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 2, 2023

Changes

This commit closes #6607. TaskSpec's member function ValidateParamArrayIndex checks alpha feature flag, but array indexing is promoted to beta feature and we should check beta flag instead. This commit fixes this issue and update doc to explicitly include array indexing as beta feature.

/kind bug

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com

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

check beta feature flag for v1 TaskSpec's ValidateParamArrayIndex instead of alpha flag, since array indexing is beta feature

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 2, 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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.0% -0.0

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.0% -0.0

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2023
@@ -612,8 +612,7 @@ func isParamRefs(s string) bool {
// - `trParams` are params from taskrun.
// - `taskSpec` contains params declarations.
func (ts *TaskSpec) ValidateParamArrayIndex(ctx context.Context, params Params) error {
cfg := config.FromContextOrDefaults(ctx)
if cfg.FeatureFlags.EnableAPIFields != config.AlphaAPIFields {
if !config.CheckAlphaOrBetaAPIFields(ctx) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed, since setting "stable" for v1beta1 also enables beta features

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh 🤯
how about v1? Should we remove it from v1?

Copy link
Member

Choose a reason for hiding this comment

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

In v1 we do check for beta API fields, so it makes sense to keep in v1

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
Copy link
Member

lbernick commented May 2, 2023

/approve cancel

@tekton-robot tekton-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2023
@Yongxuanzhang Yongxuanzhang changed the title check beta feature flag for TaskSpec's ValidateParamArrayIndex check beta feature flag for v1 TaskSpec's ValidateParamArrayIndex May 3, 2023
@lbernick
Copy link
Member

lbernick commented May 3, 2023

I think we should consider whether this function should return an error, instead of nil, if a task is using a feature where "enable-api-fields" is set to the wrong value. This is basically saying that if a task is using array param indexing and the index is out of bounds, this won't return an error if "enable-api-fields" is beta.

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@Yongxuanzhang
Copy link
Member Author

I think we should consider whether this function should return an error, instead of nil, if a task is using a feature where "enable-api-fields" is set to the wrong value.

Can we set "enable-api-fields" to random value? I think this function can validate it

func setEnabledAPIFields(cfgMap map[string]string, defaultValue string, feature *string) error {
value := defaultValue
if cfg, ok := cfgMap[enableAPIFields]; ok {
value = strings.ToLower(cfg)
}
switch value {
case AlphaAPIFields, BetaAPIFields, StableAPIFields:
*feature = value
default:
return fmt.Errorf("invalid value for feature flag %q: %q", enableAPIFields, value)
}
return nil
}

This is basically saying that if a task is using array param indexing and the index is out of bounds, this won't return an error if "enable-api-fields" is beta.

Did you mean v1 or v1beta1 task?

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@lbernick
Copy link
Member

lbernick commented May 9, 2023

@Yongxuanzhang based on @jerop's feedback on #6617 let's merge your PR first. I think you should remove the reconciler checks for alpha/beta flags, since with this change it would be possible to create a v1beta1 task with array indexing but then have it not work correctly in the reconciler. Please also pull in the tests TestPipelineWithBetaFields and TestTaskWithBetaFields from #6617.

We'll also need a release note indicating the bug fix of not requiring the "beta" feature flag for array indexing in beta tasks/pipelines.

@lbernick
Copy link
Member

lbernick commented May 9, 2023

@Yongxuanzhang can you also add array indexing to the list of beta features?

@Yongxuanzhang
Copy link
Member Author

@Yongxuanzhang can you also add array indexing to the list of beta features?

I think array indexing is already in the list(it's part of tep-76), what's missing is the tep-75 object param and results maybe I can open another small pr to update it?

This commit closes tektoncd#6607. V1 TaskSpec's member function
ValidateParamArrayIndex checks alpha feature flag, but array indexing is
promoted to beta feature and we should check beta flag instead. And for
v1beta1 the beta is on by default so we don't check the beta flag. This
commit fixes this issue and also update doc.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@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 96.9% 96.9% -0.0
pkg/apis/pipeline/v1beta1/pipeline_validation.go 99.1% 99.4% 0.3
pkg/apis/pipeline/v1beta1/task_validation.go 97.0% 97.3% 0.3

@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 May 9, 2023
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 9, 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 9, 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

@jerop
Copy link
Member

jerop commented May 9, 2023

/test pull-tekton-pipeline-build-tests

@tekton-robot tekton-robot merged commit 1df3fc5 into tektoncd:main May 9, 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/bug Categorizes issue or PR as related to a bug. 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/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.

ValidateParamArrayIndex for taskSpec should check beta flag.
4 participants