Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Add resolve_during_rolling_upgrade field to deprecation issue #75879

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static class DeprecationIssue {
private static final ParseField MESSAGE = new ParseField("message");
private static final ParseField URL = new ParseField("url");
private static final ParseField DETAILS = new ParseField("details");
private static final ParseField RESOLVE_DURING_ROLLING_UPGRADE = new ParseField("resolve_during_rolling_upgrade");
private static final ParseField META = new ParseField("_meta");

static final ConstructingObjectParser<DeprecationIssue, Void> PARSER =
Expand All @@ -136,16 +137,18 @@ public static class DeprecationIssue {
String message = (String) args[1];
String url = (String) args[2];
String details = (String) args[3];
boolean resolveDuringRollingUpgrade = (boolean) args[4];
@SuppressWarnings("unchecked")
Map<String, Object> meta = (Map<String, Object>) args[4];
return new DeprecationIssue(Level.fromString(logLevel), message, url, details, meta);
Map<String, Object> meta = (Map<String, Object>) args[5];
return new DeprecationIssue(Level.fromString(logLevel), message, url, details, resolveDuringRollingUpgrade, meta);
});

static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), LEVEL);
PARSER.declareString(ConstructingObjectParser.constructorArg(), MESSAGE);
PARSER.declareString(ConstructingObjectParser.constructorArg(), URL);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), DETAILS);
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), RESOLVE_DURING_ROLLING_UPGRADE);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> p.map(), META);
}

Expand All @@ -168,13 +171,16 @@ public String toString() {
private final String message;
private final String url;
private final String details;
private final boolean resolveDuringRollingUpgrade;
private final Map<String, Object> meta;

public DeprecationIssue(Level level, String message, String url, @Nullable String details, @Nullable Map<String, Object> meta) {
public DeprecationIssue(Level level, String message, String url, @Nullable String details, boolean resolveDuringRollingUpgrade,
@Nullable Map<String, Object> meta) {
this.level = level;
this.message = message;
this.url = url;
this.details = details;
this.resolveDuringRollingUpgrade = resolveDuringRollingUpgrade;
this.meta = meta;
}

Expand All @@ -194,6 +200,10 @@ public String getDetails() {
return details;
}

public boolean isResolveDuringRollingUpgrade() {
return resolveDuringRollingUpgrade;
}

public Map<String, Object> getMeta() {
return meta;
}
Expand All @@ -211,12 +221,13 @@ public boolean equals(Object o) {
Objects.equals(message, that.message) &&
Objects.equals(url, that.url) &&
Objects.equals(details, that.details) &&
Objects.equals(resolveDuringRollingUpgrade, that.resolveDuringRollingUpgrade) &&
Objects.equals(meta, that.meta);
}

@Override
public int hashCode() {
return Objects.hash(level, message, url, details, meta);
return Objects.hash(level, message, url, details, resolveDuringRollingUpgrade, meta);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private void toXContent(DeprecationInfoResponse.DeprecationIssue issue, XContent
if (issue.getDetails() != null) {
builder.field("details", issue.getDetails());
}
builder.field("resolve_during_rolling_upgrade", issue.isResolveDuringRollingUpgrade());
if (issue.getMeta() != null) {
builder.field("_meta", issue.getMeta());
}
Expand All @@ -99,6 +100,7 @@ private List<DeprecationInfoResponse.DeprecationIssue> createRandomIssues(boolea
randomAlphaOfLength(5),
randomAlphaOfLength(5),
randomBoolean() ? randomAlphaOfLength(5) : null,
randomBoolean(),
randomBoolean() ? randomMap(1, 5, () -> new Tuple<>(randomAlphaOfLength(4), randomAlphaOfLength(4))) : null));
}
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private DeprecationIssue createDeprecationIssue(String localIndexName) {
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/migrating-7.14.html#breaking_714_ccr_changes",
"Auto followed index [" + localIndexName
+ "] follows a remote system index and this behaviour will change in the next major version.",
null
false, null
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static DeprecationIssue checkUserAgentPipelines(ClusterState state) {
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html" +
"#ingest-user-agent-ecs-always",
"Ingest pipelines " + pipelinesWithDeprecatedEcsConfig +
" uses the [ecs] option which needs to be removed to work in 8.0", null);
" uses the [ecs] option which needs to be removed to work in 8.0", false, null);
}
return null;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ static DeprecationIssue checkTemplatesWithTooManyFields(ClusterState state) {
"Index templates " + templatesOverLimit + " have a number of fields which exceeds the automatic field expansion " +
"limit of [" + maxClauseCount + "] and does not have [" + IndexSettings.DEFAULT_FIELD_SETTING.getKey() + "] set, " +
"which may cause queries which use automatic field expansion, such as query_string, simple_query_string, and " +
"multi_match to fail if fields are not explicitly specified in the query.", null);
"multi_match to fail if fields are not explicitly specified in the query.", false, null);
}
return null;
}
Expand Down Expand Up @@ -129,7 +129,8 @@ static DeprecationIssue checkTemplatesWithFieldNamesDisabled(ClusterState state)
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#fieldnames-enabling",
"Index templates " + templatesContainingFieldNames + " use the deprecated `enable` setting for the `"
+ FieldNamesFieldMapper.NAME + "` field. Using this setting in new index mappings will throw an error "
+ "in the next major version and needs to be removed from existing mappings and templates.", null);
+ "in the next major version and needs to be removed from existing mappings and templates.",
false, null);
}
return null;
}
Expand Down Expand Up @@ -167,7 +168,7 @@ static DeprecationIssue checkPollIntervalTooLow(ClusterState state) {
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html" +
"#ilm-poll-interval-limit",
"The Index Lifecycle Management poll interval setting [" + LIFECYCLE_POLL_INTERVAL_SETTING.getKey() + "] is " +
"currently set to [" + pollIntervalString + "], but must be 1s or greater", null);
"currently set to [" + pollIntervalString + "], but must be 1s or greater", false, null);
}
return null;
}
Expand All @@ -189,6 +190,7 @@ static DeprecationIssue checkTemplatesWithMultipleTypes(ClusterState state) {
"https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html",
"Index templates " + templatesWithMultipleTypes
+ " define multiple types and so will cause errors when used in index creation",
false,
null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private static List<DeprecationIssue> mergeNodeIssues(NodesDeprecationCheckRespo
DeprecationIssue issue = entry.getKey();
String details = issue.getDetails() != null ? issue.getDetails() + " " : "";
return new DeprecationIssue(issue.getLevel(), issue.getMessage(), issue.getUrl(),
details + "(nodes impacted: " + entry.getValue() + ")", issue.getMeta());
details + "(nodes impacted: " + entry.getValue() + ")", issue.isResolveDuringRollingUpgrade(),
issue.getMeta());
}).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ public String toString() {
private final String message;
private final String url;
private final String details;
private final boolean resolveDuringRollingUpgrade;
private final Map<String, Object> meta;

public DeprecationIssue(Level level, String message, String url, @Nullable String details, @Nullable Map<String, Object> meta) {
public DeprecationIssue(Level level, String message, String url, @Nullable String details, boolean resolveDuringRollingUpgrade,
@Nullable Map<String, Object> meta) {
this.level = level;
this.message = message;
this.url = url;
this.details = details;
this.resolveDuringRollingUpgrade = resolveDuringRollingUpgrade;
this.meta = meta;
}

Expand All @@ -79,6 +82,7 @@ public DeprecationIssue(StreamInput in) throws IOException {
message = in.readString();
url = in.readString();
details = in.readOptionalString();
resolveDuringRollingUpgrade = in.getVersion().onOrAfter(Version.V_7_15_0) && in.readBoolean();
meta = in.getVersion().onOrAfter(Version.V_7_14_0) ? in.readMap() : null;
}

Expand All @@ -98,6 +102,13 @@ public String getDetails() {
return details;
}

/**
* @return whether a deprecation issue can only be resolved during a rolling upgrade when a node is offline.
*/
public boolean isResolveDuringRollingUpgrade() {
return resolveDuringRollingUpgrade;
}

/**
* @return custom metadata, which allows the ui to display additional details
* without parsing the deprecation message itself.
Expand All @@ -112,6 +123,9 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(message);
out.writeString(url);
out.writeOptionalString(details);
if (out.getVersion().onOrAfter(Version.V_7_15_0)) {
out.writeBoolean(resolveDuringRollingUpgrade);
}
if (out.getVersion().onOrAfter(Version.V_7_14_0)) {
out.writeMap(meta);
}
Expand All @@ -126,6 +140,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (details != null) {
builder.field("details", details);
}
builder.field("resolve_during_rolling_upgrade", resolveDuringRollingUpgrade);
if (meta != null) {
builder.field("_meta", meta);
}
Expand All @@ -145,12 +160,13 @@ public boolean equals(Object o) {
Objects.equals(message, that.message) &&
Objects.equals(url, that.url) &&
Objects.equals(details, that.details) &&
Objects.equals(resolveDuringRollingUpgrade, that.resolveDuringRollingUpgrade) &&
Objects.equals(meta, that.meta);
}

@Override
public int hashCode() {
return Objects.hash(level, message, url, details, meta);
return Objects.hash(level, message, url, details, resolveDuringRollingUpgrade, meta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static DeprecationIssue oldIndicesCheck(IndexMetadata indexMetadata) {
"Index created before 7.0",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/" +
"breaking-changes-8.0.html",
"This index was created using version: " + createdWith, null);
"This index was created using version: " + createdWith,
false, null);
}
return null;
}
Expand All @@ -131,7 +132,7 @@ static DeprecationIssue tooManyFieldsCheck(IndexMetadata indexMetadata) {
"This index has [" + fieldCount.get() + "] fields, which exceeds the automatic field expansion limit of 1024 " +
"and does not have [" + IndexSettings.DEFAULT_FIELD_SETTING.getKey() + "] set, which may cause queries which use " +
"automatic field expansion, such as query_string, simple_query_string, and multi_match to fail if fields are not " +
"explicitly specified in the query.", null);
"explicitly specified in the query.", false, null);
}
}
return null;
Expand All @@ -152,7 +153,7 @@ static DeprecationIssue deprecatedDateTimeFormat(IndexMetadata indexMetadata) {
"Date field format uses patterns which has changed meaning in 7.0",
"https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_java_time_changes",
"This index has date fields with deprecated formats: " + fields + ". "
+ JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS, null);
+ JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS, false, null);
}
}
return null;
Expand All @@ -174,7 +175,7 @@ static DeprecationIssue chainedMultiFieldsCheck(IndexMetadata indexMetadata) {
"Multi-fields within multi-fields",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html" +
"#_defining_multi_fields_within_multi_fields",
"The names of fields that contain chained multi-fields: " + issues, null);
"The names of fields that contain chained multi-fields: " + issues, false, null);
}
return null;
}
Expand Down Expand Up @@ -203,7 +204,7 @@ static DeprecationIssue fieldNamesDisabledCheck(IndexMetadata indexMetadata) {
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html" +
"#fieldnames-enabling",
"The index mapping contains a deprecated `enabled` setting for `_field_names` that should be removed moving foward.",
null);
false, null);
}
return null;
}
Expand Down Expand Up @@ -264,7 +265,8 @@ static DeprecationIssue translogRetentionSettingCheck(IndexMetadata indexMetadat
"translog retention settings are ignored",
"https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-translog.html",
"translog retention settings [index.translog.retention.size] and [index.translog.retention.age] are ignored " +
"because translog is no longer used in peer recoveries with soft-deletes enabled (default in 7.0 or later)", null);
"because translog is no longer used in peer recoveries with soft-deletes enabled (default in 7.0 or later)",
false, null);
}
}
return null;
Expand All @@ -277,7 +279,7 @@ static DeprecationIssue checkIndexDataPath(IndexMetadata indexMetadata) {
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/7.13/" +
"breaking-changes-7.13.html#deprecate-shared-data-path-setting";
final String details = "Found index data path configured. Discontinue use of this setting.";
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, null);
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
}
return null;
}
Expand All @@ -298,7 +300,7 @@ private static DeprecationIssue slowLogSettingCheck(IndexMetadata indexMetadata,

final String details = String.format(Locale.ROOT, "Found [%s] configured. Discontinue use of this setting. Use thresholds.",
setting.getKey());
return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, null);
return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, false, null);
}
return null;
}
Expand All @@ -311,7 +313,7 @@ static DeprecationIssue storeTypeSettingCheck(IndexMetadata indexMetadata) {
"https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-store.html",
"[simplefs] is deprecated and will be removed in 8.0. Use [niofs] or other file systems instead. " +
"Elasticsearch 7.15 or later uses [niofs] for the [simplefs] store type " +
"as it offers superior or equivalent performance to [simplefs].", null);
"as it offers superior or equivalent performance to [simplefs].", false, null);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static Optional<DeprecationIssue> checkDataFeedQuery(DatafeedConfig datafeedConf
return Optional.of(new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Datafeed [" + datafeedConfig.getId() + "] uses deprecated query options",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html#breaking_70_search_changes",
deprecations.toString(), null));
deprecations.toString(), false, null));
}
}

Expand All @@ -48,7 +48,7 @@ static Optional<DeprecationIssue> checkDataFeedAggregations(DatafeedConfig dataf
return Optional.of(new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Datafeed [" + datafeedConfig.getId() + "] uses deprecated aggregation options",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
"#breaking_70_aggregations_changes", deprecations.toString(), null));
"#breaking_70_aggregations_changes", deprecations.toString(), false, null));
}
}

Expand Down Expand Up @@ -77,6 +77,7 @@ static Optional<DeprecationIssue> checkModelSnapshot(ModelSnapshot modelSnapshot
),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-upgrade-job-model-snapshot.html",
details.toString(),
false,
Map.of("job_id", modelSnapshot.getJobId(), "snapshot_id", modelSnapshot.getSnapshotId()))
);
}
Expand Down
Loading