ensure no operation is blocked before initial license notification
closes elastic/elasticsearch#906 update comment Original commit: elastic/x-pack-elasticsearch@0bd788720f
This commit is contained in:
parent
28326a2c4c
commit
dcae5fb5f0
|
@ -16,8 +16,9 @@ import org.elasticsearch.license.plugin.core.Licensee.Status;
|
||||||
*/
|
*/
|
||||||
public class ShieldLicenseState {
|
public class ShieldLicenseState {
|
||||||
|
|
||||||
// if we start disabled then we can emit false disabled messages and block legitimate requests...
|
// we initialize the licensee status to enabled with trial operation mode to ensure no
|
||||||
protected volatile Status status = new Status(OperationMode.TRIAL, LicenseState.ENABLED);
|
// legitimate requests are blocked before initial license plugin notification
|
||||||
|
protected volatile Status status = Status.ENABLED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the license allows for security features to be enabled (authc, authz, ip filter, audit, etc)
|
* @return true if the license allows for security features to be enabled (authc, authz, ip filter, audit, etc)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
import org.elasticsearch.license.core.License.OperationMode;
|
|
||||||
import org.elasticsearch.license.plugin.core.*;
|
import org.elasticsearch.license.plugin.core.*;
|
||||||
import org.elasticsearch.shield.ShieldPlugin;
|
import org.elasticsearch.shield.ShieldPlugin;
|
||||||
|
|
||||||
|
@ -25,16 +24,16 @@ public class ShieldLicensee extends AbstractLicenseeComponent<ShieldLicensee> im
|
||||||
@Inject
|
@Inject
|
||||||
public ShieldLicensee(Settings settings, LicenseeRegistry clientService, ShieldLicenseState shieldLicenseState) {
|
public ShieldLicensee(Settings settings, LicenseeRegistry clientService, ShieldLicenseState shieldLicenseState) {
|
||||||
super(settings, ShieldPlugin.NAME, clientService);
|
super(settings, ShieldPlugin.NAME, clientService);
|
||||||
add(new Listener() {
|
|
||||||
@Override
|
|
||||||
public void onChange(Status status) {
|
|
||||||
shieldLicenseState.updateStatus(status);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.shieldLicenseState = shieldLicenseState;
|
this.shieldLicenseState = shieldLicenseState;
|
||||||
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
|
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(Status status) {
|
||||||
|
super.onChange(status);
|
||||||
|
shieldLicenseState.updateStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] expirationMessages() {
|
public String[] expirationMessages() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
|
@ -74,12 +73,11 @@ public class ShieldLicensee extends AbstractLicenseeComponent<ShieldLicensee> im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws ElasticsearchException {;
|
protected void doStart() throws ElasticsearchException {
|
||||||
if (isTribeNode) {
|
// we rely on the initial licensee state to be enabled with trial operation mode
|
||||||
//TODO currently we disable licensing on tribe node. remove this once es core supports merging cluster
|
// to ensure no operation is blocked due to not registering the licensee on a
|
||||||
this.status = new Status(OperationMode.TRIAL, LicenseState.ENABLED);
|
// tribe node
|
||||||
shieldLicenseState.updateStatus(status);
|
if (!isTribeNode) {
|
||||||
} else {
|
|
||||||
super.doStart();
|
super.doStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue