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 CloudEvents for Run definitions #4659

Merged
merged 1 commit into from
Mar 14, 2022
Merged

Conversation

afrittoli
Copy link
Member

@afrittoli afrittoli commented Mar 10, 2022

Changes

Add CloudEvents for Run definitions

Add the definitions for new CloudEvents for Runs.
The events are not sent yet. The event types are documented and
the cloudevent package supports creating events for Runs.

Partially addresses #3862
Depends-on: #4658

/kind feature

Submitter Checklist

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

  • 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 or deleted (only if no user facing changes)

Release Notes

CloudEvents for Run have been defined, but they are not sent yet.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 10, 2022
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2022
@afrittoli afrittoli changed the title Run events Add CloudEvents for Run definitions Mar 10, 2022
@afrittoli afrittoli added this to the Pipelines v0.34 milestone Mar 10, 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/v1alpha1/run_types.go 61.5% 59.3% -2.3
pkg/reconciler/events/cloudevent/cloudevent.go 91.2% 91.0% -0.2

@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/v1alpha1/run_types.go 61.5% 59.3% -2.3
pkg/reconciler/events/cloudevent/cloudevent.go 91.2% 91.0% -0.2

@afrittoli
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@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/events/cloudevent/cloudevent.go 91.2% 91.0% -0.2

This was referenced Mar 11, 2022
@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 Mar 11, 2022
@afrittoli
Copy link
Member Author

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

1 similar comment
@afrittoli
Copy link
Member Author

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

@@ -6,11 +6,12 @@ weight: 700
-->
# Events in Tekton

Tekton's task controller emits [Kubernetes events](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#event-v1-core)
Copy link
Member

Choose a reason for hiding this comment

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

just some grammar nits: controllers emits -> controllers emit and the underlying TaskRun do -> the underlying TaskRuns do

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, thank you!

@@ -68,6 +69,12 @@ Resource |Event |Event Type
`PipelineRun` | `Condition Change while Running` | `dev.tekton.event.pipelinerun.unknown.v1`
`PipelineRun` | `Succeed` | `dev.tekton.event.pipelinerun.successful.v1`
`PipelineRun` | `Failed` | `dev.tekton.event.pipelinerun.failed.v1`
`Run` | `Started` | `dev.tekton.event.run.started.v1`
Copy link
Member

@lbernick lbernick Mar 11, 2022

Choose a reason for hiding this comment

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

what's the reason not to send a condition change while running event? is this because we don't know what the run's previous status was, and can't make assumptions based on what it currently is? Is this a feature users might want?

Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot make assumptions about the Run and it will use its Conditions beyond what we specify in the custom task interface. So we can see that the resource has been created (start), we can see that an initial condition was set (running) and we can see when it's finished (successfully or not).

},
ObjectMeta: metav1.ObjectMeta{
Name: runName,
Namespace: "marshmallow",
Copy link
Member

Choose a reason for hiding this comment

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

:)

pkg/reconciler/events/cloudevent/cloudevent_test.go Outdated Show resolved Hide resolved
pkg/reconciler/events/cloudevent/cloudevent_test.go Outdated Show resolved Hide resolved

for _, c := range runTests {
t.Run(c.desc, func(t *testing.T) {
names.TestingSeed()
Copy link
Member

Choose a reason for hiding this comment

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

I see names.TestingSeed a lot in our tests-- what's the reason it's needed here, just out of curiosity?

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 paste? I wondered the same but I lazy :P I will try to find out

Copy link
Member

Choose a reason for hiding this comment

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

its there for a reason, I have been wondering about it as well since I started writing unit tests.

It was introduced to use fixed seed for the generated names as part of PR #491. This PR fixed the issue where it was reported the resource names were too long #481.

@afrittoli some of these might no longer be needed since now we have fixed names for some of the resources as your implemented in #4361.

I generally comment out one line at a time to see if its breaking my test if I am not sure what that code is doing 😄 Or add the same call twice 🙃 to understand the impact.

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 @pritidesai - good idea :)

names.TestingSeed is used to initialise the random generator used in names, so that you can get know what name to expect to validate results in tests. As @pritidesai mentioned, the need for this is probably reduced now that children resources have a more predictable name.

CloudEvent tests only match event types, so the name seed is not strictly required. It does cost anything or do any harm either, but I'll remove it as it's not needed.

Add the definitions for new CloudEvents for Runs.
The events are not sent yet. The event types are documented and
the cloudevent package supports creating events for Runs.

Partially addresses tektoncd#3862

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
@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/events/cloudevent/cloudevent.go 91.2% 91.0% -0.2

@afrittoli
Copy link
Member Author

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

@lbernick
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2022
@tekton-robot tekton-robot merged commit e4ce133 into tektoncd:main Mar 14, 2022
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/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

5 participants