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

Add shouldEnforceFetchRegistryAtInit config #1307

Conversation

yobennett
Copy link
Contributor

We add a shouldEnforceFetchRegistryAtInit configuration to support users that want the Eureka client to fail fast during initialization. If shouldEnforceFetchRegistryAtInit is set to true then the client will throw an IllegalStateException during instance construction if its initial attempt to fetch of information from the remote Eureka servers is unsuccessful. This setting does not have an effect if shouldFetchRegistry is set to false.

@@ -435,8 +435,19 @@ public synchronized BackupRegistry get() {
throw new RuntimeException("Failed to initialize DiscoveryClient!", e);
}

if (clientConfig.shouldFetchRegistry() && !fetchRegistry(false)) {
fetchRegistryFromBackup();
if (clientConfig.shouldFetchRegistry()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic here is off, you want to
if (shouldFetch) {
fetch
if (unsuccessful) {
log at info that the normal fetch failed
fetch from backup
if still unsuccessful, log a detailed msg and throw
}
}

Right now you're fetching and then fetching again from backup on success.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I revisited this logic and tried to clean it up. The changes should now require that fetching from both the primary and backup registry fail before applying the shouldEnforceFetchRegistryAtInit configuration.

Copy link
Contributor

@troshko111 troshko111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with the minor nit for the ctor ligic.

We add a `shouldEnforceFetchRegistryAtInit` configuration to support
users that want the Eureka client to fail fast during initialization.
If `shouldEnforceFetchRegistryAtInit` is set to `true` then the client
will throw an `IllegalStateException` during instance construction if
its initial attempt to fetch of information from the remote Eureka
servers (both primary and backup) is unsuccessful. This setting does
not have an effect if `shouldFetchRegistry` is set to `false`.

We also update `fetchRegistryFromBackup` to return `true` if successful.
@yobennett yobennett force-pushed the feature/add-should-enforce-fetch-registry-at-init branch from 2b64ca6 to 2b8c018 Compare June 18, 2020 00:30
@yobennett yobennett merged commit 6438fba into Netflix:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants