-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 an explicit CLEANUP step to migrations v2 #100650
Comments
Pinging @elastic/kibana-core (Team:Core) |
TBH, I’m not completely following the implementation suggestions in #97222 (comment) .
None of these are a silver bullet and we’d still be stuck with having the cleanup logic in If we’re trying to handle cleanup within the model itself and remove the explicit call to cleanup in
The trouble here is we need to build the |
not ideal, indeed, but it catches exceptions thrown during action execution as well https://github.com/elastic/kibana/blob/master/src/core/server/saved_objects/migrationsv2/state_action_machine.ts#L70
I'm not a fan of using exceptions for control flow purposes. It's only a matter of time before we run into their limitations. And as you said, we still have to keep
We will need to call I start thinking that the current implementation is okay-ish and it's not worth refactoring it until we have to. @pgayvallet |
What I would have tried to do is to move the error handling logic one level lower, in the The main goal would be to remove the duplication we got in However, after thinking about the implications, I agree that this is not bullet-proof, as if any error leads to an action/state redispatch, we could just fall into a deadloop if for some reason FATAL and/or CLEANUP throws an error (that would loop FATAL->FATAL indefinitely) and would need additional state logic to ensure we're not going that (this also means we would still need a global catch-all block higher, which just breaks the whole goal of the refactoring). Also the implementation itself would probably more complex than what we got atm.
Yea, seems like trying to improve that part is not worth the cost. The duplication is only a few lines, and is contained inside the same file, so it's not that significant. |
Um, ok, This is worth discussing further as a team then. I've gotten fairly far with the approach I outline above, intercepting all transitions to It's not that much work and I could finish it up, understanding that it might be thrown away. FWIW, my approach should have the same effect as moving the error handling to Please let me know what you think, otherwise we're wasting time here. |
The additional cleanup step that was going to be added cannot be done safely and for the reasons mentioned above, there isn't a need to add an explicit |
Migrations v2 haven't got an explicit CLEANUP stage. It calls
cleanup
function when a migration fails due to an exception or a transition toFATAL
state.kibana/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts
Lines 184 to 196 in 5a5c309
We are going to extend
cleanup
logic with additional async sub-steps (#100631). Therefore, we should be explicit aboutCLEANUP
stage and make a transition to it explicit in our migration flow.See #97222 (comment) for some implementation ideas.
The text was updated successfully, but these errors were encountered: