Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(coderd): return agent script timings#14923

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 18 commits intomainfrombq/feat-agent-timings
Oct 14, 2024

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma commentedOct 1, 2024
edited
Loading

Add the agent script timings into the/workspacebuilds/:workspacebuild/timings response.

Close#14876

Add the agent script timings into the `/workspaces/:workspaceId/timings`response.
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Good start, but I think this needs some hardening.

Comment on lines 5834 to 5852
if slices.Contains(scriptIDs, t.ScriptID) {
var script database.WorkspaceAgentScript
for _, s := range scripts {
if s.ID == t.ScriptID {
script = s
break
}
}

rows = append(rows, database.GetWorkspaceAgentScriptTimingsByWorkspaceIDRow{
ScriptID: t.ScriptID,
StartedAt: t.StartedAt,
EndedAt: t.EndedAt,
ExitCode: t.ExitCode,
Stage: t.Stage,
Status: t.Status,
DisplayName: script.DisplayName,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: reduce nesting by keeping the happy path unindented.

i.e.continue if the slice does not contain what you're looking for.

BrunoQuaresma reacted with thumbs up emoji
@BrunoQuaresma
Copy link
CollaboratorAuthor

@dannykopping I'm not sure if I addressed all your comments, but since I made a bunch of changes, I feel it is time for a second review round.

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Great work@BrunoQuaresma!

@@ -1150,7 +1150,6 @@ func New(options *Options) *API {
r.Post("/", api.postWorkspaceAgentPortShare)
r.Delete("/", api.deleteWorkspaceAgentPortShare)
})
r.Get("/timings", api.workspaceTimings)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check if this endpoint got included in a release. If it has, we'll have to keep it.

BrunoQuaresma reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

@BrunoQuaresma In theory this is a breaking change... is there any frontend component using it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Even if there isn't a frontend using it, customers might have already started integrating with it.


build, err := q.GetWorkspaceBuildByID(ctx, id)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Please wrap these errors.

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

What do you mean by " wrap these errors"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
returnnil,err
returnnil,xerrors.Errorf("failed to retrieve workspace build: %w",err)

This adds context for what might be a fairly generic error.


// When: fetching an inexistent build
buildID := uuid.New()
_, err := client.WorkspaceBuildTimings(context.Background(), buildID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of usingcontext.Background, use a context which has a timeout.

BrunoQuaresma reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

I marked some Danny's comments as important. I think the rest can be pushed in the follow-up or next iteration 👍


// When: fetching an inexistent build
buildID := uuid.New()
_, err := client.WorkspaceBuildTimings(context.Background(), buildID)
Copy link
Member

Choose a reason for hiding this comment

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

👍


build, err := q.GetWorkspaceBuildByID(ctx, id)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -1150,7 +1150,6 @@ func New(options *Options) *API {
r.Post("/", api.postWorkspaceAgentPortShare)
r.Delete("/", api.deleteWorkspaceAgentPortShare)
})
r.Get("/timings", api.workspaceTimings)
Copy link
Member

Choose a reason for hiding this comment

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

@BrunoQuaresma In theory this is a breaking change... is there any frontend component using it?

@BrunoQuaresma
Copy link
CollaboratorAuthor

In theory this is a breaking change... is there any frontend component using it?

@mtojek there is not

@mtojek
Copy link
Member

In theory this is a breaking change... is there any frontend component using it?

then I think we can remove it

@dannykopping
Copy link
Contributor

In theory this is a breaking change... is there any frontend component using it?

then I think we can remove it

We have to keep in mind that users can also use the API, so let's check if it made it into a release yet - and if so we have to keep it.

BrunoQuaresma reacted with thumbs up emoji

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Great work@BrunoQuaresma!
I think we can land this

Comment on lines +1279 to +1280
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
t.Cleanup(cancel)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can usetestutil.Context to handle this in future, btw.

@@ -1763,30 +1763,16 @@ func (api *API) workspaceTimings(rw http.ResponseWriter, r *http.Request) {
return
}

provisionerTimings, err := api.Database.GetProvisionerJobTimingsByJobID(ctx, build.JobID)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
timings, err := api.buildTimings(ctx, build)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@BrunoQuaresmaBrunoQuaresma merged commit9c8ecb8 intomainOct 14, 2024
30 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the bq/feat-agent-timings branchOctober 14, 2024 12:31
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 14, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@DanielleMaywoodDanielleMaywoodAwaiting requested review from DanielleMaywood

@mtojekmtojekAwaiting requested review from mtojek

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Expose the agent timings in the /workspace/:workspaceId/timings endpoint
3 participants
@BrunoQuaresma@mtojek@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp