Skip to content

[Console] Remove odd retry logic and add ES host selector#229574

Merged
sabarasaba merged 6 commits intoelastic:mainfrom
sabarasaba:console-host_config
Jul 31, 2025
Merged

[Console] Remove odd retry logic and add ES host selector#229574
sabarasaba merged 6 commits intoelastic:mainfrom
sabarasaba:console-host_config

Conversation

@sabarasaba
Copy link
Copy Markdown
Member

@sabarasaba sabarasaba commented Jul 28, 2025

Fixes #160380 and #147457

Summary

This PR fixes a critical bug in Console where request body streams were being consumed during host retries, causing subsequent requests to be sent without their body content. The fix removes the automatic retry logic and replaces it with explicit host selection.

By removing the retry logic and giving users explicit host selection, the behavior of console becomes predictable and transparent: users know exactly which host their requests are hitting, can easily switch hosts if one is down, and never risk silent data loss during failed requests. This trades automatic fallback for reliability and user control, which I think is more appropriate for a developer tool where understanding exactly what is happening is crucial.

Release note

Fixed an issue in Console where request bodies were lost during automatic host retries. Console now uses explicit host selection instead of retrying failed hosts, ensuring predictable behavior and preventing silent request failures.

Testing

Add elasticsearch.hosts: ["http://localhost:9200", "http://localhost:9202", "http://localhost:9201"] to your config/kibana.yml and fire up es/kibana. You should be able to ping :9200 which should be your local ES instance without a problem, but the other ports should be for nonexistent instances and should fail instead.

Screenshot 2025-07-28 at 11 41 29 Screenshot 2025-07-28 at 15 23 52
@sabarasaba sabarasaba self-assigned this Jul 28, 2025
@sabarasaba sabarasaba added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor v9.2.0 labels Jul 28, 2025
@sabarasaba sabarasaba marked this pull request as ready for review July 28, 2025 14:57
@sabarasaba sabarasaba requested a review from a team as a code owner July 28, 2025 14:57
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@sabarasaba sabarasaba added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Jul 30, 2025
@sabarasaba
Copy link
Copy Markdown
Member Author

@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@ElenaStoeva ElenaStoeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this long-standing issue @sabarasaba! Tested and worked fine, left a few comments about the code changes.

const [availableHosts, setAvailableHosts] = useState<string[]>([]);

// Get available hosts from esHostService after it's initialized
useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this causes infinite rerendering, probably because when setSelectedHost() is called, selectedHost is changed and so this is run again. We could maybe use props.settings.selectedHost instead of selectedHost?

Untitled.mov
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting! It seems that the re-rendering issue was already there in the original code, turns out that the debouncedSaveSettings is recreated on every render, and since it's in the dependency array of the other useEffect it causes the effect to run on every render, which triggers another render 🤯 Fixed it with 857c340

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for fixing it!

value: host,
inputDisplay: host,
}))}
valueOfSelected={selectedHost || (availableHosts.length > 0 ? availableHosts[0] : '')}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If availableHosts is empty, is it worth displaying this whole field?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available hosts will always have at least one entry, so I still think its worth to show it in order to be more explicit about it (even though its disabled if there is only one option) as it makes it more explicit to the users what it is actually hitting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I see your point. 👍

@sabarasaba sabarasaba enabled auto-merge (squash) July 30, 2025 14:38
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
console 194.1KB 195.4KB +1.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
console 27.7KB 28.0KB +264.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
console 14 15 +1

Total ESLint disabled count

id before after diff
console 15 16 +1

History

cc @sabarasaba

Copy link
Copy Markdown
Contributor

@ElenaStoeva ElenaStoeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my feedback! Latest lgtm.

@sabarasaba sabarasaba merged commit fedd325 into elastic:main Jul 31, 2025
13 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.1

https://github.com/elastic/kibana/actions/runs/16646303489

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 31, 2025
) (#230052)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Console] Remove odd retry logic and add ES host selector
(#229574)](#229574)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Ignacio
Rivas","email":"rivasign@gmail.com"},"sourceCommit":{"committedDate":"2025-07-31T10:17:31Z","message":"[Console]
Remove odd retry logic and add ES host selector
(#229574)","sha":"fedd325d7fe1ce702ac57ae8ed0b133a05bc9b9d","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Feature:Console","Team:Kibana
Management","backport:prev-minor","v9.2.0"],"title":"[Console] Remove
odd retry logic and add ES host
selector","number":229574,"url":"https://github.com/elastic/kibana/pull/229574","mergeCommit":{"message":"[Console]
Remove odd retry logic and add ES host selector
(#229574)","sha":"fedd325d7fe1ce702ac57ae8ed0b133a05bc9b9d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229574","number":229574,"mergeCommit":{"message":"[Console]
Remove odd retry logic and add ES host selector
(#229574)","sha":"fedd325d7fe1ce702ac57ae8ed0b133a05bc9b9d"}}]}]
BACKPORT-->

Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
delanni pushed a commit to delanni/kibana that referenced this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Console Dev Tools Console Feature release_note:enhancement Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// v9.1.1 v9.2.0

4 participants