Skip to content

Commit

Permalink
fix: get s2i log error when container not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh1028 committed Feb 7, 2020
1 parent 771b358 commit f31b1db
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 20 deletions.
25 changes: 20 additions & 5 deletions src/components/Forms/CICDs/ParamsInput/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export default class ParamsInput extends React.Component {
<div>
<Columns>
<Column>
<Form.Item label={t('Name')}>
<Form.Item
label={t('Name')}
rules={[{ required: true, message: t('This param is required') }]}
>
<Input
name={`${this.props.prefix}.name`}
defaultValue={value.name}
Expand Down Expand Up @@ -114,7 +117,10 @@ export default class ParamsInput extends React.Component {

return (
<div>
<Form.Item label={t('Name')}>
<Form.Item
label={t('Name')}
rules={[{ required: true, message: t('This param is required') }]}
>
<Input name={`${this.props.prefix}.name`} defaultValue={value.name} />
</Form.Item>
<Form.Item label={t('Default Value')}>
Expand Down Expand Up @@ -142,7 +148,10 @@ export default class ParamsInput extends React.Component {
<div>
<Columns>
<Column>
<Form.Item label={t('Name')}>
<Form.Item
label={t('Name')}
rules={[{ required: true, message: t('This param is required') }]}
>
<Input
name={`${this.props.prefix}.name`}
defaultValue={value.name}
Expand Down Expand Up @@ -179,7 +188,10 @@ export default class ParamsInput extends React.Component {
<div>
<Columns>
<Column>
<Form.Item label={t('Name')}>
<Form.Item
label={t('Name')}
rules={[{ required: true, message: t('This param is required') }]}
>
<Input
name={`${this.props.prefix}.name`}
defaultValue={value.name}
Expand Down Expand Up @@ -219,7 +231,10 @@ export default class ParamsInput extends React.Component {
<div>
<Columns>
<Column>
<Form.Item label={t('Name')}>
<Form.Item
label={t('Name')}
rules={[{ required: true, message: t('This param is required') }]}
>
<Input
name={`${this.props.prefix}.name`}
defaultValue={value.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export default class EditPipelineConfig extends React.Component {
}

handleOk = () => {
this.props.onOk(this.formRef.current._formData)
const form = this.formRef && this.formRef.current

form &&
form.validate(() => {
this.props.onOk(this.formRef.current._formData)
})
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,7 @@ export default class ImageBuilderLastRun extends React.Component {
}

render() {
const {
generation,
status,
imageName,
startTime,
name,
} = this.props.runDetail
const { count, status, imageName, startTime, name } = this.props.runDetail
const { loading } = this.props

if (loading) {
Expand All @@ -183,7 +177,7 @@ export default class ImageBuilderLastRun extends React.Component {
>
<li>
<div className={styles.value}>
#{generation} {this.renderDetailInfo()}
#{count} {this.renderDetailInfo()}
</div>
<div className={styles.label}>{t('Build Times')}</div>
</li>
Expand Down
17 changes: 15 additions & 2 deletions src/pages/projects/components/Cards/S2iBuilder/log.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { observer } from 'mobx-react'
import { isFunction } from 'lodash'
import classnames from 'classnames'
import { Icon, Loading, Tooltip } from '@pitrix/lego-ui'

import { Empty } from 'components/Base'
import RunStore from 'stores/s2i/run'

import styles from './index.scss'
Expand All @@ -37,6 +37,7 @@ export default class Log extends React.Component {
super()
this.state = {
showLog: true,
isContainerPending: false,
}
this.store = new RunStore()
this.refreshTimer = null
Expand Down Expand Up @@ -72,7 +73,11 @@ export default class Log extends React.Component {
if (globals.app.hasKSModule('logging')) {
await this.store.getLog(logURL)
} else {
await this.store.fetchPodsLogs(logURL)
await this.store.fetchPodsLogs(logURL).catch(error => {
if (error === 'container not ready') {
this.setState({ isContainerPending: true })
}
})
}
this.handleScrollToBottom()
if (logData.hasMore) {
Expand Down Expand Up @@ -170,6 +175,14 @@ export default class Log extends React.Component {
}

render() {
if (this.state.isContainerPending) {
return (
<div className={styles.logContainer}>
<Empty desc={'CONTAINER_REAL_TIME_LOGS_UNSUPPORTED_TIPS'} />
</div>
)
}

return (
<div className={styles.logContainer}>
<div className={styles.title} onClick={this.toggleLog}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class EditModal extends React.Component {
visible={visible}
isSubmitting={isSubmitting}
>
<Form.Item label={t('Name')} desc={t('LONG_NAME_DESC')}>
<Form.Item label={t('Name')} desc={t('NAME_DESC')}>
<Input name="name" disabled />
</Form.Item>
<Form.Item label={t('Alias')} desc={t('ALIAS_DESC')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class ImageBuilderDetail extends Base {
isSubmitting={isSubmitting}
/>
<EditYamlModal
readOnly
visible={viewYaml}
detail={toJS(detail._originData)}
onCancel={this.hideModal('viewYaml')}
Expand Down
16 changes: 13 additions & 3 deletions src/stores/s2i/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default class S2irunStore extends Base {

@action
async fetchS2IRunRecords({
limit,
limit = 10,
name,
page,
page = 1,
order,
reverse,
workspace,
Expand All @@ -117,7 +117,7 @@ export default class S2irunStore extends Base {
})

if (limit !== Infinity) {
params.paging = `limit=${limit || 10},page=${page || 1}`
params.paging = `limit=${limit},page=${page}`
}

if (order) {
Expand All @@ -133,6 +133,9 @@ export default class S2irunStore extends Base {
params
)
const data = result.items.map(this.mapper)
data.forEach((item, index) => {
item.count = result.total_count - index - 10 * (page - 1)
})

this.list = {
data: more ? [...this.list.data, ...data] : data,
Expand Down Expand Up @@ -199,6 +202,13 @@ export default class S2irunStore extends Base {

if (!this.containerName) {
const podsDetail = await request.get(`api/v1//namespaces/${logPath}`)
const containerID = get(
podsDetail,
'status.containerStatuses[0]containerID'
)
if (!containerID) {
return Promise.reject('container not ready')
}
this.containerName = get(podsDetail, 'spec.containers[0].name', '')
}
const result = await request.get(`api/v1/namespaces/${logPath}/log`, {
Expand Down

0 comments on commit f31b1db

Please sign in to comment.