Skip to content

Commit

Permalink
[7.16] Implement getMinimalSupportedVersion for all NameDiffs (#81374) (
Browse files Browse the repository at this point in the history
#81424)

* Implement getMinimalSupportedVersion for all NameDiffs (#81374)

This removes the default implementation of `getMinimalSupportedVersion`
and implements it in all `NameDiffs` implementations.

The default implementation was rather broad, `minimumIndexCompatibilityVersion`
as the index compatibility are wider than our wire compatibility.
Having a default implementation also had the implementors forget about
adjusting the wire compatibility to the correct version.

(cherry picked from commit 5546d5a)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetadata.java
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformMetadata.java
#	x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/allocation/TrainedModelAllocationMetadata.java
  • Loading branch information
andreidan committed Dec 7, 2021
1 parent d64e867 commit d26b202
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public interface NamedDiff<T extends Diffable<T>> extends Diff<T>, NamedWriteabl
/**
* The minimal version of the recipient this custom object can be sent to
*/
default Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumIndexCompatibilityVersion();
}
Version getMinimalSupportedVersion();

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,10 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_7_0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public int getRemovedCount() {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SingleNodeShutdownMetadata> readNodesDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SingleNodeShutdownMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return NODE_SHUTDOWN_VERSION;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void writeTo(StreamOutput out) throws IOException {
public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public Metadata.Custom apply(Metadata.Custom part) {
public void writeTo(StreamOutput out) throws IOException {
pipelines.writeTo(out);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SingleFeatureMigrationResult> readDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SingleFeatureMigrationResult::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return MIGRATION_ADDED_VERSION;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ static Diff<AutoscalingPolicyMetadata> readFrom(final StreamInput in) throws IOE
return AbstractDiffable.readDiffFrom(AutoscalingPolicyMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_8_0;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

@Override
public Version getMinimalSupportedVersion() {
return Version.V_6_6_0;
return Version.CURRENT.minimumCompatibilityVersion();
}

@Override
Expand Down Expand Up @@ -183,6 +183,11 @@ public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}

static Diff<LifecyclePolicyMetadata> readLifecyclePolicyDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(LifecyclePolicyMetadata::new, in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public boolean isResetMode() {

@Override
public Version getMinimalSupportedVersion() {
return Version.V_6_0_0_alpha1;
return Version.CURRENT.minimumCompatibilityVersion();
}

@Override
Expand Down Expand Up @@ -287,6 +287,11 @@ public String getWriteableName() {
return TYPE;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
}

static Diff<Job> readJobDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(Job::new, in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public String getWriteableName() {
public void writeTo(StreamOutput out) throws IOException {
modelAliasesDiff.writeTo(out);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_13_0;
}

}

public static class ModelAliasEntry extends AbstractDiffable<ModelAliasEntry> implements ToXContentObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,11 @@ public void writeTo(StreamOutput out) throws IOException {
static Diff<SnapshotLifecyclePolicyMetadata> readLifecyclePolicyDiffFrom(StreamInput in) throws IOException {
return AbstractDiffable.readDiffFrom(SnapshotLifecyclePolicyMetadata::new, in);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_4_0;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected Reader<Diff<Custom>> diffReader() {
}

public void testMinimumSupportedVersion() {
assertEquals(Version.V_6_6_0, createTestInstance().getMinimalSupportedVersion());
assertEquals(Version.V_6_8_0, createTestInstance().getMinimalSupportedVersion());
}

public void testcontext() {
Expand Down

0 comments on commit d26b202

Please sign in to comment.