feat(runcommand): implement wait handler for runcommand - #10354
Conversation
d1663ab to
72b2e00
Compare
1f1ee3a to
6814871
Compare
|
Implemented your suggestions. I've also rebased the PR @SerseusWasTaken |
6814871 to
d7aa463
Compare
| @@ -1,3 +1,8 @@ | |||
| ## v1.9.2 | |||
There was a problem hiding this comment.
I would do here a minor bump (v1.10.0), because it contains new features. Please update also the VERSION file accordingly
| - `v1api`: **Feature:** Add `AgentReadyWaitHandler` wait handler for waiting until the server agent has registered and submitting a command | ||
| - `v1api`: **Feature:** Add `RunCommandWaitHandler` wait handler for polling a command until it reaches a terminal state (`completed` or `failed`) |
There was a problem hiding this comment.
The changes from v1api can be summarized to one entry. Please update it also accordingly in the root changelog
| - `v1api`: **Feature:** Add `AgentReadyWaitHandler` wait handler for waiting until the server agent has registered and submitting a command | |
| - `v1api`: **Feature:** Add `RunCommandWaitHandler` wait handler for polling a command until it reaches a terminal state (`completed` or `failed`) | |
| - `v1api`: | |
| - **Feature:** Add `AgentReadyWaitHandler` wait handler for waiting until the server agent has registered and submitting a command | |
| - **Feature:** Add `RunCommandWaitHandler` wait handler for polling a command until it reaches a terminal state (`completed` or `failed`) |
There was a problem hiding this comment.
There is already also the v2api available. I would suggest to add the wait handler only to the v2api, except there is a specific reason, why someone shouldn't use the v2api
| // On success, it returns the NewCommandResponse with the submitted command ID. | ||
| func AgentReadyWaitHandler(ctx context.Context, a runcommand.DefaultAPI, projectId, serverId string, payload runcommand.CreateCommandPayload) *wait.AsyncActionHandler[runcommand.NewCommandResponse] { | ||
| handler := wait.New(func() (bool, *runcommand.NewCommandResponse, error) { | ||
| resp, err := a.CreateCommand(ctx, projectId, serverId).CreateCommandPayload(payload).Execute() |
There was a problem hiding this comment.
Isn't there a different endpoint, to check if the agent is ready? Personally I don't like to call create or update endpoints in the waithandler, because it could potentially create multiple resources.
| }, | ||
| ActiveState: []runcommand.CommandDetailsStatus{ | ||
| runcommand.COMMANDDETAILSSTATUS_COMPLETED, | ||
| runcommand.COMMANDDETAILSSTATUS_FAILED, |
There was a problem hiding this comment.
Shouldn't this state be part of the ErrorState? Because this indicates that the execution of the command failed
Description
Wait Handler for Terraform PR: stackitcloud/terraform-provider-stackit#1702
Checklist
make fmtexamples/directory)make test(will be checked by CI)make lint(will be checked by CI)