Skip to content

Commit

Permalink
Make migration thread count counfigurable (#19794)
Browse files Browse the repository at this point in the history
* Make migration thread count counfigurable

* changelog file

* fix wording

* fix build

* use getValueFromInput
  • Loading branch information
gally47 committed Jul 9, 2024
1 parent 47fbeb3 commit a8b1ea8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-19792.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type="f"
message="Make migration thread count counfigurable"

issues=["19792"]
pulls=["19794"]
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export type RemoteReindexMigration = {
error: string,
status: MigrationStatus,
progress: number,
logs: RemoteReindexLog[]
tasks_progress: { [task: string]: number }
logs: RemoteReindexLog[],
tasks_progress: { [task: string]: number },
}

export type RemoteReindexRequest = {
Expand All @@ -53,6 +53,7 @@ export type RemoteReindexRequest = {
indices: string[],
synchronous: boolean,
user: string,
threads: number,
trust_unknown_certs: boolean,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ import styled from 'styled-components';

import { Alert, Input, Row, Col } from 'components/bootstrap';
import { SearchForm, Spinner } from 'components/common';
import { getValueFromInput } from 'util/FormsUtils';

import type { RemoteReindexRequest } from '../../hooks/useRemoteReindexMigrationStatus';
import type { MigrationActions, MigrationState, MigrationStepComponentProps, StepArgs } from '../../Types';
import MigrationStepTriggerButtonToolbar from '../common/MigrationStepTriggerButtonToolbar';

const DEFAULT_THREADS_COUNT = 4;

const IndicesContainer = styled.div`
max-height: 300px;
overflow-y: scroll;
Expand Down Expand Up @@ -91,7 +94,15 @@ const MigrateExistingData = ({ currentStep, onTriggerStep }: MigrationStepCompon
};

const handleChange = async (e: React.ChangeEvent<any>, callback: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors<RemoteReindexRequest>>) => {
await callback(e.target.name, e.target.value);
let value;
value = getValueFromInput(e.target);

if (e.target.name === 'threads') {
value = (value || 0) < 1 ? DEFAULT_THREADS_COUNT : value;
}

await callback(e.target.name, value);

resetConnectionCheck();
};

Expand Down Expand Up @@ -119,6 +130,7 @@ const MigrateExistingData = ({ currentStep, onTriggerStep }: MigrationStepCompon
password: '',
synchronous: false,
indices: [],
threads: DEFAULT_THREADS_COUNT,
trust_unknown_certs: false,
};

Expand Down Expand Up @@ -171,6 +183,16 @@ const MigrateExistingData = ({ currentStep, onTriggerStep }: MigrationStepCompon
value={values.allowlist}
onChange={(e) => handleChange(e, setFieldValue)}
required />
<Input id="threads"
name="threads"
label="Threads count"
help="Threads count defines how many indices will be migrated in parallel (minimum 1, default 4)"
type="number"
min={1}
step={1}
disabled={isLoading}
value={values.threads}
onChange={(e) => handleChange(e, setFieldValue)} />
<Input id="trust_unknown_certs"
name="trust_unknown_certs"
label="Trust unknown certificates"
Expand Down

0 comments on commit a8b1ea8

Please sign in to comment.