Fixed assertion unsafe call of ClusterService.state()#19775
Fixed assertion unsafe call of ClusterService.state()#19775cwperks merged 2 commits intoopensearch-project:mainfrom
Conversation
|
❌ Gradle check result for 0fc2db2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
0fc2db2 to
004694d
Compare
|
❌ Gradle check result for 004694d: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
❌ Gradle check result for 004694d: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19775 +/- ##
============================================
+ Coverage 73.10% 73.13% +0.02%
+ Complexity 70959 70958 -1
============================================
Files 5737 5737
Lines 324766 324766
Branches 46981 46981
============================================
+ Hits 237425 237507 +82
+ Misses 68226 68110 -116
- Partials 19115 19149 +34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ject#19775) * Fixed assertion unsafe call of ClusterService.state() Signed-off-by: Nils Bandener <nils.bandener@eliatra.com> * Added changelog Signed-off-by: Nils Bandener <nils.bandener@eliatra.com> --------- Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
…ject#19775) * Fixed assertion unsafe call of ClusterService.state() Signed-off-by: Nils Bandener <nils.bandener@eliatra.com> * Added changelog Signed-off-by: Nils Bandener <nils.bandener@eliatra.com> --------- Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
Description
I have been recently reviewing test logs of the security plugin and found large amounts of test failures caused by this assertion error:
(source)
This is caused by this code:
OpenSearch/server/src/main/java/org/opensearch/node/ResourceUsageCollectorService.java
Lines 128 to 138 in 753c135
If you examine
ClusterApplierService.state(), you will see that it will throw an assertion error ifclusterStateis still null, something that will happen during early cluster initialization phases. Thus, the testclusterService.state()is bogus, as it won't guard the code in environments with assertions enabled:OpenSearch/server/src/main/java/org/opensearch/cluster/service/ClusterApplierService.java
Lines 236 to 241 in 753c135
One should use
clusterService.isStateInitialised()instead to perform the check assertion-safe.Check List
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.