pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

fix: possible error when 'stepTemplate' and 'steps' contain the same…

Open cugykw opened this issue 3 years ago • 24 comments

possible error when 'stepTemplate' and 'steps' contain the same env key

Changes

Now, when there is a conflict between the env structure of 'stepTemplate' and 'steps', it will eventually be merged according to the value in 'steps'.

Fixs: #5334

Submitter Checklist

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

  • [x] Has Docs included if any changes are user facing
  • [x] Has Tests included if any functionality added or changed
  • [x] Follows the commit message standard
  • [x] Meets the Tekton contributor standards (including functionality, content, code)
  • [x] 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
  • [x] Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • [x] Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

When stepTemplate and steps contain the same env key, they are finally merged into the env in steps.

cugykw avatar Aug 18 '22 09:08 cugykw

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: cugykw / name: yang kewei (75c8a8a3429db1203328b06382adb40809ef72d9)

Hi @cugykw. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 avatar Aug 18 '22 09:08 tekton-robot

/kind bug

cugykw avatar Aug 18 '22 10:08 cugykw

/ok-to-test

vdemeester avatar Aug 18 '22 14:08 vdemeester

[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 avatar Aug 18 '22 14:08 tekton-robot

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/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Aug 18 '22 14:08 tekton-robot

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/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Aug 18 '22 15:08 tekton-robot

The pull-tekton-pipeline-build-tests failure (https://prow.tekton.dev/view/gs/tekton-prow/pr-logs/pull/tektoncd_pipeline/5336/pull-tekton-pipeline-build-tests/1560280438541389824#1:build-log.txt%3A153-181) is legit - please run make fmt.

abayer avatar Aug 18 '22 15:08 abayer

The pull-tekton-pipeline-build-tests failure (https://prow.tekton.dev/view/gs/tekton-prow/pr-logs/pull/tektoncd_pipeline/5336/pull-tekton-pipeline-build-tests/1560280438541389824#1:build-log.txt%3A153-181) is legit - please run make fmt.

thanks, i have fixed

cugykw avatar Aug 19 '22 00:08 cugykw

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/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Aug 19 '22 00:08 tekton-robot

The pull-tekton-pipeline-build-tests failure (https://prow.tekton.dev/view/gs/tekton-prow/pr-logs/pull/tektoncd_pipeline/5336/pull-tekton-pipeline-build-tests/1560280438541389824#1:build-log.txt%3A153-181) is legit - please run make fmt.

@abayer , please review again, thanks

cugykw avatar Aug 20 '22 00:08 cugykw

/assign @abayer @jerop PTAL.

cugykw avatar Aug 25 '22 00:08 cugykw

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/merge.go 75.0% 80.4% 5.4
pkg/apis/pipeline/v1beta1/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Sep 18 '22 06:09 tekton-robot

/retest

cugykw avatar Sep 18 '22 06:09 cugykw

=== RUN   TestRealWaiterWaitMissingContent
--- PASS: TestRealWaiterWaitMissingContent (0.02s)
=== RUN   TestRealWaiterWaitWithContent
    waiter_test.go:134: expected Wait() to have detected a non-zero file size by now
--- FAIL: TestRealWaiterWaitWithContent (0.08s)
=== RUN   TestRealWaiterWaitWithErrorWaitfile
--- PASS: TestRealWaiterWaitWithErrorWaitfile (0.00s)
=== RUN   TestRealWaiterWaitWithBreakpointOnFailure
--- PASS: TestRealWaiterWaitWithBreakpointOnFailure (0.00s)
FAIL
FAIL	github.com/tektoncd/pipeline/cmd/entrypoint	2.482s
func TestRealWaiterWaitWithContent(t *testing.T) {
	tmp, err := ioutil.TempFile("", "real_waiter_test_file")
	if err != nil {
		t.Errorf("error creating temp file: %v", err)
	}
	defer os.Remove(tmp.Name())
	rw := realWaiter{}
	doneCh := make(chan struct{})
	go func() {
		err := rw.setWaitPollingInterval(testWaitPollingInterval).Wait(tmp.Name(), true, false)
		if err != nil {
			t.Errorf("error waiting on tmp file %q", tmp.Name())
		}
		close(doneCh)
	}()
	if err := ioutil.WriteFile(tmp.Name(), []byte("😺"), 0700); err != nil {
		t.Errorf("error writing content to temp file: %v", err)
	}
	delay := time.NewTimer(2 * testWaitPollingInterval)
	select {
	case <-doneCh:
		// Success
	case <-delay.C:
		t.Errorf("expected Wait() to have detected a non-zero file size by now")
	}
}

testWaitPollingInterval set too small?

cugykw avatar Sep 18 '22 07:09 cugykw

/ping @Yongxuanzhang

cugykw avatar Oct 09 '22 08:10 cugykw

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Jan 07 '23 08:01 tekton-robot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten with a justification. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

tekton-robot avatar Feb 06 '23 08:02 tekton-robot

/remove-lifecycle rotten /test check-pr-has-kind-label

vdemeester avatar Feb 06 '23 15:02 vdemeester

@vdemeester: 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 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:

/remove-lifecycle rotten /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 avatar Feb 06 '23 15:02 tekton-robot

/test check-pr-has-kind-label

jerop avatar Feb 07 '23 16:02 jerop

@jerop: 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 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 avatar Feb 07 '23 16:02 tekton-robot

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/merge.go 75.0% 80.4% 5.4
pkg/apis/pipeline/v1beta1/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Feb 14 '23 15:02 tekton-robot

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/merge.go 75.0% 80.4% 5.4
pkg/apis/pipeline/v1beta1/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Feb 14 '23 15:02 tekton-robot

[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 avatar Feb 15 '23 08:02 tekton-robot

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/merge.go 75.0% 80.4% 5.4
pkg/apis/pipeline/v1beta1/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Feb 15 '23 08:02 tekton-robot

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/merge.go 75.0% 80.4% 5.4
pkg/apis/pipeline/v1beta1/merge.go 82.4% 84.6% 2.3

tekton-robot avatar Feb 15 '23 08:02 tekton-robot

@cugykw thank you for this fix and for the patience with reviews 🙏🏾

changes look good to me, only request is to update the documentation for stepTemplate to indicate how we handle this name conflict - https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#specifying-a-step-template

@jerop Thanks to you, I tried to update the docs.

cugykw avatar Feb 15 '23 10:02 cugykw