Skip to content

Commit

Permalink
add rendering for retried taskRuns
Browse files Browse the repository at this point in the history
  • Loading branch information
steveodonovan committed May 27, 2020
1 parent d835454 commit 63a96c3
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 6 deletions.
35 changes: 30 additions & 5 deletions packages/components/src/components/PipelineRun/PipelineRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component {
return [];
}

const { tasks, taskRuns } = this.props;
const { tasks, taskRuns, intl } = this.props;

if (!tasks || !taskRuns) {
return [];
Expand All @@ -107,10 +107,22 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component {
status: { taskRuns: taskRunDetails }
} = pipelineRun;

const retryPodIndex = {};
const retriedTaskRuns = taskRuns
.filter(taskRun => taskRun.status.retriesStatus)
.reduce((acc, taskRun) => {
taskRun.status.retriesStatus.forEach((retryStatus, index) => {
const retryRun = { ...taskRun };
retryRun.status = retryStatus;
retryPodIndex[retryStatus.podName] = index;
acc.push(retryRun);
});
return acc;
}, []);
return taskRuns
.concat(retriedTaskRuns)
.map(taskRun => {
let taskSpec;

if (taskRun.spec.taskRef) {
const task = selectedTask(taskRun.spec.taskRef.name, tasks);

Expand All @@ -135,7 +147,7 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component {

const { reason, status: succeeded } = getStatus(taskRun);

const { pipelineTaskName } = taskRunDetails[taskRunName] || {
let { pipelineTaskName } = taskRunDetails[taskRunName] || {
pipelineTaskName: taskRun.metadata.labels['tekton.dev/conditionCheck']
};

Expand Down Expand Up @@ -167,11 +179,24 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component {
);
steps = stepsStatus(reorderedSteps, taskRun.status.steps);
}
const { podName } = taskRun.status;

if (retryPodIndex[podName] || taskRun.status.retriesStatus) {
const retryNumber =
retryPodIndex[podName] || taskRun.status.retriesStatus.length;
pipelineTaskName = intl.formatMessage(
{
id: 'dashboard.pipelineRun.pipelineTaskName.retryAppendage',
defaultMessage: '{pipelineTaskName} (retry {retryNumber, number})'
},
{ pipelineTaskName, retryNumber }
);
}

return {
id: taskRun.metadata.uid,
id: `${taskRun.metadata.uid}${podName}`,
pipelineTaskName,
pod: taskRun.status.podName,
pod: podName,
reason,
steps,
succeeded,
Expand Down
57 changes: 57 additions & 0 deletions packages/components/src/components/PipelineRun/PipelineRun.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,60 @@ it('PipelineRunContainer handles init step failures', async () => {
);
await waitForElement(() => getByText(initStepName));
});

it('PipelineRunContainer handles init step failures for retry', async () => {
const initStepName = 'my-failed-init-step';
const pipelineRunName = 'fake_pipelineRunName';
const taskRunName = 'fake_taskRunName';
const retryText = '(retry 1)';

const taskRun = {
metadata: {
name: taskRunName,
labels: {}
},
spec: {
params: {},
resources: {
inputs: {},
outputs: {}
},
taskSpec: {}
},
status: {
steps: [
{
terminated: {},
name: initStepName
}
],
retriesStatus: [
{
status: {
steps: [
{
terminated: {},
name: initStepName
}
]
}
}
]
}
};

const pipelineRun = {
metadata: {
name: pipelineRunName
},
status: {
taskRuns: []
}
};

const { getByText } = renderWithIntl(
<PipelineRun pipelineRun={pipelineRun} taskRuns={[taskRun]} tasks={[]} />
);
await waitForElement(() => getByText(initStepName));
await waitForElement(() => getByText(retryText));
});
3 changes: 2 additions & 1 deletion src/nls/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"dashboard.pipelineRun.logEmpty": "No log available",
"dashboard.pipelineRun.logFailed": "Unable to fetch log",
"dashboard.pipelineRun.notFound": "PipelineRun not found",
"dashboard.pipelineRun.pipelineTaskName.retryAppendage": "{pipelineTaskName} (retry {retryNumber, number})",
"dashboard.pipelineRun.rerunStatusMessage": "View status",
"dashboard.pipelineRun.stepCompleted": "Step completed",
"dashboard.pipelineRun.stepFailed": "Step failed",
Expand Down Expand Up @@ -314,4 +315,4 @@
"react-intl-formatted-duration.minutesUnit": "{value, plural, one {minute} other {minutes}}",
"react-intl-formatted-duration.secondsUnit": "{value, plural, one {second} other {seconds}}"
}
}
}

0 comments on commit 63a96c3

Please sign in to comment.