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

[7.8] Ensure default watches are updated for rolling upgrades. (#57185) #57562

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.sniff.ElasticsearchNodesSniffer;
import org.elasticsearch.client.sniff.Sniffer;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -415,7 +416,7 @@ public Iterator<Setting<?>> settings() {
private static final ConcurrentHashMap<String, SecureString> SECURE_AUTH_PASSWORDS = new ConcurrentHashMap<>();
private final ThreadContext threadContext;
private final DateFormatter dateTimeFormatter;

private final ClusterStateListener onLocalMasterListener;
/**
* Create an {@link HttpExporter}.
*
Expand Down Expand Up @@ -476,6 +477,14 @@ public HttpExporter(final Config config, final SSLService sslService, final Thre

// mark resources as dirty after any node failure or license change
listener.setResource(resource);

//for a mixed cluster upgrade, ensure that if master changes and this is the master, allow the resources to re-publish
onLocalMasterListener = clusterChangedEvent -> {
if (clusterChangedEvent.nodesDelta().masterNodeChanged() && clusterChangedEvent.localNodeMaster()) {
resource.markDirty();
}
};
config.clusterService().addListener(onLocalMasterListener);
}

/**
Expand Down Expand Up @@ -935,9 +944,11 @@ public void openBulk(final ActionListener<ExportBulk> listener) {
@Override
public void doClose() {
try {
config.clusterService().removeListener(onLocalMasterListener);
if (sniffer != null) {
sniffer.close();
}

} catch (Exception e) {
logger.error("an error occurred while closing the internal client sniffer", e);
} finally {
Expand Down