Skip to content

Allow Start Last Run in the Overview to work again - #3227

Merged
openshift-merge-robot merged 1 commit into
openshift:masterfrom
andrewballantyne:fix-pipeline-run-overview
Nov 6, 2019
Merged

Allow Start Last Run in the Overview to work again#3227
openshift-merge-robot merged 1 commit into
openshift:masterfrom
andrewballantyne:fix-pipeline-run-overview

Conversation

@andrewballantyne

Copy link
Copy Markdown
Contributor

https://jira.coreos.com/browse/ODC-2177

Fixes the Start Last Run button on the Overview pane in Topology. It ran into a conflict with another work that reworked the API.

Issue:
StartLastRun

Fixed:
StartLastRunWorking

The shaking appears related to https://jira.coreos.com/browse/ODC-2122 if you look at the dev tools you can see the vibration happens at the time it remounts.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 4, 2019
@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Nov 4, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rare instances it wouldn't start immediately and showed - which I felt could be better shown as Pending.

@andrewballantyne andrewballantyne Nov 4, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This probably shouldn't be a hook. accessReview is optional (from rerunPipeline) but it must call this function every time due to the way hooks work.

@andrewballantyne

Copy link
Copy Markdown
Contributor Author

/assign @sahil143

This is fixing of your feature work during the merge conflicts that make this call no longer work. Please review and let me know if you think the heart of what you had is still here.

Comment thread frontend/packages/dev-console/src/utils/pipeline-actions.tsx Outdated
@andrewballantyne
andrewballantyne force-pushed the fix-pipeline-run-overview branch from 4541c76 to 185e8a0 Compare November 5, 2019 13:16
Comment on lines 147 to 151

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you checking for metadata.name and namespace here? If pipelineRun is there then metadata should be there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not according to the type. PipelineRun doesn't define it, but extends K8sResourceKind and it specifies it as optional. Of which inside metadata, name and namespace are also optional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAIK if pipelineRun exists then it will have metadata for sure. Check out the K8sResourceCommon type (metadata is not optional) we are migrating to it. Now, it's only used for DeploymentKind but it will be used for other types as well.
I don't think a Resource would exist without it's name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sahil143 unless the type we are currently using says this, I won't write code that "assumes" optional params are there. Types should not be just ignored when it's inconvenient. This code is currently only executed on click so it's not a render-cycle slowdown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

resources is not being used in the method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, but it's the signature of the KebabAction, and I need the customData for my callbacks:

export type KebabAction = (
  kind: K8sKind,
  obj: K8sResourceKind,
  resources?: any,
  customData?: any,
) => KebabOption;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can define {pipelineRunRedirect: true} here and make it optional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not entirely true. customData not being defined would get the default value. But if I provided null or a different set of customData I'd lose the ability to predefine my value.

This is a thought exercise of course, since I did change the logic up a bit. But for sake of argument, you should deal with this in two spots, because = ... only works on params that are explicitly defined as undefined or just not provided.

type RerunPipelineData = {
onComplete?: (pipelineRun: PipelineRun) => void;
};
const rerunPipeline: KebabAction = (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I logged https://jira.coreos.com/browse/ODC-2184 to address the fact that this function was converted to being a rereun pipeline runs.

Comment on lines +172 to +179
export const rerunPipelineAndStay: KebabAction = (kind: K8sKind, pipelineRun: PipelineRun) => {
return rerunPipeline(kind, pipelineRun);
};

export const rerunPipelineAndRedirect: KebabAction = (kind: K8sKind, pipelineRun: PipelineRun) => {
return rerunPipeline(kind, pipelineRun, null, { onComplete: handlePipelineRunSubmit });
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this change? I think flag thing (pipelineRunRedirect) worked fine.
You are still adding a check
typeof onComplete === 'function' ? onComplete : () => {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By default we can keep the flag true or false depending on majority usage of flag and make customData optional. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to make the API of using this not complex. The KebabActions are of a particular type, the caller shouldn't need to jump through hoops. I feel as an outsider calling to this utility of functions, I shouldn't care about how we set it up. rerunPipelineAndRedirect or rerunPipelineAndStay are very straight forward and easy to understand when you see the method call and easy to call.

@sahil143

sahil143 commented Nov 5, 2019

Copy link
Copy Markdown
Contributor

/lgtm

verified changes locally. It works!!
@andrewballantyne just wanted to make a note regarding the "mount and unmount issue with pipeline component" and we already have a bug for this (https://jira.coreos.com/browse/ODC-2122) but it has become noticeable on the UI.
mu

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2019
@andrewballantyne

Copy link
Copy Markdown
Contributor Author

@andrewballantyne just wanted to make a note regarding the "mount and unmount issue with pipeline component" and we already have a bug for this (https://jira.coreos.com/browse/ODC-2122) but it has become noticeable on the UI.

Yup :) I posted that in my description of the PR.

@rohitkrai03 rohitkrai03 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/approve

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, rohitkrai03, sahil143

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 6, 2019
@openshift-merge-robot
openshift-merge-robot merged commit af4a331 into openshift:master Nov 6, 2019
@spadgett spadgett added this to the v4.3 milestone Nov 7, 2019
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. component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants