Skip to content

Commit

Permalink
fix(k8s/runJob): External logs URL to support manifest with implicit …
Browse files Browse the repository at this point in the history
…default namespace (#7252)

When the manifest didn't have a namespace explicitly provided, the external logs URL couldn't be prepared.
Now sourcing the namespace from `context.jobStatus.location`, reusing the existing variable.
Also removed the `manifest` property from JobStageExecutionLogs as it wasn't being used.
  • Loading branch information
Pierre Delagrave authored and maggieneterval committed Jul 24, 2019
1 parent 4edc5f7 commit 4dba1b1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import * as React from 'react';
import { template, isEmpty } from 'lodash';
import { Observable, Subject } from 'rxjs';

import { IStageManifest } from '../ManifestService';
import { JobManifestPodLogs } from './JobManifestPodLogs';
import { IManifest } from 'core/domain/IManifest';
import { Application } from 'core/application';
import { IPodNameProvider } from '../PodNameProvider';
import { ManifestReader } from 'core/manifest';

interface IJobStageExecutionLogsProps {
manifest: IStageManifest;
deployedName: string;
account: string;
application: Application;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class PreconfiguredJobExecutionDetails extends React.Component<IExecution
const { stage } = this.props;

if (cloudProvider === 'kubernetes') {
const manifest = get(stage, ['context', 'manifest'], null);
const namespace = get<string>(stage, ['context', 'jobStatus', 'location']);
const deployedJobs = get(this.props.stage, ['context', 'deploy.jobs']);
const deployedName = get(deployedJobs, namespace, [])[0] || '';
Expand All @@ -85,7 +84,6 @@ export class PreconfiguredJobExecutionDetails extends React.Component<IExecution
return (
<div className="well">
<JobStageExecutionLogs
manifest={manifest}
deployedName={deployedName}
account={this.props.stage.context.account}
application={this.props.application}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,13 @@ import {
ExecutionDetailsSection,
AccountTag,
JobStageExecutionLogs,
IStageManifest,
DefaultPodNameProvider,
IJobOwnedPodStatus,
} from '@spinnaker/core';

interface IStageDeployedJobs {
[namespace: string]: string[];
}

export class RunJobExecutionDetails extends React.Component<IExecutionDetailsSectionProps> {
public static title = 'runJobConfig';

private extractDeployedJobName(manifest: IStageManifest, deployedJobs: IStageDeployedJobs): string {
const namespace = get(manifest, ['metadata', 'namespace'], '');
const jobNames = get(deployedJobs, namespace, []);
return jobNames.length > 0 ? jobNames[0] : '';
}

private mostRecentlyCreatedPodName(podsStatuses: IJobOwnedPodStatus[]): string {
const sorted = sortBy(podsStatuses, (p: IJobOwnedPodStatus) => p.status.startTime);
const mostRecent = last(sorted);
Expand All @@ -34,12 +23,11 @@ export class RunJobExecutionDetails extends React.Component<IExecutionDetailsSec
const { stage, name, current } = this.props;
const { context } = stage;

const { manifest } = context;
const deployedName = this.extractDeployedJobName(manifest, get(context, ['deploy.jobs']));
const namespace = get(stage, ['context', 'jobStatus', 'location'], '');
const deployedName = namespace ? get<string[]>(context, ['deploy.jobs', namespace])[0] : '';
const externalLink = get<string>(stage, ['context', 'execution', 'logs']);
const podName = this.mostRecentlyCreatedPodName(get(stage.context, ['jobStatus', 'pods'], []));
const podNameProvider = new DefaultPodNameProvider(podName);
const namespace = get(stage, ['context', 'jobStatus', 'location'], '');

return (
<ExecutionDetailsSection name={name} current={current}>
Expand All @@ -57,7 +45,6 @@ export class RunJobExecutionDetails extends React.Component<IExecutionDetailsSec
<dt>Logs</dt>
<dd>
<JobStageExecutionLogs
manifest={manifest}
deployedName={deployedName}
account={this.props.stage.context.account}
location={namespace}
Expand Down

0 comments on commit 4dba1b1

Please sign in to comment.