[CCR] Delay auto follow license check (#33557)
* [CCR] Delay auto follow license check so that we're sure that there are auto follow patterns configured Otherwise we log a warning in case someone is running with basic or gold license and has not used the ccr feature.
This commit is contained in:
parent
c4adcee3ea
commit
8eebca32d2
|
@ -70,12 +70,6 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAutoFollow() {
|
private void doAutoFollow() {
|
||||||
if (ccrLicenseChecker.isCcrAllowed() == false) {
|
|
||||||
// TODO: set non-compliant status on auto-follow coordination that can be viewed via a stats API
|
|
||||||
LOGGER.warn("skipping auto-follower coordination", LicenseUtils.newComplianceException("ccr"));
|
|
||||||
threadPool.schedule(pollInterval, ThreadPool.Names.SAME, this::doAutoFollow);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (localNodeMaster == false) {
|
if (localNodeMaster == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +85,13 @@ public class AutoFollowCoordinator implements ClusterStateApplier {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ccrLicenseChecker.isCcrAllowed() == false) {
|
||||||
|
// TODO: set non-compliant status on auto-follow coordination that can be viewed via a stats API
|
||||||
|
LOGGER.warn("skipping auto-follower coordination", LicenseUtils.newComplianceException("ccr"));
|
||||||
|
threadPool.schedule(pollInterval, ThreadPool.Names.SAME, this::doAutoFollow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Consumer<Exception> handler = e -> {
|
Consumer<Exception> handler = e -> {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
LOGGER.warn("failure occurred during auto-follower coordination", e);
|
LOGGER.warn("failure occurred during auto-follower coordination", e);
|
||||||
|
|
|
@ -12,6 +12,10 @@ import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.ElasticsearchSecurityException;
|
import org.elasticsearch.ElasticsearchSecurityException;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||||
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
|
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||||
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
|
@ -23,6 +27,8 @@ import org.elasticsearch.xpack.ccr.action.CreateAndFollowIndexAction;
|
||||||
import org.elasticsearch.xpack.ccr.action.FollowIndexAction;
|
import org.elasticsearch.xpack.ccr.action.FollowIndexAction;
|
||||||
import org.elasticsearch.xpack.ccr.action.PutAutoFollowPatternAction;
|
import org.elasticsearch.xpack.ccr.action.PutAutoFollowPatternAction;
|
||||||
import org.elasticsearch.xpack.ccr.action.ShardFollowNodeTask;
|
import org.elasticsearch.xpack.ccr.action.ShardFollowNodeTask;
|
||||||
|
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
|
||||||
|
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -127,6 +133,40 @@ public class CcrLicenseIT extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoFollowCoordinatorLogsSkippingAutoFollowCoordinationWithNonCompliantLicense() throws Exception {
|
public void testAutoFollowCoordinatorLogsSkippingAutoFollowCoordinationWithNonCompliantLicense() throws Exception {
|
||||||
|
// Update the cluster state so that we have auto follow patterns and verify that we log a warning in case of incompatible license:
|
||||||
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||||
|
clusterService.submitStateUpdateTask("test-add-auto-follow-pattern", new ClusterStateUpdateTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||||
|
AutoFollowPattern autoFollowPattern =
|
||||||
|
new AutoFollowPattern(Collections.singletonList("logs-*"), null, null, null, null, null, null, null, null);
|
||||||
|
AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata(
|
||||||
|
Collections.singletonMap("test_alias", autoFollowPattern),
|
||||||
|
Collections.emptyMap()
|
||||||
|
);
|
||||||
|
|
||||||
|
ClusterState.Builder newState = ClusterState.builder(currentState);
|
||||||
|
newState.metaData(MetaData.builder(currentState.getMetaData())
|
||||||
|
.putCustom(AutoFollowMetadata.TYPE, autoFollowMetadata)
|
||||||
|
.build());
|
||||||
|
return newState.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(String source, Exception e) {
|
||||||
|
latch.countDown();
|
||||||
|
fail("unexpected error [" + e.getMessage() + "]");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
latch.await();
|
||||||
|
|
||||||
final Logger logger = LogManager.getLogger(AutoFollowCoordinator.class);
|
final Logger logger = LogManager.getLogger(AutoFollowCoordinator.class);
|
||||||
final MockLogAppender appender = new MockLogAppender();
|
final MockLogAppender appender = new MockLogAppender();
|
||||||
appender.start();
|
appender.start();
|
||||||
|
|
Loading…
Reference in New Issue