Skip to content

feat(runcommand): implement wait handler for runcommand - #10354

Open
h3adex wants to merge 2 commits into
stackitcloud:mainfrom
h3adex:feat/add-wait-handler-for-run-command
Open

feat(runcommand): implement wait handler for runcommand#10354
h3adex wants to merge 2 commits into
stackitcloud:mainfrom
h3adex:feat/add-wait-handler-for-run-command

Conversation

@h3adex

@h3adex h3adex commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

Wait Handler for Terraform PR: stackitcloud/terraform-provider-stackit#1702

Checklist

  • Issue was linked above
  • No generated code was adjusted manually (check comments in file header)
  • Changelogs
    • Changelog in the root directory was adjusted (see here)
    • Changelog(s) of the service(s) were adjusted (see e.g. here)
  • VERSION file(s) of the service(s) were adjusted
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@h3adex
h3adex requested a review from a team as a code owner August 18, 2026 09:56
@h3adex
h3adex force-pushed the feat/add-wait-handler-for-run-command branch 5 times, most recently from d1663ab to 72b2e00 Compare August 18, 2026 12:03
@h3adex
h3adex force-pushed the feat/add-wait-handler-for-run-command branch 2 times, most recently from 1f1ee3a to 6814871 Compare August 24, 2026 11:25
Comment thread services/runcommand/v1api/wait/wait.go Outdated
Comment thread services/runcommand/v1api/wait/wait.go Outdated
@h3adex

h3adex commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Implemented your suggestions. I've also rebased the PR @SerseusWasTaken

@h3adex
h3adex force-pushed the feat/add-wait-handler-for-run-command branch from 6814871 to d7aa463 Compare August 31, 2026 07:42
@@ -1,3 +1,8 @@
## v1.9.2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do here a minor bump (v1.10.0), because it contains new features. Please update also the VERSION file accordingly

Comment on lines +2 to +3
- `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`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes from v1api can be summarized to one entry. Please update it also accordingly in the root changelog

Suggested change
- `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`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this state be part of the ErrorState? Because this indicates that the execution of the command failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants