-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[ML] Set df-analytics task state to failed when appropriate #43880
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
Changes from 2 commits
164b365
1bca37c
2ad2d8b
43cb1d3
4cec4c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ | |
package org.elasticsearch.xpack.core.ml.action; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.ActionRequestBuilder; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.TaskOperationFailure; | ||
import org.elasticsearch.action.support.tasks.BaseTasksRequest; | ||
import org.elasticsearch.action.support.tasks.BaseTasksResponse; | ||
|
@@ -158,16 +158,19 @@ public static class Stats implements ToXContentObject, Writeable { | |
private final String id; | ||
private final DataFrameAnalyticsState state; | ||
@Nullable | ||
private final String failureReason; | ||
@Nullable | ||
private final Integer progressPercentage; | ||
@Nullable | ||
private final DiscoveryNode node; | ||
@Nullable | ||
private final String assignmentExplanation; | ||
|
||
public Stats(String id, DataFrameAnalyticsState state, @Nullable Integer progressPercentage, | ||
public Stats(String id, DataFrameAnalyticsState state, @Nullable String failureReason, @Nullable Integer progressPercentage, | ||
@Nullable DiscoveryNode node, @Nullable String assignmentExplanation) { | ||
this.id = Objects.requireNonNull(id); | ||
this.state = Objects.requireNonNull(state); | ||
this.failureReason = failureReason; | ||
this.progressPercentage = progressPercentage; | ||
this.node = node; | ||
this.assignmentExplanation = assignmentExplanation; | ||
|
@@ -176,6 +179,7 @@ public Stats(String id, DataFrameAnalyticsState state, @Nullable Integer progres | |
public Stats(StreamInput in) throws IOException { | ||
id = in.readString(); | ||
state = DataFrameAnalyticsState.fromStream(in); | ||
failureReason = in.readOptionalString(); | ||
progressPercentage = in.readOptionalInt(); | ||
node = in.readOptionalWriteable(DiscoveryNode::new); | ||
assignmentExplanation = in.readOptionalString(); | ||
|
@@ -202,6 +206,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws | |
public XContentBuilder toUnwrappedXContent(XContentBuilder builder) throws IOException { | ||
builder.field(DataFrameAnalyticsConfig.ID.getPreferredName(), id); | ||
builder.field("state", state.toString()); | ||
if (failureReason != null) { | ||
builder.field("failure_reason", failureReason); | ||
dimitris-athanasiou marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it may be prudent to use a more generic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But in the short term while we only populate the field when the job is For the question of why it's not assigned to a node during an upgrade this will already be available in I guess the question is whether to combine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thinking was to avoid having a |
||
} | ||
if (progressPercentage != null) { | ||
builder.field("progress_percent", progressPercentage); | ||
} | ||
|
@@ -229,14 +236,15 @@ public XContentBuilder toUnwrappedXContent(XContentBuilder builder) throws IOExc | |
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(id); | ||
state.writeTo(out); | ||
out.writeOptionalString(failureReason); | ||
out.writeOptionalInt(progressPercentage); | ||
out.writeOptionalWriteable(node); | ||
out.writeOptionalString(assignmentExplanation); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, state, progressPercentage, node, assignmentExplanation); | ||
return Objects.hash(id, state, failureReason, progressPercentage, node, assignmentExplanation); | ||
} | ||
|
||
@Override | ||
|
@@ -250,6 +258,7 @@ public boolean equals(Object obj) { | |
Stats other = (Stats) obj; | ||
return Objects.equals(id, other.id) | ||
&& Objects.equals(this.state, other.state) | ||
&& Objects.equals(this.failureReason, other.failureReason) | ||
&& Objects.equals(this.node, other.node) | ||
&& Objects.equals(this.assignmentExplanation, other.assignmentExplanation); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is in a different doc tag callout, I think the doc build will fail. You may need to move
Up in side the
// tag::stop-data-frame-analytics-request
tag