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

[BUG] Deprecation message spamming logs from Security plugin #1108

Closed
vamshin opened this issue Jul 2, 2021 · 19 comments · Fixed by #1660
Closed

[BUG] Deprecation message spamming logs from Security plugin #1108

vamshin opened this issue Jul 2, 2021 · 19 comments · Fixed by #1660

Comments

@vamshin
Copy link
Member

vamshin commented Jul 2, 2021

Describe the bug
Deprecation message spamming the logs


**To Reproduce**
Steps to reproduce the behavior:
1. Stream logs from logstash to OpenSearch with username, password. 

**Expected behavior**
No spamming of logs 

@vamshin
Copy link
Member Author

vamshin commented Jul 2, 2021

Sample Spam logs:

[2021-07-01T05:18:51,291][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:51,293][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:51,295][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,283][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,283][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,283][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,283][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,284][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,286][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,287][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,289][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:52,291][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,330][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,330][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,330][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,331][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,332][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,333][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,333][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,338][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,338][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,338][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,338][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:53,344][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,302][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,302][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,303][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,302][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,306][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,302][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,309][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,302][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,311][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,313][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,316][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:54,319][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:18:57,299][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:02,303][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:04,276][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:09,285][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,312][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,314][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,315][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,317][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,318][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,319][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,321][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,322][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,323][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default
[2021-07-01T05:19:29,324][DEPRECATION][o.o.d.c.m.IndexNameExpressionResolver] [0e77307b90eb] this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default

@CEHENKLE CEHENKLE transferred this issue from opensearch-project/OpenSearch Jul 5, 2021
@vrozov
Copy link
Contributor

vrozov commented Jul 8, 2021

@CEHENKLE the logging is from OS, not from the security plugin. Please provide details on how the message can be suppressed by the security plugin or disable it on the OS side.

@Kyefer
Copy link

Kyefer commented Jul 22, 2021

I am also seeing this issue when I running a periodic health check against the REST endpoint /_cluster/health.

According to the Elastic System Indices Feature, the /_cluster/health path should allow access to to system indices. However, it seems like with the security plugin installed, that is no longer the case.

I've gone through the source code for both OpenSearch and this plugin and I think the issue is with how the plugin injects the authentication validation code before all REST route handlers.

Here is what I've found:

In org.opensearch.security.filter.SecurityRestFilter, the wrap(RestHandler, AdminDNs) method takes the original RestHandler that is passed in and creates a new one with only the handleRequest(RestRequest, RestChannel, NodeClient) overridden. However, there are additional default methods of the interface that are not overridden in the method. So when a request to /_cluster/health comes through, the new handler that is "wrapped" uses the default implementation of allowSystemIndexAccessByDefault(), which always returns false while the original handler of class org.opensearch.rest.action.admin.cluster.RestClusterHealthAction has allowSystemIndexAccessByDefault() overridden to always be true.

Since the method returns false, org.opensearch.rest.RestController sets the thread local field of IndexNameExpressionResolver.SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY to false, which gets checked byorg.opensearch.cluster.metadata.IndexNameExpressionResolver and thus these error messages are printed.

@vrozov
Copy link
Contributor

vrozov commented Jul 25, 2021

Based on elastic/elasticsearch#63274 the warning should only be enabled for SNAPSHOT builds.

@vrozov
Copy link
Contributor

vrozov commented Jul 27, 2021

@nknize @dblock @CEHENKLE Is warning still expected to be enabled for SNAPSHOTS build only? If not, when this was changed?

@vamshin
Copy link
Member Author

vamshin commented Jul 27, 2021

Another related issue opendistro-for-elasticsearch/k-NN#356

@vrozov
Copy link
Contributor

vrozov commented Jul 30, 2021

Tried the same scenario on ES 7.10.2 and I don't see any warning. The issue is introduced by OpenSearch.

@dblock
Copy link
Member

dblock commented Aug 18, 2021

Looks like this is coming from

. We probably want to log it once? Moving this issue to the OpenSearch project.

@dblock dblock transferred this issue from opensearch-project/security Aug 18, 2021
@dblock dblock added untriaged v1.1.0 Issues, PRs, related to the 1.1.0 release bug Something isn't working and removed untriaged labels Aug 18, 2021
@dblock
Copy link
Member

dblock commented Aug 18, 2021

Based on elastic/elasticsearch#63274 the warning should only be enabled for SNAPSHOT builds.

Help me find code that supposedly would enable the deprecation logger in snapshot builds?

@VachaShah
Copy link
Collaborator

VachaShah commented Oct 27, 2021

Hi @vamshin , can you add the steps on how to reproduce this issue? I am running OpenSearch with the Logstash and added the configuration following this document, but I am not able to see the deprecation message.

@CEHENKLE CEHENKLE added v1.3.0 and removed v1.2.0 Issues related to version 1.2.0 labels Nov 9, 2021
@VachaShah
Copy link
Collaborator

The warning is being logged from: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/cluster/metadata/IndexNameExpressionResolver.java#L368

Tried to apply custom log level while logging deprecation warnings and change the log level of the deprecation log but that would result in this warning not being printed if the log level threshold is lower.

Raised a PR to avoid logging the warning multiple times.

@dblock
Copy link
Member

dblock commented Nov 11, 2021

This entire method should then be deprecated. Who is calling it?

@VachaShah
Copy link
Collaborator

This entire method should then be deprecated. Who is calling it?

Found a lot of instances that use the IndexNameExpressionResolver which uses the check method for system indices access.

@aw-was-here
Copy link

aw-was-here commented Nov 18, 2021

FWIW, under OpenDistro 1.13.2:

  • single node (no clients)-> no spam
  • 3-node master (no clients)-> 5 messages every 30 seconds on every ES node

I was planning on doing 1.11.0 (what we currently have deployed) -> 1.13.2 (wait 2 weeks) -> OpenSearch 1.x.x but this log spam is going to make it nearly impossible. Is there anything we can do to shut it up?

@dblock
Copy link
Member

dblock commented Nov 19, 2021

I don't know about workarounds, but possibly there's a way to disable the logger in log4j configuration?

@VachaShah is working on a solution in #1537

@aw-was-here
Copy link

For those of you that need a fix now, this issue was already discussed by the community a while back:

https://discuss.opendistrocommunity.dev/t/upgrading-from-odfe-1-11-0-to-1-12-0-deprection-logs-complain-about-a-lot/4389/4

@fandigunawan
Copy link

Hi everyone, I got this kind of message on OpenSearch 1.2.3
This message log perhaps will help to reproduce the bug.
2022-01-24 11:57:50,736 [WARN] from org.elasticsearch.client.RestClient in I/O dispatcher 2 - request [POST https://orch-db-node-2:9200/imt-orch_6/_search?scroll=60000ms] returned 1 warnings: [299 OpenSearch-1.2.3-8a529d7733432bc45baa5ac1c4ba3b2741b57dac "this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default"]

@dblock
Copy link
Member

dblock commented Feb 2, 2022

@fandigunawan The original issue is that you would see this message a ton of times. This was fixed in #1537. Are you still seeing this log many times in 1.2.3?

@xiezhenye
Copy link

xiezhenye commented Mar 2, 2023

I also see a lot of such log like below in opensearch-1.2.4

2023-02-23 06:06:41.430 WARN 55411 --- [trace-summary-task-3,,] org.opensearch.client.RestClient : request [POST http://11.162.218.223:9200/ocp_trace_20230222,ocp_trace_20230223/_search?typed_keys=true&max_concurrent_shard_requests=5&ignore_unavailable=true&expand_wildcards=open&allow_no_indices=true&preference=_shards%3A2&ignore_throttled=false&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true] returned 1 warnings: [299 OpenSearch-1.2.4-e505b10357c03ae8d26d675172402f2f2144ef0f "this request accesses system indices: [.opendistro_security], but in a future major version, direct access to system indices will be prevented by default"]

cwperks added a commit to opensearch-project/security that referenced this issue Aug 30, 2023
### Description

Opening up a PR to describe the issues faced with BWC tests with the
security plugin installed and solicit feedback.

I plan to forward port this change to main, but first wanted to show
this working for 2.9 -> 2.10 tests (as of the time of this writing).

Thanks to the work that @scrawfor99 did in
[core](opensearch-project/OpenSearch#8900) to
supply security settings to testClusters to be able to run the initial
wait for cluster yellow checks with a URL that includes the right
protocol (`https` when security is enabled) along with a username and
password to authenticate the request.

I ran into 4 hurdles to get this to run:

1. Initially the cluster didn't form. After a lot of frustration, I
ended up finding that by supplying `network.bind_host` and
`network.publish_host` to both 127.0.0.1 it resolved the issue. These
could probably be combined into a single `network.host`, but I chose to
keep them separated.
2. I had issue testing changes to the gradle build-tools after making
changes locally. This was the most frustrating hurdle, but ultimately
the solution was to change the [`opensearch.version` setting in
`bwc-test/build.gradle`](https://github.com/opensearch-project/security/blob/2.x/bwc-test/build.gradle#L47)
to `2.10.0-SNAPSHOT`. This value is specifically used as the version of
the gradle build-tools that the [BWC tests
use](https://github.com/opensearch-project/security/blob/main/bwc-test/build.gradle#L58).
The changes I made locally didn't reflect because I was publishing to
maven local from the 2.x branch (currently 2.10) and it was looking for
2.9.0-SNAPSHOT artifacts. After updating the value it found my maven
local snapshots. For this artifact you can produce maven local snapshots
using `./gradlew :build-tools:publishToMavenLocal` from the respective
branch in the core repo.
3. After the waitForYellow checks were able to run successfully, the
REST Client in the SecurityBackwardsCompatibilityIT was also having
problems connecting to the cluster because it didn't recognize the
certificates of the server. I ended up using the overly trustworthy
route where there is no SSL verification for the REST Client used in
this test. I borrowed this implementation from [k-NN's
ODFERestTestCase](https://github.com/opensearch-project/k-NN/blob/2.x/src/testFixtures/java/org/opensearch/knn/ODFERestTestCase.java#L118-L141)
which is widely used in the plugin ecosystem. There is an open issue to
abstract this class into common-utils. More work can be done here to
ensure the rest-high-level-client runs with a truststore with the root
certificate.
4. The last hurdle I faced was a WarningFailureException where the REST
Client could not deserialize the cluster health response because of a
warning that was returned with the response about the request including
system indices. According to this
[comment](opensearch-project/OpenSearch#1108 (comment)),
this may only be enabled in snapshots. To fix this, I set preserve
cluster to true which [bypasses the
method](https://github.com/opensearch-project/OpenSearch/blob/main/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java#L364)
where the error was thrown.

* Category (Enhancement, New feature, Bug fix, Test fix, Refactoring,
Maintenance, Documentation)

Enhancement

### Issues Resolved

#3056

### Check List
- [ ] New functionality includes testing
- [ ] New functionality has been documented
- [ ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
cwperks added a commit to cwperks/security that referenced this issue Aug 30, 2023
Opening up a PR to describe the issues faced with BWC tests with the
security plugin installed and solicit feedback.

I plan to forward port this change to main, but first wanted to show
this working for 2.9 -> 2.10 tests (as of the time of this writing).

Thanks to the work that @scrawfor99 did in
[core](opensearch-project/OpenSearch#8900) to
supply security settings to testClusters to be able to run the initial
wait for cluster yellow checks with a URL that includes the right
protocol (`https` when security is enabled) along with a username and
password to authenticate the request.

I ran into 4 hurdles to get this to run:

1. Initially the cluster didn't form. After a lot of frustration, I
ended up finding that by supplying `network.bind_host` and
`network.publish_host` to both 127.0.0.1 it resolved the issue. These
could probably be combined into a single `network.host`, but I chose to
keep them separated.
2. I had issue testing changes to the gradle build-tools after making
changes locally. This was the most frustrating hurdle, but ultimately
the solution was to change the [`opensearch.version` setting in
`bwc-test/build.gradle`](https://github.com/opensearch-project/security/blob/2.x/bwc-test/build.gradle#L47)
to `2.10.0-SNAPSHOT`. This value is specifically used as the version of
the gradle build-tools that the [BWC tests
use](https://github.com/opensearch-project/security/blob/main/bwc-test/build.gradle#L58).
The changes I made locally didn't reflect because I was publishing to
maven local from the 2.x branch (currently 2.10) and it was looking for
2.9.0-SNAPSHOT artifacts. After updating the value it found my maven
local snapshots. For this artifact you can produce maven local snapshots
using `./gradlew :build-tools:publishToMavenLocal` from the respective
branch in the core repo.
3. After the waitForYellow checks were able to run successfully, the
REST Client in the SecurityBackwardsCompatibilityIT was also having
problems connecting to the cluster because it didn't recognize the
certificates of the server. I ended up using the overly trustworthy
route where there is no SSL verification for the REST Client used in
this test. I borrowed this implementation from [k-NN's
ODFERestTestCase](https://github.com/opensearch-project/k-NN/blob/2.x/src/testFixtures/java/org/opensearch/knn/ODFERestTestCase.java#L118-L141)
which is widely used in the plugin ecosystem. There is an open issue to
abstract this class into common-utils. More work can be done here to
ensure the rest-high-level-client runs with a truststore with the root
certificate.
4. The last hurdle I faced was a WarningFailureException where the REST
Client could not deserialize the cluster health response because of a
warning that was returned with the response about the request including
system indices. According to this
[comment](opensearch-project/OpenSearch#1108 (comment)),
this may only be enabled in snapshots. To fix this, I set preserve
cluster to true which [bypasses the
method](https://github.com/opensearch-project/OpenSearch/blob/main/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java#L364)
where the error was thrown.

* Category (Enhancement, New feature, Bug fix, Test fix, Refactoring,
Maintenance, Documentation)

Enhancement

opensearch-project#3056

- [ ] New functionality includes testing
- [ ] New functionality has been documented
- [ ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
cwperks added a commit to opensearch-project/security that referenced this issue Aug 31, 2023
### Description

Opening up a PR to describe the issues faced with BWC tests with the
security plugin installed and solicit feedback.

Thanks to the work that @scrawfor99 did in
[core](opensearch-project/OpenSearch#8900) to
supply security settings to testClusters to be able to run the initial
wait for cluster yellow checks with a URL that includes the right
protocol (`https` when security is enabled) along with a username and
password to authenticate the request.

I ran into 4 hurdles to get this to run:

1. Initially the cluster didn't form. After a lot of frustration, I
ended up finding that by supplying `network.bind_host` and
`network.publish_host` to both 127.0.0.1 it resolved the issue. These
could probably be combined into a single `network.host`, but I chose to
keep them separated.
2. I had issue testing changes to the gradle build-tools after making
changes locally. This was the most frustrating hurdle, but ultimately
the solution was to change the [`opensearch.version` setting in
`bwc-test/build.gradle`](https://github.com/opensearch-project/security/blob/2.x/bwc-test/build.gradle#L47)
to `2.10.0-SNAPSHOT`. This value is specifically used as the version of
the gradle build-tools that the [BWC tests
use](https://github.com/opensearch-project/security/blob/main/bwc-test/build.gradle#L58).
The changes I made locally didn't reflect because I was publishing to
maven local from the 2.x branch (currently 2.10) and it was looking for
2.9.0-SNAPSHOT artifacts. After updating the value it found my maven
local snapshots. For this artifact you can produce maven local snapshots
using `./gradlew :build-tools:publishToMavenLocal` from the respective
branch in the core repo.
3. After the waitForYellow checks were able to run successfully, the
REST Client in the SecurityBackwardsCompatibilityIT was also having
problems connecting to the cluster because it didn't recognize the
certificates of the server. I ended up using the overly trustworthy
route where there is no SSL verification for the REST Client used in
this test. I borrowed this implementation from [k-NN's
ODFERestTestCase](https://github.com/opensearch-project/k-NN/blob/2.x/src/testFixtures/java/org/opensearch/knn/ODFERestTestCase.java#L118-L141)
which is widely used in the plugin ecosystem. There is an open issue to
abstract this class into common-utils. More work can be done here to
ensure the rest-high-level-client runs with a truststore with the root
certificate.
4. The last hurdle I faced was a WarningFailureException where the REST
Client could not deserialize the cluster health response because of a
warning that was returned with the response about the request including
system indices. According to this
[comment](opensearch-project/OpenSearch#1108 (comment)),
this may only be enabled in snapshots. To fix this, I set preserve
cluster to true which [bypasses the
method](https://github.com/opensearch-project/OpenSearch/blob/main/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java#L364)
where the error was thrown.

* Category (Enhancement, New feature, Bug fix, Test fix, Refactoring,
Maintenance, Documentation)

Enhancement

### Issues Resolved

#3056

### Check List
- [ ] New functionality includes testing
- [ ] New functionality has been documented
- [ ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment