Skip to content

Commit

Permalink
refactor(boot): increases wait timeout for servlets initialization (#…
Browse files Browse the repository at this point in the history
…8947)

Co-authored-by: RyanHolstien <[email protected]>
  • Loading branch information
PatrickfBraz and RyanHolstien authored Oct 5, 2023
1 parent 3cede10 commit debac3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ bootstrap:
enabled: ${UPGRADE_DEFAULT_BROWSE_PATHS_ENABLED:false} # enable to run the upgrade to migrate legacy default browse paths to new ones
backfillBrowsePathsV2:
enabled: ${BACKFILL_BROWSE_PATHS_V2:false} # Enables running the backfill of browsePathsV2 upgrade step. There are concerns about the load of this step so hiding it behind a flag. Deprecating in favor of running through SystemUpdate
servlets:
waitTimeout: ${BOOTSTRAP_SERVLETS_WAITTIMEOUT:60} # Total waiting time in seconds for servlets to initialize


systemUpdate:
initialBackOffMs: ${BOOTSTRAP_SYSTEM_UPDATE_INITIAL_BACK_OFF_MILLIS:5000}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.context.annotation.Configuration;


/**
* Responsible for coordinating starting steps that happen before the application starts up.
*/
@Configuration
@Slf4j
@Component
public class OnBootApplicationListener {
Expand All @@ -44,6 +47,8 @@ public class OnBootApplicationListener {
@Qualifier("configurationProvider")
private ConfigurationProvider provider;

@Value("${bootstrap.servlets.waitTimeout}")
private int _servletsWaitTimeout;

@EventListener(ContextRefreshedEvent.class)
public void onApplicationEvent(@Nonnull ContextRefreshedEvent event) {
Expand All @@ -62,7 +67,7 @@ public void onApplicationEvent(@Nonnull ContextRefreshedEvent event) {
public Runnable isSchemaRegistryAPIServletReady() {
return () -> {
final HttpGet request = new HttpGet(provider.getKafka().getSchemaRegistry().getUrl());
int timeouts = 30;
int timeouts = _servletsWaitTimeout;
boolean openAPIServeletReady = false;
while (!openAPIServeletReady && timeouts > 0) {
try {
Expand All @@ -79,7 +84,7 @@ public Runnable isSchemaRegistryAPIServletReady() {
timeouts--;
}
if (!openAPIServeletReady) {
log.error("Failed to bootstrap DataHub, OpenAPI servlet was not ready after 30 seconds");
log.error("Failed to bootstrap DataHub, OpenAPI servlet was not ready after {} seconds", timeouts);
System.exit(1);
} else {
_bootstrapManager.start();
Expand Down

0 comments on commit debac3c

Please sign in to comment.