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

Watcher API watcher_get_settings does not return "X-elastic-product" header #102928

Closed
ldematte opened this issue Dec 4, 2023 · 3 comments · Fixed by #103003
Closed

Watcher API watcher_get_settings does not return "X-elastic-product" header #102928

ldematte opened this issue Dec 4, 2023 · 3 comments · Fixed by #103003
Assignees

Comments

@ldematte
Copy link
Contributor

ldematte commented Dec 4, 2023

Elasticsearch Version

8.12

Installed Plugins

No response

Java Version

bundled

OS Version

N/A

Problem Description

I was fixing an error that omitted the elastic product header checks for V8 (

if (executionContext.esVersion().major == Version.V_7_17_0.major && executionContext.esVersion().after(Version.V_7_17_1)) {
// #84038 and #84089 mean that this assertion fails when running against a small number of 7.17.x released versions
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
}
).
However, by doing that WatcherYamlRestIT » test {p0=watcher/update_settings/10_update_watcher_settings/Test update and get watch settings api} starts to fail.
The "X-elastic-product" header is really missing from the headers. I suspect this bug is due to these lines:
// Stashing and un-stashing the context allows warning headers about accessing a system index to be ignored.
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
IndexMetadata metadata = state.metadata().index(WATCHER_INDEX_NAME);
if (metadata == null) {
listener.onResponse(new GetWatcherSettingsAction.Response(Settings.EMPTY));
} else {
listener.onResponse(new GetWatcherSettingsAction.Response(filterSettableSettings(metadata.getSettings())));
}
}

That clear up the context in the response.

Steps to Reproduce

The bug is present in all versions from 8.8.0 to current; to trigger it is sufficient to call the API and observer the resulting response, and see that the product header is not there.

A way to do that is to remove the if here (

if (executionContext.esVersion().major == Version.V_7_17_0.major && executionContext.esVersion().after(Version.V_7_17_1)) {
// #84038 and #84089 mean that this assertion fails when running against a small number of 7.17.x released versions
checkElasticProductHeader(response.getHeaders("X-elastic-product"));
}
) and run linked failing tests, e.g.
./gradlew ':x-pack:plugin:watcher:qa:rest:yamlRestTest' --tests "org.elasticsearch.smoketest.WatcherYamlRestIT.test {p0=watcher/update_settings/10_update_watcher_settings/Test update and get watch settings api}"

Logs (if relevant)

No response

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@ldematte
Copy link
Contributor Author

ldematte commented Dec 4, 2023

Link to the issues fixing the version check: #102929
The problem can be observed in the failing build scan

@ldematte
Copy link
Contributor Author

ldematte commented Dec 6, 2023

Fix here #103003 ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants