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 1876515: Fix inline taskSpec error in pipeline page #6541

Merged

Conversation

karthikjeeyar
Copy link
Contributor

@karthikjeeyar karthikjeeyar commented Sep 7, 2020

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

Problem:
Issue with inline spec over taskref causes the pipeline details page to break

Solution:
Handle the inline spec issue and skip the visualization

Screenshots:
image

Test cases:
image
PipelineVisualization tests
image

pipeline-actions tests
image

@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Sep 7, 2020
@karthikjeeyar karthikjeeyar changed the title Fix inline taskSpec error in pipeline page Bug 1876515: Fix inline taskSpec error in pipeline page Sep 7, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium 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 Sep 7, 2020
@openshift-ci-robot
Copy link
Contributor

@karthikjeeyar: This pull request references Bugzilla bug 1876515, 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 1876515: Fix inline taskSpec error in pipeline page

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.

@@ -181,7 +181,16 @@ const appendPipelineRunStatus = (pipeline, pipelineRun) => {
return mTask;
});
};

export const hasInlineTaskSpec = (pipeline: K8sResourceKind) => {
const tasks = (pipeline.spec && pipeline.spec.tasks) || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const tasks = (pipeline.spec && pipeline.spec.tasks) || [];
const tasks = pipeline.spec?.tasks ?? [];

@@ -192,7 +201,7 @@ export const getPipelineTasks = (
): PipelineVisualizationTaskItem[][] => {
// Each unit in 'out' array is termed as stage | out = [stage1 = [task1], stage2 = [task2,task3], stage3 = [task4]]
const out = [];
if (!pipeline.spec || !pipeline.spec.tasks) {
if (!pipeline.spec || !pipeline.spec.tasks || hasInlineTaskSpec(pipeline)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!pipeline.spec || !pipeline.spec.tasks || hasInlineTaskSpec(pipeline)) {
if (!pipeline.spec?.tasks || hasInlineTaskSpec(pipeline)) {

@karthikjeeyar karthikjeeyar force-pushed the fix-inline-spec branch 2 times, most recently from e5f062c to c9f7470 Compare September 8, 2020 06:46
Copy link
Contributor

@sahil143 sahil143 left a comment

Choose a reason for hiding this comment

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

/lgtm

verified changes locally

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

sahil143 commented Sep 9, 2020

/lgtm cancel

It breaks in the Edit Pipeline page
Screenshot 2020-09-09 at 3 26 47 PM

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

Added the check in edit scenario, so that if there is an inline taskSpec, it will not throw error and will allow us to add/modify the tasks in the builder form.
image

@andrewballantyne
Copy link
Contributor

andrewballantyne commented Sep 9, 2020

@karthikjeeyar I think we need UX here... I don't think it's appropriate to edit a Pipeline and clear out the tasks because they are using inline spec - this could have wildly unexpected results for the user. I think we need to take a path of least resistance here - it is an unsupported feature of the DevConsole. Maybe we showcase a message saying "Using tasks inlineSpec, which is unsupported" in the "visualization area" and removing the Edit Pipeline kebab option.

cc @bgliwa01 / @openshift/team-devconsole-ux

Comment on lines 186 to 191
let hasInlineSpec = false;
tasks.forEach((task) => {
if (!hasInlineSpec) {
hasInlineSpec = !!(task.taskSpec && !task.taskRef);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

You're re-implementing Array.prototype.some... best just use it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it.

@bgliwa01
Copy link

@karthikjeeyar I agree with @andrewballantyne we should remove the edit pipeline option in the kebab dropdown and then we can display the message "This Pipeline cannot be visualized. Pipeline taskSpec is not supported."

@andrewballantyne
Copy link
Contributor

@karthikjeeyar I agree with @andrewballantyne we should remove the edit pipeline option in the kebab dropdown and then we can display the message "This Pipeline cannot be visualized. Pipeline taskSpec is not supported."

@karthikjeeyar When you do this, make sure there is a gap under the message before the first label.

Thanks @bgliwa01 !

@openshift-ci-robot
Copy link
Contributor

@karthikjeeyar: This pull request references Bugzilla bug 1876515, 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 1876515: Fix inline taskSpec error in pipeline page

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.

@karthikjeeyar
Copy link
Contributor Author

Updated the code to hide the edit pipeline option and added the UX provided message to the visualization area.
@bgliwa01 Please take a look at the updated screenshots.
cc: @andrewballantyne

// Nothing to render
// TODO: Confirm wording with UX; ODC-1860
return <Alert variant="info" isInline title="This Pipeline has no tasks to visualize." />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the return? I think we can just have another return here.

EDIT: In case it's unclear, I'm asking you to just keep this simple and revert the changes you did here. Add the new if-statement and make it a return of the new alert. There is no reason not to exit early.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved it inside the block, so that it gets the margin-bottom style (for the gap underneath the message) from the odc-pipeline-visualization class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see... why don't we clean this up more and instead of treating errors differently, just have a variable called content or something and have 3 if-else statements... landing on rendering the Component as the fallback else.

It'll look cleaner and be easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, its more readable now. Updated it

@@ -181,7 +181,10 @@ const appendPipelineRunStatus = (pipeline, pipelineRun) => {
return mTask;
});
};

export const hasInlineTaskSpec = (pipeline: K8sResourceKind) => {
const tasks = pipeline?.spec.tasks ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

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

spec is not optional.

@@ -192,7 +195,7 @@ export const getPipelineTasks = (
): PipelineVisualizationTaskItem[][] => {
// Each unit in 'out' array is termed as stage | out = [stage1 = [task1], stage2 = [task2,task3], stage3 = [task4]]
const out = [];
if (!pipeline.spec || !pipeline.spec.tasks) {
if (!pipeline?.spec.tasks) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think this can ever happen anymore. Tasks of 1 is required by the operator. We can keep this if you change it to look for tasks also being an empty array.

Also spec is not optional.

@@ -12,7 +12,7 @@ export const mockPipelinesJSON: K8sResourceKind[] = [
params: [
{
name: 'APP_NAME',
type: 'string',
Copy link
Contributor

Choose a reason for hiding this comment

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

type should be allowed 🤔 Why did you remove this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah because it's not part of the type 😞

Can you just add it to the type instead?
It's supported by upstream

Each declared parameter has a type field, which can be set to either array or string.

We'll want the type to probably be:

  type: 'string' | 'array';

Instead of a straight string type... this way we can easily see what we support.

Copy link

@bgliwa01 bgliwa01 left a comment

Choose a reason for hiding this comment

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

lgtm

// Nothing to render
// TODO: Confirm wording with UX; ODC-1860
return <Alert variant="info" isInline title="This Pipeline has no tasks to visualize." />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see... why don't we clean this up more and instead of treating errors differently, just have a variable called content or something and have 3 if-else statements... landing on rendering the Component as the fallback else.

It'll look cleaner and be easier to read.

@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
kind?: string;
};
taskSpec?: PipelineTaskSpec;
taskRef?: PipelineTaskRef;
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@jerolimov jerolimov left a comment

Choose a reason for hiding this comment

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

Tested it locally, works fine 👍

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@jerolimov
Copy link
Member

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 4907c9d into openshift:master Sep 15, 2020
@openshift-ci-robot
Copy link
Contributor

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

Bugzilla bug 1876515 has been moved to the MODIFIED state.

In response to this:

Bug 1876515: Fix inline taskSpec error in pipeline page

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.

@andrewballantyne
Copy link
Contributor

/cherry-pick release-4.5

@openshift-cherrypick-robot

@andrewballantyne: new pull request created: #6638

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.

@spadgett spadgett added this to the v4.6 milestone Sep 16, 2020
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-medium Referenced Bugzilla bug's severity is medium 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