This Change removes version.distribution when the version.number is overridden with the cluster setting compatibility.override_main_response_version. Signed-off-by: Marc Handalian <handalm@amazon.com>
This commit is contained in:
parent
230f90b554
commit
b749b38043
|
@ -139,9 +139,11 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
builder.field("name", nodeName);
|
||||
builder.field("cluster_name", clusterName.value());
|
||||
builder.field("cluster_uuid", clusterUuid);
|
||||
builder.startObject("version")
|
||||
.field("distribution", build.getDistribution())
|
||||
.field("number", versionNumber)
|
||||
builder.startObject("version");
|
||||
if (isCompatibilityModeDisabled()) {
|
||||
builder.field("distribution", build.getDistribution());
|
||||
}
|
||||
builder.field("number", versionNumber)
|
||||
.field("build_type", build.type().displayName())
|
||||
.field("build_hash", build.hash())
|
||||
.field("build_date", build.date())
|
||||
|
@ -155,6 +157,12 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
return builder;
|
||||
}
|
||||
|
||||
private boolean isCompatibilityModeDisabled() {
|
||||
// if we are not in compatibility mode (spoofing versionNumber), then
|
||||
// build.getQualifiedVersion is always used.
|
||||
return build.getQualifiedVersion().equals(versionNumber);
|
||||
}
|
||||
|
||||
private static final ObjectParser<MainResponse, Void> PARSER = new ObjectParser<>(MainResponse.class.getName(), true,
|
||||
MainResponse::new);
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ public class MainResponseTests extends AbstractSerializingTestCase<MainResponse>
|
|||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
assertTrue(Strings.toString(builder).contains("\"number\":\"" + responseVersion + "\","));
|
||||
assertFalse(Strings.toString(builder).contains("\"distribution\":\"" + Build.CURRENT.getDistribution() + "\","));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue