Skip to content

Commit

Permalink
feat(preconfiguredJob): logs for k8s jobs (#6840)
Browse files Browse the repository at this point in the history
supports logs for preconfigured kubernetes jobs. titus jobs only link
out to extenal systems for their logs. for kubernetes, logs are stored
in the execution context and can be displayed directly.
  • Loading branch information
ethanfrogers authored Apr 11, 2019
1 parent c30058a commit e618548
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';

import { IModalComponentProps } from '@spinnaker/core';
import { IModalComponentProps } from 'core/presentation';

export interface IRunJobLogsModalProps extends IModalComponentProps {
export interface ILogsModalProps extends IModalComponentProps {
logs: string;
}

export class RunJobLogsModal extends React.Component<IRunJobLogsModalProps> {
constructor(props: IRunJobLogsModalProps) {
export class LogsModal extends React.Component<ILogsModalProps> {
constructor(props: ILogsModalProps) {
super(props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,49 @@ import * as React from 'react';
import { get } from 'lodash';

import { IStage } from 'core/domain';
import { ReactModal } from 'core/presentation';

export const StageExecutionLogs = (props: { stage: IStage }): JSX.Element => {
const logs = get<string>(props.stage, 'context.execution.logs');
if (!logs) {
return null;
import { LogsModal, ILogsModalProps } from './LogsModal';

export interface IStageExecutionLogsProps {
stage: IStage;
}

export class StageExecutionLogs extends React.Component<IStageExecutionLogsProps> {
public isExternalLink = false;

constructor(props: any) {
super(props);
// titus jobs present a link to an external system for logs
// kubernetes jobs store logs in the execution context (for better, or for worse)
this.isExternalLink = get<string>(this.props.stage, 'context.execution.logs') !== undefined;
}

return (
<div className="row">
<div className="col-md-12">
<div className="well alert alert-info">
<a target="_blank" href={logs}>
View Execution Logs
</a>
public showModal = () => {
ReactModal.show(
LogsModal,
{
logs: get<string>(this.props.stage, 'context.jobStatus.logs'),
} as ILogsModalProps,
{ dialogClassName: 'modal-lg modal-fullscreen' },
);
};

public render() {
const logs = get<string>(this.props.stage, 'context.execution.logs');
return (
<div className="row">
<div className="col-md-12">
<div className="well alert alert-info">
{this.isExternalLink && (
<a target="_blank" href={logs}>
View Execution Logs
</a>
)}
{!this.isExternalLink && <a onClick={this.showModal}>View Execution Logs</a>}
</div>
</div>
</div>
</div>
);
};
);
}
}
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/pipeline/details/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './executionDetailsSection.service';
export * from './ExecutionDetailsSectionNav';
export * from './StageExecutionLogs';
export * from './StageFailureMessage';
export * from './LogsModal';
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import { get } from 'lodash';

import { RunJobLogsModal, IRunJobLogsModalProps } from './RunJobLogsModal';

import {
IExecutionDetailsSectionProps,
ExecutionDetailsSection,
AccountTag,
ReactModal,
ReactInjector,
LogsModal,
ILogsModalProps,
} from '@spinnaker/core';

export class RunJobExecutionDetails extends React.Component<IExecutionDetailsSectionProps> {
Expand All @@ -25,10 +25,10 @@ export class RunJobExecutionDetails extends React.Component<IExecutionDetailsSec

const modalProps = { dialogClassName: 'modal-lg modal-fullscreen' };
ReactModal.show(
RunJobLogsModal,
LogsModal,
{
logs: get(fullStage, 'context.jobStatus.logs', 'No log output found.'),
} as IRunJobLogsModalProps,
} as ILogsModalProps,
modalProps,
);
});
Expand Down

0 comments on commit e618548

Please sign in to comment.