Skip to content

Commit

Permalink
Fix: Add the prepare step for the canary workflow (#779)
Browse files Browse the repository at this point in the history
Signed-off-by: barnettZQG <[email protected]>
  • Loading branch information
barnettZQG committed Apr 17, 2023
1 parent dabd21b commit 47f2313
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,25 @@ interface Props {

const generateCanaryDeployGroup = (step: WorkflowStep, batch: number): WorkflowStep => {
const interval = Math.round(100 / batch);
const steps: WorkflowStep[] = [];
const policies: string[] | null = step.properties ? step.properties['policies'] : null;
for (let i = 0; i < batch; i++) {
const steps: WorkflowStep[] = [
{
name: 'prepare-canary',
alias: 'Prepare Canary',
type: DeployModes.CanaryDeploy,
properties: {
weight: 0,
policies: _.cloneDeep(policies),
},
},
];
for (let i = 1; i <= batch; i++) {
const batchStep: WorkflowStep = {
name: step.name + '-batch-' + i,
alias: 'Batch ' + i,
type: DeployModes.CanaryDeploy,
properties: {
weight: i == batch - 1 ? 100 : interval * (i + 1),
weight: i == batch ? 100 : interval * i,
policies: [],
},
};
Expand Down
87 changes: 48 additions & 39 deletions packages/velaux-ui/src/pages/ApplicationWorkflowStudio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,52 +231,61 @@ class ApplicationWorkflowStudio extends React.Component<Props, State> {
style={{
display: 'flex',
justifyContent: 'end',
flexWrap: 'wrap',
}}
>
<div
style={{
display: 'flex',
width: '100%',
justifyContent: 'end',
}}
>
<MenuButton
style={{ marginRight: 'var(--spacing-4)' }}
autoWidth={false}
label={i18n.t('More').toString()}
>
<MenuButton.Item
onClick={() => {
locationService.partial({ setCanary: true });
this.setState({ setCanary: true });
}}
>
<Translation>Canary Rollout Setting</Translation>
</MenuButton.Item>
</MenuButton>
<Form.Item label={i18n.t('Mode').toString()} labelAlign="inset" style={{ marginRight: '8px' }}>
<Select
locale={locale().Select}
defaultValue="StepByStep"
value={mode}
dataSource={WorkflowModeOptions}
onChange={(value) => {
this.setState({ mode: value, changed: this.state.mode !== value });
}}
/>
</Form.Item>
<Form.Item label={i18n.t('Sub Mode').toString()} labelAlign="inset" style={{ marginRight: '8px' }}>
<Select
locale={locale().Select}
defaultValue="DAG"
value={subMode}
onChange={(value) => {
this.setState({ subMode: value, changed: this.state.subMode !== value });
}}
dataSource={WorkflowModeOptions}
/>
</Form.Item>
<Button disabled={!changed} loading={saveLoading} type="primary" onClick={this.onSave}>
<Translation>Save</Translation>
</Button>
</div>
{changed && (
<div className="notice-changes">
<Translation>Unsaved changes</Translation>
</div>
)}
<MenuButton
style={{ marginRight: 'var(--spacing-4)' }}
autoWidth={false}
label={i18n.t('More').toString()}
>
<MenuButton.Item
onClick={() => {
locationService.partial({ setCanary: true });
this.setState({ setCanary: true });
}}
>
<Translation>Canary Rollout Setting</Translation>
</MenuButton.Item>
</MenuButton>
<Form.Item label={i18n.t('Mode').toString()} labelAlign="inset" style={{ marginRight: '8px' }}>
<Select
locale={locale().Select}
defaultValue="StepByStep"
value={mode}
dataSource={WorkflowModeOptions}
onChange={(value) => {
this.setState({ mode: value, changed: this.state.mode !== value });
}}
/>
</Form.Item>
<Form.Item label={i18n.t('Sub Mode').toString()} labelAlign="inset" style={{ marginRight: '8px' }}>
<Select
locale={locale().Select}
defaultValue="DAG"
value={subMode}
onChange={(value) => {
this.setState({ subMode: value, changed: this.state.subMode !== value });
}}
dataSource={WorkflowModeOptions}
/>
</Form.Item>
<Button disabled={!changed} loading={saveLoading} type="primary" onClick={this.onSave}>
<Translation>Save</Translation>
</Button>
</Col>
</Row>
</Card>
Expand Down

0 comments on commit 47f2313

Please sign in to comment.