-
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
add APIs to Maintenance Mode in ILM #31410
Conversation
- POST _xpack/index_lifecycle/maintenance/_request - issues a request to be placed into maintenenance mode. This is not immediate, since we must first verify that it is safe to go from REQUESTED -> IN maintenance mode. - POST _xpack/index_lifecycle/maintenance/_stop - issues a request to be taken out (this is immediate) - GET _xpack/index_lifecycle/maintenance - get back the current mode our lifecycle management is in - maintenance mode update task was hardened to support uninstalled metadata - if no metadata is installed, the request/stop actions will install metadata and proceed to try and change it (default start mode is NORMAL) follow-up to elastic#31164.
Pinging @elastic/es-core-infra |
I have some setup issues, I will fix the actions setup tomorrow morning. But, please review the rest when available! I noticed it would be a weird experience to error because the lifecycle metadata wasn't installed... so I decided that these set APIs can install it too. That feels like the more appropriate thing to do, but I can see it being desired to keep the metadata installation to put-lifecycle. let me know what you think |
public class GetMaintenanceModeAction | ||
extends Action<GetMaintenanceModeAction.Request, GetMaintenanceModeAction.Response> { | ||
public static final GetMaintenanceModeAction INSTANCE = new GetMaintenanceModeAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/maintenance/get"; |
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 think this should be cluster:admin/xpack/index_lifecycle/operation_mode/get
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field("in_maintenance_mode", mode == OperationMode.MAINTENANCE); |
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.
Do we need this given we have the mode
below?
builder.startObject(); | ||
builder.field("in_maintenance_mode", mode == OperationMode.MAINTENANCE); | ||
builder.field("operation_mode", mode); | ||
return builder; |
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.
missing end object?
|
||
public class SetOperationModeAction extends Action<SetOperationModeAction.Request, SetOperationModeAction.Response> { | ||
public static final SetOperationModeAction INSTANCE = new SetOperationModeAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/operation_mode"; |
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 think this should be: cluster:admin/xpack/index_lifecycle/operation_mode/set
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class SetOperationModeAction extends Action<SetOperationModeAction.Request, SetOperationModeAction.Response> { |
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 think we should call this PutOperationModeAction
if (currentMetadata.getMaintenanceMode().isValidChange(mode)) { | ||
newMode = mode; | ||
} else { | ||
newMode = currentMetadata.getMaintenanceMode(); |
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 this be any cleaner? We seem to be checking things twice. Maybe we could check for a nell metadata first and then check if the change is valid?
public RestGetOperationModeAction(Settings settings, RestController controller) { | ||
super(settings); | ||
controller.registerHandler(RestRequest.Method.GET, | ||
IndexLifecycle.BASE_PATH + "maintenance", this); |
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 think the endpoint shouldn't contain maintenance
otherwise its confusing what it means when this API returns mode: normal
. Instead I think this should be _xapck/index_lifecycle/mode
or _xapck/index_lifecycle/operation_mode
public RestRequestMaintenanceAction(Settings settings, RestController controller) { | ||
super(settings); | ||
controller.registerHandler(RestRequest.Method.POST, | ||
IndexLifecycle.BASE_PATH + "maintenance/_request", this); |
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 wonder if it would be better to have this endpoint as PUT _xpack/index_lifeycle/operation_mode/{mode}
?
public RestStopMaintenanceAction(Settings settings, RestController controller) { | ||
super(settings); | ||
controller.registerHandler(RestRequest.Method.POST, | ||
IndexLifecycle.BASE_PATH + "maintenance/_stop", this); |
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 wonder if it would be better to have this endpoint as PUT _xpack/index_lifeycle/operation_mode/{mode}?
Could this just be:
where |
@clintongormley yes. I believe I prefer your suggestion. I believe there were two reason we
If one steps away from those two points, "maintenance" is a rather ambiguous term and @colings86, what do you think? |
@colings86 I've made the changes to the new format that Clint suggested! I think we are in a better place, thanks Clint! |
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 minor comments but I think its close
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class SetOperationModeAction extends Action<SetOperationModeAction.Response> { |
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.
Maybe to be consistent with the naming of the other APIs in Elasticsearch we should call this Put
instead of Set
?
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 suppose this felt weird since I am not PUTing a resty resource, especially since it is being exposed by APIs that do not necessarily ever set a specific operation-mode directly, like STOPPED
.
Given all of ^, I also view this as a pedantic argument that loses in the battle of consistency 😄. So I will rename
import org.elasticsearch.xpack.core.indexlifecycle.action.GetOperationModeStatusAction; | ||
import org.elasticsearch.xpack.indexlifecycle.IndexLifecycle; | ||
|
||
public class RestGetOperationModeStatusAction extends BaseRestHandler { |
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 think we should call this API *GetStatusAction
since that is the endpoint that it maps to
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.
agreed, another one of case of "crossed my mind, but decided against it for mediocre reasons". Will change
thanks @colings86, I've updated with the renaming and fixed the failing rest tests |
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 assuming it passes CI
- POST _xpack/index_lifecycle/_stop - issues a request to be placed into STOPPED mode (maintenance mode). This is not immediate, since we must first verify that it is safe to go from STOPPING -> STOPPED. - POST _xpack/index_lifecycle/_start - issues a request to be placed back into RUNNING mode (immediately) - GET _xpack/index_lifecycle/_status - get back the current mode our lifecycle management is in - update task was hardened to support uninstalled metadata - if no metadata is installed, the start/stop actions will install metadata and proceed to try and change it (default start mode is RUNNING) - rename MAINTENANCE -> STOPPED, MAINTENANCE_REQUESTED -> STOPPING, NORMAL -> RUNNING follow-up to #31164.
POST _xpack/index_lifecycle/_stop
This is not immediate, since we must first verify that
it is safe to go from STOPPING -> STOPPED.
POST _xpack/index_lifecycle/_start
GET _xpack/index_lifecycle/_status
update task was hardened to support uninstalled metadata
if no metadata is installed, the start/stop actions will install metadata
and proceed to try and change it (default start mode is RUNNING)
rename MAINTENANCE -> STOPPED, MAINTENANCE_REQUESTED -> STOPPING, NORMAL -> RUNNING
follow-up to #31164.