-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added Last Status information for Container #1041
Conversation
- This update will support a last status of terminated and display the information for the termninated state. Signed-off-by: Steve Richards <srichards@mirantis.com>
Signed-off-by: Steve Richards <srichards@mirantis.com>
@@ -149,7 +149,16 @@ export interface IPodContainerStatus { | |||
reason: string; | |||
}; | |||
}; | |||
lastState: {}; | |||
lastState: { | |||
[index: string]: object; |
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.
so this is covering running
and waiting
states?
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.
@nevalla - No, the lastState is only going to show terminated. Do we need the lastState to also show waiting as it can't be running as if a pod terminates and restarts it would be status of running and lastState of terminated.
@@ -54,6 +55,15 @@ export class PodDetailsContainer extends React.Component<Props> { | |||
</span> | |||
</DrawerItem> | |||
} | |||
{status && |
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 would change this to {lastState &&
. So not displaying even the title if Last status is not found.
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.
That was a typo. Corrected in next commit
<span> | ||
{lastState ? `${lastState}, ` : ""} | ||
{lastState === 'terminated' ? `${status.lastState.terminated.reason} (${_i18n._(t`exit code`)}: ${status.lastState.terminated.exitCode}), | ||
${_i18n._(t`started at`)}: ${status.lastState.terminated.startedAt}, ${_i18n._(t`finished at`)}: ${status.lastState.terminated.finishedAt}` : ''} |
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.
Please could you give an example, how these are looking after rendered?
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.
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.
That is rather hard to read. @nevalla Would a table-like view be better for information like this?
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.
How about putting line breaks after exit code and timestamps, so the result would be:
terminated, Error (exit code: 255)
started at: 2020-10-12T10:19:20Z
finished at: 2020-10-13T15:49:23Z
Would it be any better?
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.
That would be better, however then the comma after lastState
scans oddly
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.
How about no comma and we just separate each item with a line break?
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.
@Nokel81 , @nevalla - with this logic:
renderLastState(lastState: string, status: IPodContainerStatus) {
if (lastState === 'terminated') {
return (
<span>
{lastState}<br/>
{_i18n._(t`Reason`)}: {status.lastState.terminated.reason} - {_i18n._(t`exit code`)}: {status.lastState.terminated.exitCode}<br/>
{_i18n._(t`Started at`)}: {status.lastState.terminated.startedAt}<br/>
{_i18n._(t`Finished at`)}: {status.lastState.terminated.finishedAt}<br/>
</span>
)
}
}
we get the following output - is this ok?
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
{status && | ||
<DrawerItem name={<Trans>Last Status</Trans>}> | ||
<span> | ||
{lastState ? `${lastState}, ` : ""} | ||
{lastState === 'terminated' ? `${status.lastState.terminated.reason} (${_i18n._(t`exit code`)}: ${status.lastState.terminated.exitCode}), | ||
${_i18n._(t`started at`)}: ${status.lastState.terminated.startedAt}, ${_i18n._(t`finished at`)}: ${status.lastState.terminated.finishedAt}` : ''} | ||
</span> | ||
</DrawerItem> | ||
} |
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 decently complicated inline render. I personally would like to see it moved to its own function
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.
@Nokel81 - something like this:
renderLastState(lastState: string, status: IPodContainerStatus) {
return (
<span>
{lastState ? `${lastState}, ` : ""}
{lastState === 'terminated' ? `${status.lastState.terminated.reason} (${_i18n._(t`exit code`)}: ${status.lastState.terminated.exitCode}),
${_i18n._(t`started at`)}: ${status.lastState.terminated.startedAt}, ${_i18n._(t`finished at`)}: ${status.lastState.terminated.finishedAt}` : ''}
</span>
);
}
and the calling line:
{lastState &&
<DrawerItem name={<Trans>Last Status</Trans>}>
{this.renderLastState(lastState, status)}
</DrawerItem>
Wasn't sure if the DrawerItem should also be moved - thought it was better to leave it in the main body for ease of reading.
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.
That could work, I would have the drawer item in the separate function but that is more of a personal preference.
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 can't see any other examples where we do have the DrawerItem in the function so will leave as currently committed.
Signed-off-by: Steve Richards <srichards@mirantis.com>
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 it is good now
Fixes: #926
Signed-off-by: Steve Richards srichards@mirantis.com