-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate max number of node connections (#196908)
#Closes [#110155](#110155) ## Summary Currently Elastic Search has a limitation of 2^31-1 (2147483647) maximum node connections. This PR adds this hardcoded value and is used to validate that the input does not exceed this value and, therefore, the user does not have to wait for the server to return the error to know that they have entered a number that is too high. ES does not have an API to query the number, that's why it is hardcoded. <img width="1500" alt="Screenshot 2024-10-18 at 17 13 14" src="https://github.com/user-attachments/assets/c18a4756-df76-4e0e-ba31-5118208f686d">
- Loading branch information
1 parent
46eda4c
commit 860e445
Showing
12 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ents/remote_cluster_form/validators/__snapshots__/validate_node_connections.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ion/sections/components/remote_cluster_form/validators/validate_node_connections.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { MAX_NODE_CONNECTIONS } from '../../../../../../common/constants'; | ||
import { validateNodeConnections } from './validate_node_connections'; | ||
|
||
describe('validateNodeConnections', () => { | ||
test('rejects numbers larger than MaxValue', () => { | ||
expect(validateNodeConnections(MAX_NODE_CONNECTIONS + 1)).toMatchSnapshot(); | ||
}); | ||
|
||
test('accepts numbers equal than MaxValue', () => { | ||
expect(validateNodeConnections(MAX_NODE_CONNECTIONS)).toBe(null); | ||
}); | ||
|
||
test('accepts numbers smaller than MaxValue', () => { | ||
expect(validateNodeConnections(MAX_NODE_CONNECTIONS - 1)).toBe(null); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
...lication/sections/components/remote_cluster_form/validators/validate_node_connections.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { MAX_NODE_CONNECTIONS } from '../../../../../../common/constants'; | ||
|
||
export function validateNodeConnections(connections?: number | null): null | JSX.Element { | ||
if (connections && connections > MAX_NODE_CONNECTIONS) { | ||
return ( | ||
<FormattedMessage | ||
id="xpack.remoteClusters.form.errors.maxValue" | ||
defaultMessage="This number must be equal or less than {maxValue}." | ||
values={{ | ||
maxValue: MAX_NODE_CONNECTIONS, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters