-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[Inference API] Check pipelines on delete inference endpoint #109123
Merged
maxhniebergall
merged 20 commits into
main
from
checkPipelinesOnDeleteInferenceEndpoint
May 31, 2024
Merged
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
aa28a7e
renaming
maxhniebergall a7727b6
check for pipeline references
maxhniebergall a58ff8f
add force and dry run options to request
maxhniebergall ac64d14
add force delete and dry run options to Actions
maxhniebergall 290082e
Revert dependency on ml module
maxhniebergall 31d57bf
duplicate InferenceProcessorInfoExtractor to inference module
maxhniebergall 4d58493
Ignore missing IngestMetadata during attempted endpoint delete
maxhniebergall 8ce76b8
Update docs/changelog/109123.yaml
maxhniebergall 9318e22
rename RestDeleteInference Action
maxhniebergall 3929cfd
fix dry run
maxhniebergall e5e62ef
Add integration test and misc improvements
maxhniebergall da3c3e2
Merge branch 'checkPipelinesOnDeleteInferenceEndpoint' of https://git…
maxhniebergall fcbf4c5
Update 109123.yaml
maxhniebergall 9cdbc52
Merge branch 'main' into checkPipelinesOnDeleteInferenceEndpoint
maxhniebergall b7c3a1c
merge fixes
maxhniebergall 73c9135
Improvements from PR review
maxhniebergall e688dea
Moving shared pieces to core (#109183)
jonathan-buttner 038918c
replace `model` in exception message with `inference endpoint`
maxhniebergall 30d4071
Merge branch 'main' into checkPipelinesOnDeleteInferenceEndpoint
maxhniebergall d1faacb
test fix
maxhniebergall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 109123 | ||
summary: "[Inference API] Check for related pipelines on delete inference endpoint" | ||
area: Machine Learning | ||
type: enhancement | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
...ain/java/org/elasticsearch/xpack/core/inference/action/DeleteInferenceEndpointAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.inference.action; | ||
|
||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.inference.TaskType; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public class DeleteInferenceEndpointAction extends ActionType<AcknowledgedResponse> { | ||
|
||
public static final DeleteInferenceEndpointAction INSTANCE = new DeleteInferenceEndpointAction(); | ||
public static final String NAME = "cluster:admin/xpack/inference/delete"; | ||
|
||
public DeleteInferenceEndpointAction() { | ||
super(NAME); | ||
} | ||
|
||
public static class Request extends AcknowledgedRequest<DeleteInferenceEndpointAction.Request> { | ||
|
||
private final String inferenceEndpointId; | ||
private final TaskType taskType; | ||
private final boolean forceDelete; | ||
private final boolean dryRun; | ||
|
||
public Request(String inferenceEndpointId, TaskType taskType, boolean forceDelete, boolean dryRun) { | ||
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, DEFAULT_ACK_TIMEOUT); | ||
this.inferenceEndpointId = inferenceEndpointId; | ||
this.taskType = taskType; | ||
this.forceDelete = forceDelete; | ||
this.dryRun = dryRun; | ||
} | ||
|
||
public Request(StreamInput in) throws IOException { | ||
super(in); | ||
this.inferenceEndpointId = in.readString(); | ||
this.taskType = TaskType.fromStream(in); | ||
if (in.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_ENHANCE_DELETE_ENDPOINT)) { | ||
this.forceDelete = Boolean.TRUE.equals(in.readOptionalBoolean()); | ||
this.dryRun = Boolean.TRUE.equals(in.readOptionalBoolean()); | ||
} else { | ||
this.forceDelete = false; | ||
this.dryRun = false; | ||
} | ||
} | ||
|
||
public String getInferenceEndpointId() { | ||
return inferenceEndpointId; | ||
} | ||
|
||
public TaskType getTaskType() { | ||
return taskType; | ||
} | ||
|
||
public boolean isForceDelete() { | ||
return forceDelete; | ||
} | ||
|
||
public boolean isDryRun() { | ||
return dryRun; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(inferenceEndpointId); | ||
taskType.writeTo(out); | ||
if (out.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_ENHANCE_DELETE_ENDPOINT)) { | ||
out.writeOptionalBoolean(forceDelete); | ||
out.writeOptionalBoolean(dryRun); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DeleteInferenceEndpointAction.Request request = (DeleteInferenceEndpointAction.Request) o; | ||
return Objects.equals(inferenceEndpointId, request.inferenceEndpointId) | ||
&& taskType == request.taskType | ||
&& forceDelete == request.forceDelete | ||
&& dryRun == request.dryRun; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(inferenceEndpointId, taskType, forceDelete, dryRun); | ||
} | ||
} | ||
|
||
public static class Response extends AcknowledgedResponse { | ||
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. the main changes to this file are here, in the Response |
||
|
||
private final String PIPELINE_IDS = "pipelines"; | ||
Set<String> pipelineIds; | ||
|
||
public Response(boolean acknowledged, Set<String> pipelineIds) { | ||
super(acknowledged); | ||
this.pipelineIds = pipelineIds; | ||
} | ||
|
||
public Response(StreamInput in) throws IOException { | ||
super(in); | ||
pipelineIds = in.readCollectionAsSet(StreamInput::readString); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeCollection(pipelineIds, StreamOutput::writeString); | ||
} | ||
|
||
@Override | ||
protected void addCustomFields(XContentBuilder builder, Params params) throws IOException { | ||
super.addCustomFields(builder, params); | ||
builder.field(PIPELINE_IDS, pipelineIds); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder returnable = new StringBuilder(); | ||
returnable.append("acknowledged: ").append(this.acknowledged); | ||
returnable.append(", pipelineIdsByEndpoint: "); | ||
for (String entry : pipelineIds) { | ||
returnable.append(entry).append(", "); | ||
} | ||
return returnable.toString(); | ||
} | ||
} | ||
} |
74 changes: 0 additions & 74 deletions
74
...c/main/java/org/elasticsearch/xpack/core/inference/action/DeleteInferenceModelAction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this file already existed, it was just renamed