-
Notifications
You must be signed in to change notification settings - Fork 25.2k
HLRC: Add Lifecycle delete to the HLRC #33142
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
Conversation
Adds support for Lifecycle deletion to the Java High-Level Rest Client. Also includes some stopgap measures to support using the new Client package structure which should be replaced once the structure refactoring is complete. Relates to elastic#33100
Pinging @elastic/es-core-infra |
} | ||
|
||
public void testValidate() { | ||
if (frequently()) { |
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 split this into two different tests rather than using the randomness here? I don't think it buys us anything
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 LGTM assuming @hub-cap is good with the MasterTimeoutRequest
change
|
||
import java.util.Objects; | ||
|
||
public class DeleteLifecycleRequest extends MasterTimeoutRequest<DeleteLifecycleRequest> { |
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.
The transport based APIs extend AcknowledgedRequest
which has a timeout
and ackTimeout
in addition to the masterNodeTimeout
.
(this does not) Curious if is this is intentional ?
The javadoc for AcknowledgedRequest
states Facilitates consistency across different api.
... is that something we should carry forward while still divorcing ourselves from the transport request objects ?
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 based MasterTimeoutRequest
on MasterNodeRequest
, rather than AcknowledgedRequest
, which doesn't have an ackTimeout
. It's possible I should be using AcknowledgedRequest
instead - the difference wasn't immediately clear.
So, to answer your question: It was intentional, but it's possible I intended the wrong thing.
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 talked to @hub-cap on Slack and his answer was that these timeouts should be based on the parameters that the requests can take. To determine this, there should be a Rest<whatever>Action
class which defines those parameters. In this case, RestDeleteLifecycleAction
(see here) defines both timeout
and master_timeout
, so this class should include both.
(Just waiting on some more feedback to make this change)
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.
@gwbrown Thanks for following up. I am working a similar issue and will follow your lead here.
@@ -0,0 +1,55 @@ | |||
/* |
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.
Should this be DeleteIndex
LifecycleRequest ?
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.
From what I saw, the classes with names including IndexLifecycle
seem to relate to index<->lifecycle policy relationships (i.e. lifecycle A
applies to index B
), but ones with just Lifecycle
relate to the management of lifecycles. If that's correct, this class is named correctly.
@dakrone, can you confirm?
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 DeleteLifecyclePolicyRequest
to indicate that the policy is going to be removed, and then DeleteIndexLifecycleRequest
is for when we are removing a lifecycle from an index
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 a couple of minor comments
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
* @param listener the listener to be notified upon request completion | ||
*/ | ||
public void deleteLifecycleAsync(DeleteLifecyclePolicyRequest request, RequestOptions options, |
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.
In the same spirit as @dakrone's comment about renaming the request object to DeleteLifecyclePolicyRequest
I think we should rename these methods to deleteLifecyclePolicy
and deleteLifecyclePolicyAsync
?
@@ -1174,6 +1175,17 @@ static Request xpackUsage(XPackUsageRequest usageRequest) { | |||
return request; | |||
} | |||
|
|||
static Request deleteLifecycle(DeleteLifecyclePolicyRequest deleteLifecyclePolicyRequest) { |
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.
Rename to deleteLifecyclePolicy
?
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.
Yep, +1 to rename this deleteLifecyclePolicy
Just had a brief meeting with @hub-cap - the result of that meeting is that there are some not-well-understood requirements around exactly which timeouts need to/can be shared between request classes. Baz is going to figure those requirements out when he has bandwidth to do so. In the meantime the abstract request class in this PR will change to include both |
I lied - @hub-cap got the base class into I've made all the changes suggest so far, so any last comments on this? If not I'll merge about EOD (this comment + 7 hours) today, assuming CI passes. |
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 comments about some renames
@@ -1174,6 +1175,17 @@ static Request xpackUsage(XPackUsageRequest usageRequest) { | |||
return request; | |||
} | |||
|
|||
static Request deleteLifecycle(DeleteLifecyclePolicyRequest deleteLifecyclePolicyRequest) { |
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.
Yep, +1 to rename this deleteLifecyclePolicy
this.lifecycle = lifecycle; | ||
} | ||
|
||
public String getLifecycle() { |
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 rename these getLifecyclePolicy
?
try { | ||
DeleteLifecyclePolicyRequest req = new DeleteLifecyclePolicyRequest(randomFrom("", null)); | ||
fail("should not be able to create a DeleteLifecyclePolicyRequest with null lifecycle name"); | ||
} catch (IllegalArgumentException exception) { |
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.
For the future, you can use
expectThrows(IllegalArgumentException.class, () -> new DeleteLifecyclePolicyRequest(randomFrom("", null)));
Instead of having to do the try/fail/catch check
Per review comments in elastic#33142
@gwbrown its also been backported as of about an hour ago. So you should be good to go for any 6.5 merging as well. |
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
Adds support for Lifecycle Policy deletion to the Java High-Level Rest Client. Relates to #33100
Adds support for Lifecycle deletion to the Java High-Level Rest Client.
Also includes some stopgap measures to support using the new Client
package structure which should be replaced once the structure
refactoring is complete.
Relates to #33100