Skip to content

Commit cc95e72

Browse files
zane-neoakolarkunnu
authored andcommitted
Revert opensearch-project#15258 to figure out a better approach to fix the issue. (opensearch-project#16377)
Signed-off-by: zane-neo <zaniu@amazon.com>
1 parent 5753636 commit cc95e72

File tree

3 files changed

+2
-62
lines changed

3 files changed

+2
-62
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8484
- Fix multi-search with template doesn't return status code ([#16265](https://github.com/opensearch-project/OpenSearch/pull/16265))
8585
- [Streaming Indexing] Fix intermittent 'The bulk request must be terminated by a newline [\n]' failures [#16337](https://github.com/opensearch-project/OpenSearch/pull/16337))
8686
- Fix wrong default value when setting `index.number_of_routing_shards` to null on index creation ([#16331](https://github.com/opensearch-project/OpenSearch/pull/16331))
87-
- Fix disk usage exceeds threshold cluster can't spin up issue ([#15258](https://github.com/opensearch-project/OpenSearch/pull/15258)))
8887
- [Workload Management] Make query groups persistent across process restarts [#16370](https://github.com/opensearch-project/OpenSearch/pull/16370)
8988

9089
- Fix inefficient Stream API call chains ending with count() ([#15386](https://github.com/opensearch-project/OpenSearch/pull/15386))

distribution/tools/keystore-cli/src/test/java/org/opensearch/bootstrap/BootstrapTests.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@
3131

3232
package org.opensearch.bootstrap;
3333

34-
import org.opensearch.common.logging.LogConfigurator;
3534
import org.opensearch.common.settings.KeyStoreCommandTestCase;
3635
import org.opensearch.common.settings.KeyStoreWrapper;
3736
import org.opensearch.common.settings.SecureSettings;
3837
import org.opensearch.common.settings.Settings;
3938
import org.opensearch.common.util.io.IOUtils;
4039
import org.opensearch.core.common.settings.SecureString;
4140
import org.opensearch.env.Environment;
42-
import org.opensearch.node.Node;
4341
import org.opensearch.test.OpenSearchTestCase;
4442
import org.junit.After;
4543
import org.junit.Before;
@@ -53,14 +51,8 @@
5351
import java.nio.file.Path;
5452
import java.util.ArrayList;
5553
import java.util.List;
56-
import java.util.concurrent.CountDownLatch;
57-
import java.util.concurrent.TimeUnit;
58-
import java.util.concurrent.atomic.AtomicInteger;
5954

6055
import static org.hamcrest.Matchers.equalTo;
61-
import static org.mockito.Mockito.doAnswer;
62-
import static org.mockito.Mockito.mock;
63-
import static org.mockito.Mockito.verify;
6456

6557
public class BootstrapTests extends OpenSearchTestCase {
6658
Environment env;
@@ -139,38 +131,4 @@ private void assertPassphraseRead(String source, String expected) {
139131
}
140132
}
141133

142-
public void testInitExecutionOrder() throws Exception {
143-
AtomicInteger order = new AtomicInteger(0);
144-
CountDownLatch countDownLatch = new CountDownLatch(1);
145-
Thread mockThread = new Thread(() -> {
146-
assertEquals(0, order.getAndIncrement());
147-
countDownLatch.countDown();
148-
});
149-
150-
Node mockNode = mock(Node.class);
151-
doAnswer(invocation -> {
152-
try {
153-
boolean threadStarted = countDownLatch.await(1000, TimeUnit.MILLISECONDS);
154-
assertTrue(
155-
"Waited for one second but the keepAliveThread isn't started, please check the execution order of"
156-
+ "keepAliveThread.start and node.start",
157-
threadStarted
158-
);
159-
} catch (InterruptedException e) {
160-
fail("Thread interrupted");
161-
}
162-
assertEquals(1, order.getAndIncrement());
163-
return null;
164-
}).when(mockNode).start();
165-
166-
LogConfigurator.registerErrorListener();
167-
Bootstrap testBootstrap = new Bootstrap(mockThread, mockNode);
168-
Bootstrap.setInstance(testBootstrap);
169-
170-
Bootstrap.startInstance(testBootstrap);
171-
172-
verify(mockNode).start();
173-
assertEquals(2, order.get());
174-
}
175-
176134
}

server/src/main/java/org/opensearch/bootstrap/Bootstrap.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ final class Bootstrap {
9393
private final Thread keepAliveThread;
9494
private final Spawner spawner = new Spawner();
9595

96-
// For testing purpose
97-
static void setInstance(Bootstrap bootstrap) {
98-
INSTANCE = bootstrap;
99-
}
100-
101-
// For testing purpose
102-
Bootstrap(Thread keepAliveThread, Node node) {
103-
this.keepAliveThread = keepAliveThread;
104-
this.node = node;
105-
}
106-
10796
/** creates a new instance */
10897
Bootstrap() {
10998
keepAliveThread = new Thread(new Runnable() {
@@ -347,10 +336,8 @@ private static Environment createEnvironment(
347336
}
348337

349338
private void start() throws NodeValidationException {
350-
// keepAliveThread should start first than node to ensure the cluster can spin up successfully in edge cases:
351-
// https://github.com/opensearch-project/OpenSearch/issues/14791
352-
keepAliveThread.start();
353339
node.start();
340+
keepAliveThread.start();
354341
}
355342

356343
static void stop() throws IOException {
@@ -423,7 +410,7 @@ static void init(final boolean foreground, final Path pidFile, final boolean qui
423410
throw new BootstrapException(e);
424411
}
425412

426-
startInstance(INSTANCE);
413+
INSTANCE.start();
427414

428415
// We don't close stderr if `--quiet` is passed, because that
429416
// hides fatal startup errors. For example, if OpenSearch is
@@ -475,10 +462,6 @@ static void init(final boolean foreground, final Path pidFile, final boolean qui
475462
}
476463
}
477464

478-
static void startInstance(Bootstrap instance) throws NodeValidationException {
479-
instance.start();
480-
}
481-
482465
@SuppressForbidden(reason = "System#out")
483466
private static void closeSystOut() {
484467
System.out.close();

0 commit comments

Comments
 (0)