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

TaskRun details and log page #6851

Merged

Conversation

abhinandan13jan
Copy link
Contributor

@abhinandan13jan abhinandan13jan commented Oct 6, 2020

Addresses

https://issues.redhat.com/browse/ODC-4801

Screenshot

task-run-det-multi

Tests

Added two test suites, TaskRunDetails and TaskRunLogs

Browser conformance

chrome

Comment on lines 26 to 31
props.obj.status?.podName ? (
<TaskRunLog {...props} />
) : (
<StatusBox loadError="Pod not found" label="TaskRun Log" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we have this check in the above function and early exit if podName is not available 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works, but it fails lint check when there is an if block before the useK8sGet Hook

Copy link
Contributor

Choose a reason for hiding this comment

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

Best to name this wrapper component and export that as default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

named as wrapper

@karthikjeeyar
Copy link
Contributor

/kind feature

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 6, 2020
obj.status.podName,
obj.metadata.namespace,
);
if (podLoaded) {
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 (podLoaded) {
if (podLoaded && !podError) {

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 this as well as named to TaskRunLogWrapper

Comment on lines 26 to 31
props.obj.status?.podName ? (
<TaskRunLog {...props} />
) : (
<StatusBox loadError="Pod not found" label="TaskRun Log" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Best to name this wrapper component and export that as default.

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.

@abhinandan13jan Logs doesn't seem to be streaming. It just says loading and when step is changed from the dropdown. There is an error
Screenshot 2020-10-09 at 10 23 47 AM
Screenshot 2020-10-09 at 10 24 00 AM
But it streams fine in the Pipeline run logs
Screenshot 2020-10-09 at 10 24 13 AM

};

// to safeguard against cases where Pod is yet to be assigned or is removed
const TaskRunLogWrapper = (props: TaskRunLogProps) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a Functional Component. Should type it properly

Suggested change
const TaskRunLogWrapper = (props: TaskRunLogProps) =>
const TaskRunLogWrapper: React.FC<TaskRunLogProps> = (props) =>

Comment on lines 26 to 29
<Status status={pipelineRunFilterReducer(taskRun)} />
</dd>
</dl>
<PipelineRunDetailsErrorLog pipelineRun={taskRun} />
Copy link
Contributor

Choose a reason for hiding this comment

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

These two pipelineRun specific functions called in the context of taskRun looks odd to me. If taskRun has more specific type definition, then this will cause lint errors and confusions in future. It will be good to refactor these to a generic function calls. WDYT?

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've updated such that PLR and TR uses separate utils and point to a common component

@abhinandan13jan
Copy link
Contributor Author

@abhinandan13jan Logs doesn't seem to be streaming. It just says loading and when step is changed from the dropdown. There is an error
Screenshot 2020-10-09 at 10 23 47 AM
Screenshot 2020-10-09 at 10 24 00 AM
But it streams fine in the Pipeline run logs
Screenshot 2020-10-09 at 10 24 13 AM

Strange, I find it to work the same as Pod log

trlog2
trlog1

Comment on lines 9 to 11
pipelineRun: PipelineRun;
pipelineRun?: PipelineRun;
taskRun?: K8sResourceKind;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we just simplify this to a single K8sResourceKind or even better down to just namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplified to namespace for all cases

Comment on lines 28 to 48
describe('TaskRunDetailsPage', () => {
const pipelineRunWrapper = shallow(<TaskRunDetails {...TaskDetailsProps} />);
it('Renders a SectionHeading', () => {
expect(pipelineRunWrapper.find(SectionHeading).exists());
});
it('Renders a Resource Summary', () => {
expect(pipelineRunWrapper.find(ResourceSummary).exists());
});
it('Renders a Status', () => {
expect(pipelineRunWrapper.find(Status).exists());
});
it('Renders a Task Run Log snippet', () => {
expect(pipelineRunWrapper.find(TaskRunDetailsErrorLog).exists());
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing against static content won't save us from anything. The best it can do is fail a test when we change the layout... there isn't any conditional here that we would be concerned about. Ie, no logic breaks can cause these tests to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just based on current acceptance criteria. Just to make sure, the code adheres to the AC

Copy link
Contributor

Choose a reason for hiding this comment

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

Unit tests guard against accidental breaks in logic.

Eg. A unit test for add5() would be add5(5).toBe(10)... you could test positive numbers, negative numbers, strings (should return NaN), objects, etc, etc...

If you wrap your add5():

function getOffsetNumber() {
  return add5(37);
}

This function doesn't get you much but it allows the caller not to worry about providing this static 37 (this is an overly simple example). A testing of this function doesn't mean much. getOffsetNumber().toBe(42)... how will this test break? If we choose 37 is not a valid constant anymore? So we just change the test and the code at the same time and nothing super shocking here happens. No assistance is really provided by our test, no assurances we don't accidentally break.

Tests are so you can go into add5 and change the fact that it doesn't add 5 anymore, it subtracts 8 or does something else (uses math.random for instance). Zero inputs or inputs that don't change the output are not test worthy scenarios. They just explicitly tie our tests to our implementation and thus makes us update one more place when we need to change something. It doesn't guard against breaks.

With this mental model, React Components have a similar structure with 1 extra condition. We only shallowly look at the structure of a component. So if your React Component does not take any props or the props are not conditional rendering props but just pass-thru props, then there are no tests needing to be written.

So in summary, because I ranted a bit here. Don't test a component that does not use conditional rendering as you're not really writing a test, you're writing just 1 more spot to update if we need to change anything.

import { PodModel } from '@console/internal/models';

export type TaskRunLogProps = {
obj: K8sResourceKind;
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
obj: K8sResourceKind;
obj: TaskRunKind;

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

Copy link
Contributor

@karthikjeeyar karthikjeeyar left a comment

Choose a reason for hiding this comment

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

I observe the same issue as sahil mentioned above.When you create a taskRun, logs are not streaming correctly.

@@ -58,3 +58,8 @@ export const pipelineResourceTypeFilter = (filters, pipelineResource): boolean =
const type = pipelineResourceFilterReducer(pipelineResource);
return filters.selected.has(type) || !_.includes(filters.all, type);
};

export const taskRunFilterReducer = (taskRun): string => {
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
export const taskRunFilterReducer = (taskRun): string => {
export const taskRunFilterReducer = (taskRun: TaskRunKind): string => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cyclic dependence will be there

@@ -58,3 +58,8 @@ export const pipelineResourceTypeFilter = (filters, pipelineResource): boolean =
const type = pipelineResourceFilterReducer(pipelineResource);
return filters.selected.has(type) || !_.includes(filters.all, type);
};

export const taskRunFilterReducer = (taskRun): string => {
const status = pipelineRunStatus(taskRun);
Copy link
Contributor

Choose a reason for hiding this comment

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

pipelineRunStatus function should be also typed to accept PipelineRun | TaskRunKind as arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's one issue with that. It's a cyclic dependence and pipeline-filter-reducer doesn't have types. It should be a separate issue to refactor Types out of pipeline-augment. cc: @andrewballantyne

Copy link
Member

@jerolimov jerolimov Oct 22, 2020

Choose a reason for hiding this comment

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

I would prefer here to not reuse pipelineRunStatus at all and to not mix PipelineRun and TaskRun objects. I personally would prefer in this case "duplicated" code for both types instead of methods which supports both.

But that's up to you. But we should at least add some types here. +1 for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, types are annoying in this file. So it should be handled by the work to take Pipelines out of DevConsole package

Comment on lines 10 to 14
const TaskDetailsProps: Props = {
obj: {
kind: 'TaskRun',
metadata: { name: 'abhi', namespace: 'abhi1' },
status: {
completionTime: '2019-10-29T11:57:53Z',
conditions: [
{
lastTransitionTime: '2019-10-29T11:57:53Z',
reason: 'Failed',
status: 'True',
type: 'Failed',
},
],
},
},
};

Copy link
Contributor

Choose a reason for hiding this comment

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

can we please move this to a test-data file ? and reuse in other spec files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

import * as React from 'react';
import { PodLogs } from '@console/internal/components/pod-logs';
import { StatusBox } from '@console/internal/components/utils/status-box';
import { shallow } from 'enzyme';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: sort imports

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

@abhinandan13jan
Copy link
Contributor Author

I observe the same issue as sahil mentioned above.When you create a taskRun, logs are not streaming correctly.

Fixed it with useK8sWatchResource hook

@bgliwa01
Copy link

Will all of the columns be added on the list view? Right now I only see namespace and created, but there should be others included as seen in this PR - #6840 (comment)

I'm not sure if these designs will automatically update based on Deb's PR or not...

Copy link
Contributor

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

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

Based on @siamaksade comment ...

Strange, I find it to work the same as Pod log

@abhinandan13jan If possible, I'd suggest that we use the same component from the Log tab in PipelineRun here, but just not show the left nav piece with the task list

I think this was a miscommunication because we discussed "using conventions" :)

@abhinandan13jan
Copy link
Contributor Author

Will all of the columns be added on the list view? Right now I only see namespace and created, but there should be others included as seen in this PR - #6840 (comment)

I'm not sure if these designs will automatically update based on Deb's PR or not...

@bgliwa01 Yes, the list view will be updated as per @debsmita1 's PR. You can ignore the list view shown in my screenshots :)

@abhinandan13jan
Copy link
Contributor Author

abhinandan13jan commented Oct 15, 2020

Based on @siamaksade comment ...

Strange, I find it to work the same as Pod log

@abhinandan13jan If possible, I'd suggest that we use the same component from the Log tab in PipelineRun here, but just not show the left nav piece with the task list

I think this was a miscommunication because we discussed "using conventions" :)

Hi @serenamarie125 !! I've updated to use the Multistreaming Log

task-run-det-multi

@karthikjeeyar
Copy link
Contributor

Verified locally, works fine
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2020
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

@invincibleJai
Copy link
Member

@abhinandan13jan looks like, it needs rebase

@abhinandan13jan abhinandan13jan force-pushed the taskrun-details branch 2 times, most recently from ca4221e to 0d31381 Compare November 2, 2020 11:28
import LogSnippetBlock from './LogSnippetBlock';

type PipelineStatusLogProps = {
pipelineRun: PipelineRun;
logDetails;
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a type

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

Looks good, just need to use the TaskRunKind

Comment on lines 18 to 28
export type TaskRunStatus = {
podName?: string;
conditions: Condition[];
};

export type TaskRunData = K8sResourceKind & {
status: TaskRunStatus;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Should just add these to the TaskRunKind...


export interface TaskRunDetailsProps {
obj: K8sResourceKind;
obj: K8sResourceKind & { status: TaskRunStatus };
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
obj: K8sResourceKind & { status: TaskRunStatus };
obj: TaskRunKind;

import { CombinedErrorDetails, TaskRunData } from '../../pipelineruns/logs/log-snippet-types';
import { taskRunSnippetMessage } from '../../pipelineruns/logs/log-snippet-utils';

export const getTRLogSnippet = (taskRun: TaskRunData): CombinedErrorDetails => {
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
export const getTRLogSnippet = (taskRun: TaskRunData): CombinedErrorDetails => {
export const getTRLogSnippet = (taskRun: TaskRunKind): CombinedErrorDetails => {

@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 2, 2020
@karthikjeeyar
Copy link
Contributor

/retest

1 similar comment
@karthikjeeyar
Copy link
Contributor

/retest

@karthikjeeyar
Copy link
Contributor

/retest

@abhinandan13jan
Copy link
Contributor Author

/test backend

@karthikjeeyar
Copy link
Contributor

Verified locally, works fine
/lgtm

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

/retest

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

Comment on lines 18 to 28
export type TaskRunStatus = {
completionTime?: string;
conditions: Condition[];
podName?: string;
startTime?: string;
steps?: PLRTaskRunStep[];
};

export type TaskRunData = K8sResourceKind & {
status: TaskRunStatus;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Failed to remove this code 😄 Please trim it out so we don't have confusion on which to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup.. updated..thanks

@andrewballantyne
Copy link
Contributor

/lgtm cancel

@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 3, 2020
@andrewballantyne
Copy link
Contributor

/approve

Remove the unused code and we should be good to go.

@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 3, 2020
@karthikjeeyar
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinandan13jan, 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

@openshift-merge-robot openshift-merge-robot merged commit ea90110 into openshift:master Nov 4, 2020
@spadgett spadgett added this to the v4.7 milestone Nov 4, 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. component/dev-console Related to dev-console kind/feature Categorizes issue or PR as related to a new feature. 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