diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java index 62b3d8ef127c8..562f427ca2cc6 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java @@ -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; @@ -415,7 +416,7 @@ public Iterator> settings() { private static final ConcurrentHashMap SECURE_AUTH_PASSWORDS = new ConcurrentHashMap<>(); private final ThreadContext threadContext; private final DateFormatter dateTimeFormatter; - + private final ClusterStateListener onLocalMasterListener; /** * Create an {@link HttpExporter}. * @@ -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); } /** @@ -935,9 +944,11 @@ public void openBulk(final ActionListener 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 {