Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Aug 25, 2025

Closes coder/internal#900

  • Implements coder exp task status
  • Adds testutil.MustURL helper

No robots were harmed in the making of this PR.

- Implements `coder exp task status`
- Adds `testutil.MustURL` helper
@johnstcn johnstcn self-assigned this Aug 25, 2025
args []string
expectOutput string
expectError string
hf func(context.Context) func(http.ResponseWriter, *http.Request)
Copy link
Member Author

Choose a reason for hiding this comment

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

review: I elected to mock the API response instead of standing up a whole coderdtest. We have too many of these as it is.

"testing"
)

func MustURL(t testing.TB, raw string) *url.URL {
Copy link
Member Author

Choose a reason for hiding this comment

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

review: I figured this might be useful.

State: codersdk.TaskStateWorking,
},
})
c.Add(1)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just sad I couldn't write c++ here 😢

Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

I think it'd be nice to have a /status endpoint in coderd that allows follow without polling, but I'm fine with the current implementation for now. Some comments/suggestions inline.


// TODO: right now tasks are still "workspaces" under the hood.
// We should update this once we have a proper task model.
ws, err := namedWorkspace(ctx, client, id)
Copy link
Member

Choose a reason for hiding this comment

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

Is this lookup necessary, is it mainly to support e.g. workspace name rather than plain uuid lookups?

We should perhaps consider supporting name lookup in the get task endpoint.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is basically for convenience due to the current task <-> workspace relationship

@johnstcn johnstcn requested a review from mafredri August 26, 2025 12:15

var (
ctx = testutil.Context(t, testutil.WaitShort)
now = time.Now().UTC() // TODO: replace with quartz
Copy link
Member Author

@johnstcn johnstcn Aug 26, 2025

Choose a reason for hiding this comment

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

review: this is unfortunately flake-prone unless we just test the JSON output which omits the relative time.

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

I think switching to the table approach was a good call, nice. A few suggestions pertaining to JSON output but otherwise LGTM.

Handler: func(i *serpent.Invocation) error {
ctx := i.Context()
ec := codersdk.NewExperimentalClient(client)
id := i.Args[0]
Copy link
Member

Choose a reason for hiding this comment

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

Just realized this could support multiple args (tasks) as well, and watching each. But let's leave that for future.

@johnstcn johnstcn merged commit 5baaf27 into main Aug 26, 2025
31 checks passed
@johnstcn johnstcn deleted the cj/exp-cli-status branch August 26, 2025 15:01
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2025
@johnstcn johnstcn added the cherry-pick/v2.26 Needs to be cherry-picked to the 2.26 release branch label Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cherry-pick/v2.26 Needs to be cherry-picked to the 2.26 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tasks CLI: Add status command
3 participants