-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Adds REST client support for starting and stopping ILM #32609
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
Adds REST client support for starting and stopping ILM #32609
Conversation
Pinging @elastic/es-core-infra |
Any thoughts on my suggestions above? |
I prefer (1.) I re-used the same transport request for simplicity under the hood, I do not think this consolidation should be exposed to the user, and users should see specific objects that reflect what they can or cannot do. |
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.
Not sure if this is the best way to expose this API. I think given the REST api for this API are separate endpoints (_ilm/start and _ilm/stop) that we should either:
- Split this API into two on the transport layer as well and have a StartILMAction and a StopILMAction with their own request and response objects
- Keep the action as is but hide the PutOperationRequest from the user and have the client expose a PutOperationModeResponse startILM(RequestiOptions) method and a PutOperationModeResponse stopILM(RequestOptions) method.
I think I'm more in favor of option 1, even though it will require slightly more code.
I think this helps us not have to expose the PutOperationModeRequest
and the Enum that (I agree) is not particularly friendly to a user. So whatever we can do to avoid exposing that would be great.
@@ -1168,6 +1170,17 @@ static Request setIndexLifecyclePolicy(SetIndexLifecyclePolicyRequest setPolicyR | |||
return request; | |||
} | |||
|
|||
static Request putOperationMode(PutOperationModeRequest putOperationModeRequest) { |
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.
Think it'd be worth renaming this to putLifecycleOperationMode
? I'm worried the name is too generic for a gigantic file that isn't specific to ILM
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.
I left some comments, could you remove the new Response classes and use AcknowledgedResponse everywhere please
|
||
@Inject | ||
public TransportStartILMAction(Settings settings, TransportService transportService, ClusterService clusterService, | ||
ThreadPool threadPool, ActionFilters actionFilters, |
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.
Indentation is off here and the line below (super minor)
|
||
@Inject | ||
public TransportPutOperationModeAction(Settings settings, TransportService transportService, ClusterService clusterService, | ||
public TransportStopILMAction(Settings settings, TransportService transportService, ClusterService clusterService, | ||
ThreadPool threadPool, ActionFilters actionFilters, |
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.
Same here about indentation now
|
||
@Override | ||
public int hashCode() { | ||
return 64; |
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.
How did we arrive at this? (not critiquing, just curious)
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.
random number so no method to pick it really. The problem is that we need to be able to do equality so it has to have some value. Ideally I would have an INSTANCE constant and make the constructor private but the Streamable serialisation relies on the constructor being public
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
public class StartILMResponse extends AcknowledgedResponse implements ToXContentObject { |
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.
Can you remove this class entirely in favor of just returning AcknowledgedResponse? (similar to #32722)
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
|
||
public class StopILMRequest extends AcknowledgedRequest<StopILMRequest> { |
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.
Can you also remove this one in favor of AcknowledgedRequest?
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.
Whoops sorry, ignore this, should only change the Response ones
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
public class StopILMResponse extends AcknowledgedResponse implements ToXContentObject { |
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.
Another to remove
@dakrone I pushed a commit that should address your comments |
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.
LGTM, thanks Colin!
* Adds REST client support for PutOperationMode in ILM * Corrects licence headers * iter * add request converter test * Fixes tests * Creates start and stop actions for controlling ILM operation * Addresses review comments
Not sure if this is the best way to expose this API. I think given the REST api for this API are separate endpoints (
_ilm/start
and_ilm/stop
) that we should either:StartILMAction
and aStopILMAction
with their own request and response objectsPutOperationRequest
from the user and have the client expose aPutOperationModeResponse startILM(RequestiOptions)
method and aPutOperationModeResponse stopILM(RequestOptions)
method.In either case I'm not sure its a good idea to expose the current
PutOperationModeRequest
class to the user since its not particularly user friendly because:a. As far as the user is concerned what they want to do is start and stop ILM not put it into an "operation mode"
b. The
OperationMode
enum itself is not particular user friendly since its values areRUNNING
,STOPPING
andSTOPPED
which relate to the state ILM is in not what you want to do as a user and also becausePutOperationModeRequest
rejectsSTOPPED
because you can't go fromRUNNING
straight toSTOPPED
and this is an implementation detail the user should not need to be concerned with when they use this APIOpen to thoughts.