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
update pipelinerun graph to show past pipeline structure #6960
update pipelinerun graph to show past pipeline structure #6960
Conversation
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally, works as expected
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I don't think we need to keep the dependancy on Pipeline
. It is true that 1.0.1 of the Operator does still require it but based on the Compatibility Matrix 4.7 is going to be a far cry away from upstream Pipelines not having this feature (which was added in 0.12).
For sanity for the customer's cluster, I think we could go back 1 (1.2) or even more safety 2 (1.1) versions and still give that support so they are not getting a broken UI immediately after upgrading but not changing their channel. If memory serves correctly, when the Operator updates to give us an ocp-4.7
channel, they'll remove the ocp-4.5
channel. Which will remove any chance for unsupported code to exist.
The easiest approach to solving this ask I think is to just remove the requirement of Pipeline from getExecutedPipeline
(see my comment below to get you started).
export const getExecutedPipeline = (pipeline: Pipeline, pipelineRun: PipelineRun): Pipeline => { | ||
return { | ||
...pipeline, | ||
...(pipelineRun?.status?.pipelineSpec && { spec: pipelineRun?.status?.pipelineSpec }), | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to do two things here:
- Remove the dependancy on Pipeline and trim it out along all the call paths (I just did this and it's quite a bit of changes and adjustments, no references to Pipeline should exist in the call paths)
- Rename it to something like (don't have to take this if you have something better)
getPipelineFromPipelineRun
Tests will need to be updated naturally when this happens, since getTaskStatus
heavily uses Pipeline. We may even need to update the test data to add pipelineSpec
(which should be a mirror - maybe break that out to a var? - of the pipeline.spec used in the same data structure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the pipeline dependency in the call paths, updated test data and tests as well.
7434a46
to
b99a150
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more touch ups please.
return <PipelineVisualization pipeline={pipeline} pipelineRun={pipelineRun} />; | ||
return ( | ||
<PipelineVisualization | ||
pipeline={getPipelineFromPipelineRun(pipelineRun) || pipeline} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a PipelineRun visualization, it never needs the Pipeline, let's kill the fetch call for it.
@@ -22,7 +22,7 @@ const PipelineBuildDecoratorTooltip: React.FC<PipelineBuildDecoratorTooltipProps | |||
return null; | |||
} | |||
|
|||
const taskStatus = getTaskStatus(pipeline.latestRun, pipeline); | |||
const taskStatus = getTaskStatus(pipeline.latestRun); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, wonder if we want to just remove the Pipeline
from this data and just handle the PipelineRun
as the Decorator is only really reading the PipelineRun information.
The caller of this component is build-decorator-utils
and that creates a currentPipelineStatus
that contains currentPipeline
which is the pipeline
in the above line. I believe my metholodolgy when I wrote it was to manage the standard Pipeline + .latestRun as a single param, instead of handling two variables Pipeline and PipelineRun.
This is all to say, I think we can change currentPipelineStatus
to just have the PipelineRun, as nothing else really needs the Pipeline.
The work Divyanshi is doing for the "not started" icon and text is based around having a Pipeline but not having a PipelineRun. So I think we are safe on that front.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the pipeline dependency here.
@@ -35,7 +35,216 @@ type CombinedPipelineTestData = { | |||
}; | |||
|
|||
type PipelineTestData = { [key in PipelineExampleNames]?: CombinedPipelineTestData }; | |||
|
|||
const pipelineSpec = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const pipelineSpec = { | |
type PipelineSpecData = { [key in PipelineExampleNames]?: PipelineSpec }; | |
const pipelineSpec: PipelineSpecData = { |
status: { creationTimestamp: '31', conditions: [{ type: 'Succeeded', status: 'True' }] }, | ||
status: { | ||
pipelineSpec: { tasks: [] }, | ||
creationTimestamp: '31', | ||
conditions: [{ type: 'Succeeded', status: 'True' }], | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'abhiapi/v1', | ||
kind: 'Pipeline', | ||
metadata: { name: 'dragonstone', namespace: 'corazon' }, | ||
spec: { pipelineRef: { name: 'danaerys-targaeryen' } }, | ||
status: { creationTimestamp: '31', conditions: [{ type: 'Succeeded', status: 'Unknown' }] }, | ||
status: { | ||
pipelineSpec: { tasks: [] }, | ||
creationTimestamp: '31', | ||
conditions: [{ type: 'Succeeded', status: 'Unknown' }], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this is duplicate data from frontend/packages/dev-console/src/components/pipelines/modals/common/__tests__/utils.spec.ts
😞
Think we could move this data into pipeline-data.ts
and then import it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this mock data and used the data from pipeline-data.ts
and also refactored utils.spec.ts
to avoid duplication of mock data.
return null; | ||
} | ||
return { | ||
apiVersion: PipelineModel.apiVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apiVersion: PipelineModel.apiVersion, | |
apiVersion: apiVersionForModel(PipelineModel), |
Awkward, I know... but apiVersion
in the Model is actually the version, whereas the K8s CR is the "group + version".
const totalTasks = | ||
pipeline && pipeline.spec && pipeline.spec.tasks ? pipeline.spec.tasks.length : 0; | ||
export const getPipelineFromPipelineRun = (pipelineRun: PipelineRun): Pipeline => { | ||
if (!pipelineRun?.status?.pipelineSpec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably possible to pass in a inlineSpec for Pipeline, can we also check to see if the label for Pipeline is here on the PipelineRun?
if (!pipelineRun?.status?.pipelineSpec) { | |
const pipelineName = pipelineRun.metadata.labels[TektonResourceLabel.pipeline]; | |
if (!pipelineName || !pipelineRun?.status?.pipelineSpec) { |
apiVersion: PipelineModel.apiVersion, | ||
kind: PipelineModel.kind, | ||
metadata: { | ||
name: pipelineRun.metadata[TektonResourceLabel.pipeline], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Shouldn't this be pipelineRun.metadata.labels
?
name: pipelineRun.metadata[TektonResourceLabel.pipeline], | |
name: pipelineRun.metadata.labels[TektonResourceLabel.pipeline], |
Also, perhaps make use of the variable based on my last comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be. updated.
}, | ||
}; | ||
const executedPipeline = getPipelineFromPipelineRun(plrWithOneTask); | ||
expect(currentPipeline.spec.tasks).toHaveLength(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird expect
... you're not testing data you used to deliver the test of getPipelineFromPipelineRun
you trimmed it out on 324 to being only the first one. What is this expect doing other than testing you have data that has 2 points (which is a bit odd of a test)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I Agree, after the pipeline dependancy removal this test wasn't serving the purpose. So i updated it now.
const executedPipeline = getPipelineFromPipelineRun(plrWithOneTask); | ||
expect(currentPipeline.spec.tasks).toHaveLength(2); | ||
expect(executedPipeline.spec.tasks).toHaveLength(1); | ||
expect(executedPipeline).not.toEqual(currentPipeline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused about this too... this follows my previous comment's confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the test
}, | ||
pipelineTestData[PipelineExampleNames.SIMPLE_PIPELINE].pipelineRuns[DataState.SUCCESS], | ||
pipelineTestData[PipelineExampleNames.WORKSPACE_PIPELINE].pipelineRuns[DataState.SUCCESS], | ||
pipelineTestData[PipelineExampleNames.CLUSTER_PIPELINE].pipelineRuns[DataState.SUCCESS], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard approve of this change. Very nicely done, consolidating test data is awesome!
b99a150
to
f33b7df
Compare
f33b7df
to
470ac6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great test changes, thanks for cleaning that up. Couple odd changes in the test data and one minor test needed.
status: '', | ||
type: 'Running', | ||
status: 'Unknown', | ||
type: 'Succeeded', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, this is DataState.IN_PROGRESS
, you have changed it to completed... I think you're mixing data points here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted back.
completionTime: '2020-07-13T17:21:05Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2020-07-13T17:21:05Z', | ||
message: | ||
'Pipeline andrew/task-ref-error can\'t be Run; it contains Tasks that don\'t exist: Couldn\'t retrieve Task "not-a-task": task.tekton.dev "not-a-task" not found', | ||
message: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you got rid of this data text? We could trim out my name for sure haha, it was log dumps when I created. We could make the message something like Test error text
, but I think it shouldn't be empty... as our tests could send that data in and it be mistaken as no error text rather than just an empty error text for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While consolidating the test data, there was a test case, where it returns a static message Unknown failure condition
if the message field is emtpy. For that reason i added this. I have reverted back the above one and handled the mock data in the test case itself.
@@ -328,3 +296,34 @@ describe('Pipeline exists test to determine whether a pipeline is linked to a pi | |||
expect(pipelineFound).toBeFalsy(); | |||
}); | |||
}); | |||
|
|||
describe('Pipelinerun graph to show the executed pipeline structure', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are missing a test for the actual result. You definitely have tested the paths to our current usage, but the method is, in isolation, just creating a Pipeline. We don't have a test to make sure it did do that. Goals of Unit Tests for functions should be to cover edge cases, any conditional paths, intended uses today and the function is performing the action it prescribes to - which in this case is making a PL CR out of the PLR CR.
470ac6c
to
f482b76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/retest Looks to be a connection issue |
/retest Please review the full test history for this PR and help us cut down flakes. |
6 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
f482b76
to
3df3d8e
Compare
I rebased due to merge conflicts. |
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
5 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
Fixes: https://issues.redhat.com/browse/ODC-2302
Description:
As a user, I would like to be able to view my past Pipeline Run visualization graphs without them being impacted by my current Pipeline status.
Problem:
Pipeline visualization component was always fetching the tasks from the current pipeline.
Solution:
Visualization component now uses the tasks from the
pipelinerun.status.pipelineSpec
field, which holds the reference of the pipeline at the time of execution. As a fallback, we still read from the pipeline if thispipelinerun.status.pipelineSpec
field is not available.Screenshots:
Test cases:
cc: @siamaksade @andrewballantyne
/kind feature