Marvel: Use cluster UUID in hash function
Original commit: elastic/x-pack-elasticsearch@919f7928f0
This commit is contained in:
parent
392398c7aa
commit
f08b53eb2d
|
@ -44,8 +44,9 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
|
|||
builder.field(Fields.MAX_NODES, license.maxNodes());
|
||||
builder.field(Fields.ISSUED_TO, license.issuedTo());
|
||||
builder.field(Fields.ISSUER, license.issuer());
|
||||
builder.field(Fields.HKEY, hash(license, marvelDoc.getClusterName()));
|
||||
builder.field(Fields.HKEY, hash(license, marvelDoc.clusterUUID()));
|
||||
builder.endObject();
|
||||
|
||||
}
|
||||
}
|
||||
builder.endArray();
|
||||
|
@ -67,8 +68,8 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
|
|||
return hash(status(license), license.uid(), license.type(), String.valueOf(license.expiryDate()), clusterName);
|
||||
}
|
||||
|
||||
public static String hash(String licenseStatus, String licenseUid, String licenseType, String licenseExpiryDate, String clusterName) {
|
||||
String toHash = licenseStatus + licenseUid + licenseType + licenseExpiryDate + clusterName;
|
||||
public static String hash(String licenseStatus, String licenseUid, String licenseType, String licenseExpiryDate, String clusterUUID) {
|
||||
String toHash = licenseStatus + licenseUid + licenseType + licenseExpiryDate + clusterUUID;
|
||||
return Hashing.sha256().hashString(toHash, Charsets.UTF_8).toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.LicensePlugin;
|
||||
import org.elasticsearch.marvel.MarvelPlugin;
|
||||
import org.elasticsearch.marvel.agent.collector.licenses.LicensesCollector;
|
||||
|
@ -94,7 +93,7 @@ public class LicensesRendererIT extends ESIntegTestCase {
|
|||
|
||||
// We basically recompute the hash here
|
||||
String hkey = (String) ((Map) license).get(LicensesRenderer.Fields.HKEY.underscore().toString());
|
||||
String recalculated = LicensesRenderer.hash(status, uid, type, String.valueOf(expiryDate), cluster().getClusterName());
|
||||
String recalculated = LicensesRenderer.hash(status, uid, type, String.valueOf(expiryDate), clusterUUID);
|
||||
assertThat(hkey, equalTo(recalculated));
|
||||
|
||||
assertThat((String) ((Map) license).get(LicensesRenderer.Fields.FEATURE.underscore().toString()), not(isEmptyOrNullString()));
|
||||
|
|
Loading…
Reference in New Issue