Skip to content
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

Fix: Add the prepare step for the canary workflow #779

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 });

Check warning

Code scanning / CodeQL

Potentially inconsistent state update

Component state update uses [potentially inconsistent value](1).
}}
/>
</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 });

Check warning

Code scanning / CodeQL

Potentially inconsistent state update

Component state update uses [potentially inconsistent value](1).
}}
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