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

Bug 1872336: Use metadata.generatorName when create a pipeline trigger #6248

Merged
merged 1 commit into from Sep 14, 2020

Conversation

jerolimov
Copy link
Member

@jerolimov jerolimov commented Aug 6, 2020

Fixes:
https://issues.redhat.com/browse/ODC-4236

Analysis / Root cause:
When adding a new Trigger for a Pipeline the web console creates an EventListener and a TriggerTemplate. The trigger templates contains a spec of a PipelineRun configuration (incl. parameters and resources) which will be created when an event is received. The current PipelineRun spec defines a fix name which could be created only once.

Solution Description:
To create multiple PipelineRun objects it is required to the a metaname generateName instead of name in the TriggerTemplate spec.

Some background infos I received from Andrew:

YAML diff:

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: trigger-template-docker-kvqrbt
spec:
  resourcetemplates:
    - apiVersion: tekton.dev/v1beta1
      kind: PipelineRun
      metadata:
-       name: docker-3p01ab
+       generateName: docker-
...

Screen shots / Gifs for design review:
Nothing changed in the UI

But here you see the relevant part of the test setup below:
odc-4236

Unit test coverage report:
Added some unit tests, no big change here.

Before:

=============================== Coverage summary ===============================
Statements   : 27.99% ( 20197/72165 )
Branches     : 17.94% ( 7515/41880 )
Functions    : 16.2% ( 2628/16222 )
Lines        : 29.82% ( 19255/64575 )
================================================================================

After:

=============================== Coverage summary ===============================
Statements   : 28% ( 20203/72165 )
Branches     : 17.96% ( 7523/41886 )
Functions    : 16.22% ( 2631/16222 )
Lines        : 29.83% ( 19261/64575 )
================================================================================

Test setup:

  • Install the OpenShift Pipeline operator
  • Create a Pipeline, for example Import from Git and select "Add Pipeline"
  • Open the pipeline and press the menu button in the top right corner and select "Add Trigger"
  • Fill the form and validate the generator trigger template
  • Please test also Start Pipeline, Re-run pipeline
  • And finally you can test the event listener with postman or curl. You find a GitHub POST JSON in the ticket. Ensure that the copied JSON does not contain JSON errors! You can just remove the lines with JSON errors!

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@jerolimov
Copy link
Member Author

/king bug
/cc @andrewballantyne
/assign andrewballantyne

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

Looks like you did a bit of a refactor to solve a long standing issue (ODC-2184)... unfortunately this is not going to be acceptable during the stability sprints. We should look to trim this down to just managing a use of generateName for the trigger modal.

If you want, you can copy this code out and open up another PR we can get into master when it switches to 4.6 - but that's likely not until Oct 2nd.

@jerolimov jerolimov force-pushed the odc-4236 branch 2 times, most recently from 5388662 to 59ffa52 Compare August 25, 2020 11:37
@jerolimov jerolimov changed the title Use metadata.generatorName when create a pipeline trigger [WIP] Use metadata.generatorName when create a pipeline trigger Aug 25, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 25, 2020
@jerolimov jerolimov changed the title [WIP] Use metadata.generatorName when create a pipeline trigger Bug 1872336: Use metadata.generatorName when create a pipeline trigger Aug 25, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 25, 2020
@openshift-ci-robot
Copy link
Contributor

@jerolimov: This pull request references Bugzilla bug 1872336, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1872336: Use metadata.generatorName when create a pipeline trigger

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.

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 25, 2020
@jerolimov
Copy link
Member Author

Looks like you did a bit of a refactor to solve a long standing issue (ODC-2184)... unfortunately this is not going to be acceptable during the stability sprints. We should look to trim this down to just managing a use of generateName for the trigger modal.

If you want, you can copy this code out and open up another PR we can get into master when it switches to 4.6 - but that's likely not until Oct 2nd.

@andrewballantyne I removed the refactoring and monitor ODC-2184 so that we can maybe apply these changes later. The original changes are available here: master...jerolimov:odc-4236-with-refactoring

I keep the extended unit tests. I'm open for any feedback. 😄

@openshift-ci-robot
Copy link
Contributor

@jerolimov: This pull request references Bugzilla bug 1872336, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1872336: Use metadata.generatorName when create a pipeline trigger

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.

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

I think you are on the right path for wanting to improve this... but as you found during your original changes, this is a broken path as it is today. Getting a Pipeline Run needs to be improved a lot and I don't know if it's worth while touching that path today. Just a straight improvement later to get us to the right spot might be the better call.

@@ -12,14 +12,15 @@ import {
} from '../../resource-types';

export const createTriggerTemplate = (
pipeline: Pipeline,
pipelineRun: PipelineRun,
params: TriggerTemplateKindParam[],
): TriggerTemplateKind => {
return {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could just override it for this one use-case rather than baking it into the (more or less) broken flow that exists today getting a Pipeline Run.

I think the refactor portion of your PR hit the nose of the problem, and that definitely is the better choice once we can refactor the code. Just not sure we need to pollute "crafting a pipeline run" if we are going to rewrite it in a few anyways.

I just suggest the modification here:

  const resource = _.omit(pipelineRun, 'metadata.name');
  resource.metadata.generateName = `${pipeline.metadata.name}-`;

Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewballantyne I though multiple times (and longer than I should) about this.. I would be happy if we stay with this (reduced) change. Keep the additional options parameter allow us to extend the unit tests for this case. Keep the additional tests instead of just "override" the generated json here is worth enough to touch 3 files.

I'm on your side that its still not perfect, but for me it looks like the right direction. 🤔

I'm also happy if we want split this method into 3 when starting with 4.7.

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

Going with Christoph's suggestion to keep this change.

Imo, a full refactor in 4.7 is much better than a partial change here, but I left it up to him to make the call. Let's hope this fragile piece of the code doesn't come back to haunt us.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 14, 2020
Copy link
Contributor

@rottencandy rottencandy left a comment

Choose a reason for hiding this comment

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

Tested locally
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, jerolimov, rottencandy

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

@openshift-merge-robot openshift-merge-robot merged commit c638b7f into openshift:master Sep 14, 2020
@openshift-ci-robot
Copy link
Contributor

@jerolimov: All pull requests linked via external trackers have merged:

Bugzilla bug 1872336 has been moved to the MODIFIED state.

In response to this:

Bug 1872336: Use metadata.generatorName when create a pipeline trigger

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.

@jerolimov
Copy link
Member Author

/cherry-pick release-4.5

@openshift-cherrypick-robot

@jerolimov: new pull request created: #6615

In response to this:

/cherry-pick release-4.5

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.

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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants