Skip to content

Commit

Permalink
TaskRun details Page
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinandan13jan committed Nov 2, 2020
1 parent 80b767c commit fc7611f
Show file tree
Hide file tree
Showing 21 changed files with 553 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
} from '../../../utils/pipeline-augment';
import { PipelineModel, PipelineResourceModel } from '../../../models';
import ResourceLinkList from '../../pipelines/resource-overview/ResourceLinkList';
import PipelineRunDetailsErrorLog from '../logs/PipelineRunDetailsErrorLog';
import RunDetailsErrorLog from '../logs/RunDetailsErrorLog';
import PipelineRunVisualization from './PipelineRunVisualization';
import TriggeredBySection from './TriggeredBySection';
import { getPLRLogSnippet } from '../logs/pipelineRunLogSnippet';

import './TriggeredBySection.scss';

Expand Down Expand Up @@ -43,7 +44,10 @@ export const PipelineRunDetails: React.FC<PipelineRunDetailsProps> = ({ obj: pip
<Status status={pipelineRunFilterReducer(pipelineRun)} />
</dd>
</dl>
<PipelineRunDetailsErrorLog pipelineRun={pipelineRun} />
<RunDetailsErrorLog
logDetails={getPLRLogSnippet(pipelineRun)}
namespace={pipelineRun.metadata.name}
/>
{pipelineRefExists(pipelineRun) && (
<dl>
<dt>Pipeline</dt>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import * as React from 'react';
import { PipelineRun } from '../../../utils/pipeline-augment';
import LogSnippetFromPod from './LogSnippetFromPod';
import { PipelineRunErrorDetails } from './pipelineRunLogSnippet';
import { CombinedErrorDetails } from './log-snippet-types';

type LogSnippetBlockProps = {
children: (logSnippet: string) => React.ReactNode;
logDetails: PipelineRunErrorDetails;
pipelineRun: PipelineRun;
logDetails: CombinedErrorDetails;
namespace: string;
};

const LogSnippetBlock: React.FC<LogSnippetBlockProps> = ({ children, logDetails, pipelineRun }) => {
const LogSnippetBlock: React.FC<LogSnippetBlockProps> = ({ children, logDetails, namespace }) => {
return 'podName' in logDetails ? (
<LogSnippetFromPod
containerName={logDetails.containerName}
namespace={pipelineRun.metadata.namespace}
namespace={namespace}
podName={logDetails.podName}
title={logDetails.title}
>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as React from 'react';
import LogSnippetBlock from './LogSnippetBlock';
import { CombinedErrorDetails } from './log-snippet-types';

type RunDetailErrorLogProps = {
logDetails: CombinedErrorDetails;
namespace: string;
};

const RunDetailsErrorLog: React.FC<RunDetailErrorLogProps> = ({ logDetails, namespace }) => {
if (!logDetails) {
return null;
}

return (
<>
<dl>
<dt>Message</dt>
<dd>{logDetails.title}</dd>
</dl>
<dl>
<dt>Log Snippet</dt>
<dd>
<LogSnippetBlock logDetails={logDetails} namespace={namespace}>
{(logSnippet: string) => <pre>{logSnippet}</pre>}
</LogSnippetBlock>
</dd>
</dl>
</>
);
};

export default RunDetailsErrorLog;
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import { PipelineRun } from 'packages/dev-console/src/utils/pipeline-augment';
import { TaskRunData } from '../log-snippet-types';

export const LogSnippetTaskData: TaskRunData[] = [
{
kind: 'TaskRun',
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' },
status: {
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'True',
type: 'Failed',
},
],
},
spec: {},
},
{
kind: 'TaskRun',
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' },
status: {
podName: 'pod1',
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'True',
type: 'Failed',
},
],
},
spec: {},
},
{
kind: 'TaskRun',
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' },
status: {
podName: 'pod1',
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'SUCCEEDED',
status: 'True',
type: 'SUCCEEDED',
},
],
},
spec: {},
},
];

export const PipelineRunMock: PipelineRun[] = [
{
apiVersion: 'tekton.dev/v1alpha1',
kind: 'PipelineRun',
metadata: {
name: 'simple-pipeline-failed',
namespace: 'tekton-pipelines',
},
spec: {
pipelineRef: {
name: 'simple-pipeline',
},
},
status: {
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Succeeded',
status: 'True',
type: 'Succeeded',
},
],
startTime: '2019-10-29T11:56:40Z',
taskRuns: {
task1: {
status: {
startTime: '2019-10-29T11:57:53Z',
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Succeeded',
status: 'True',
type: 'Succeeded',
},
],
podName: 'p1',
},
pipelineTaskName: 'task1',
},
},
},
},
{
apiVersion: 'tekton.dev/v1alpha1',
kind: 'PipelineRun',
metadata: {
name: 'simple-pipeline-failed',
namespace: 'tekton-pipelines',
},
spec: {
pipelineRef: {
name: 'simple-pipeline',
},
},
status: {
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'False',
type: 'Succeeded',
},
],
startTime: '2019-10-29T11:56:40Z',
taskRuns: {
task1: {
status: {
startTime: '2019-10-29T11:57:53Z',
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'False',
type: 'Succeeded',
},
],
podName: 'pod1',
steps: [
{
container: 'container1',
imageID: 'a',
name: 'step1',
terminated: {
containerID: 'b',
exitCode: 1,
finishedAt: 'x',
reason: 'FAILED INTENTIONALLY',
startedAt: 'c',
},
},
],
},
pipelineTaskName: 'task1',
},
},
},
},
{
apiVersion: 'tekton.dev/v1alpha1',
kind: 'PipelineRun',
metadata: {
name: 'simple-pipeline-failed-2',
namespace: 'tekton-pipelines',
},
spec: {
pipelineRef: {
name: 'simple-pipeline',
},
},
status: {
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'False',
type: 'Succeeded',
},
],
startTime: '2019-10-29T11:56:40Z',
taskRuns: {
task1: {
status: {
startTime: '2019-10-29T11:57:53Z',
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'False',
type: 'Succeeded',
},
],
podName: 'pod1',
},
pipelineTaskName: 'task1',
},
},
},
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { taskRunSnippetMessage } from '../log-snippet-utils';
import { ErrorDetailsWithLogName, ErrorDetailsWithStaticLog } from '../log-snippet-types';
import { LogSnippetTaskData } from './log-snippet-test-data';

const testContainer = 'container-B';

describe('LogSnippet utils test', () => {
it('should return title and static message for no container', () => {
const { title, staticMessage } = taskRunSnippetMessage(
LogSnippetTaskData[0].metadata.name,
LogSnippetTaskData[0].status,
null,
) as ErrorDetailsWithStaticLog;
expect(title).toEqual(
`Failure on task ${LogSnippetTaskData[0].metadata.name} - check logs for details.`,
);
expect(staticMessage).toEqual('Unknown failure condition');
});

it('should return title and static message for no pod', () => {
const { title, staticMessage } = taskRunSnippetMessage(
LogSnippetTaskData[0].metadata.name,
LogSnippetTaskData[0].status,
testContainer,
) as ErrorDetailsWithStaticLog;
expect(title).toEqual(
`Failure on task ${LogSnippetTaskData[0].metadata.name} - check logs for details.`,
);
expect(staticMessage).toEqual('Unknown failure condition');
});

it('should return title from task metadata, pod and container', () => {
const { title, podName, containerName } = taskRunSnippetMessage(
LogSnippetTaskData[1].metadata.name,
LogSnippetTaskData[1].status,
testContainer,
) as ErrorDetailsWithLogName;
expect(title).toEqual(
`Failure on task ${LogSnippetTaskData[1].metadata.name} - check logs for details.`,
);
expect(podName).toEqual(LogSnippetTaskData[1].status.podName);
expect(containerName).toEqual(testContainer);
});
});

0 comments on commit fc7611f

Please sign in to comment.