lxd/operations: Return failed operation state from wait endpoint - #18829
lxd/operations: Return failed operation state from wait endpoint#18829IzzaldinSamir wants to merge 1 commit into
Conversation
Fixes canonical#18715 Signed-off-by: Izzaldin Samir <izzaldinsamir@gmail.com>
|
Hey @IzzaldinSamir! If you closed this because of the failed DCO or CLA checks, no need to restart from scratch! That happens all the time with first contributions.
|
Hey @0xSA7, thanks for looking out! I actually caught a minor code duplication in my Go logic right after opening this, and since my browser editor was acting up with the Git Amend command for the DCO signature, I just spun up a clean branch and recreated it over at #18830. Everything is green and good to go now. I really appreciate the help though! |
Root Cause
The wait endpoint commits to an HTTP 200 OK before blocking on the operation. When
op.Waitreturned an operation error, the handler attempted to render a second HTTP error response instead of returning the operation state. As a result, clients (likelxc network) interpreted failed asynchronous operations as successful because they received a 200 OK without the failure payload.The Fix
Instead of checking the error from
op.Wait(ctx), we now callop.Render()after the wait returns to fetch the actual final state of the operation (which includes failures and timeouts) and return it to the client via aSyncResponse.Added regression coverage in
test/suites/operations.shto ensure duplicate network creations properly return the failure state.Fixes #18715