mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(opensearch): keep readiness polling after errors (#3373)
* fix(opensearch): keep readiness polling after errors * test(opensearch): remove readiness timing dependency
This commit is contained in:
1 parent
3669c8e84c
commit
713a166a7c
2 files changed
+27
-2
No files matched your search
@@ -347,7 +347,11 @@ public class OpenSearchService implements ResourceProvider {
|
||||
}
|
||||
|
||||
private void startReadinessPoller() {
|
||||
poller.scheduleWithFixedDelay(() -> {
|
||||
poller.scheduleWithFixedDelay(this::pollReadiness, 3, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
void pollReadiness() {
|
||||
try {
|
||||
for (Domain domain : allDomains()) {
|
||||
if (domain.isProcessing() && domainManager.isReady(domain)) {
|
||||
domain.setProcessing(false);
|
||||
@@ -356,7 +360,9 @@ public class OpenSearchService implements ResourceProvider {
|
||||
domain.getDomainName(), domain.getEndpoint());
|
||||
}
|
||||
}
|
||||
}, 3, 3, TimeUnit.SECONDS);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.warn("OpenSearch readiness poll failed; will retry", e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Domain> allDomains() {
|
||||
|
||||
+19
@@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -79,4 +80,22 @@ class OpenSearchServiceTest {
|
||||
assertFalse(domain.isProcessing());
|
||||
verify(domainManager, Mockito.never()).tryStartDomain(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void readinessPollerContinuesAfterOneReadinessFailure() {
|
||||
when(domainManager.tryStartDomain(any())).thenReturn(true);
|
||||
when(domainManager.isReady(any()))
|
||||
.thenThrow(new RuntimeException("temporary readiness failure"))
|
||||
.thenReturn(true);
|
||||
|
||||
service.createDomain("ready-recovery", "OpenSearch_2.11",
|
||||
null, null, null, "us-east-1");
|
||||
|
||||
service.pollReadiness();
|
||||
assertTrue(service.describeDomain("ready-recovery").isProcessing());
|
||||
|
||||
service.pollReadiness();
|
||||
assertFalse(service.describeDomain("ready-recovery").isProcessing());
|
||||
verify(domainManager, atLeast(2)).isReady(any());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user