Skip to content

feat: add agent timings #14713

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bcfacf7
feat: begin impl of agent script timings
DanielleMaywood Sep 17, 2024
d55b2e6
feat: add job_id and display_name to script timings
DanielleMaywood Sep 17, 2024
05d8a8b
fix: increment migration number
DanielleMaywood Sep 17, 2024
d54f6c3
fix: rename migrations from 251 to 254
DanielleMaywood Sep 18, 2024
d573c67
test: get tests compiling
DanielleMaywood Sep 18, 2024
09a1a42
fix: appease the linter
DanielleMaywood Sep 18, 2024
6d829f3
fix: get tests passing again
DanielleMaywood Sep 18, 2024
4df7831
fix: drop column from correct table
DanielleMaywood Sep 18, 2024
2565f0a
test: add fixture for agent script timings
DanielleMaywood Sep 18, 2024
669b837
fix: typo
DanielleMaywood Sep 18, 2024
df51673
fix: use job id used in provisioner job timings
DanielleMaywood Sep 18, 2024
c6d71d1
fix: increment migration number
DanielleMaywood Sep 18, 2024
a306e48
test: behaviour of script runner
DanielleMaywood Sep 18, 2024
4b0056c
test: rewrite test
DanielleMaywood Sep 18, 2024
14b68a1
test: does exit 1 script break things?
DanielleMaywood Sep 18, 2024
b22cb57
test: rewrite test again
DanielleMaywood Sep 18, 2024
ef5e2fe
fix: revert change
DanielleMaywood Sep 19, 2024
a5b412b
fix: let code breathe
DanielleMaywood Sep 19, 2024
57ebf30
fix: wrap errors
DanielleMaywood Sep 19, 2024
2a49f67
fix: justify nolint
DanielleMaywood Sep 19, 2024
0698584
fix: swap require.Equal argument order
DanielleMaywood Sep 19, 2024
3580069
fix: add mutex operations
DanielleMaywood Sep 19, 2024
9cb1252
feat: add 'ran_on_start' and 'blocked_login' fields
DanielleMaywood Sep 19, 2024
0b0d1ef
fix: update testdata fixture
DanielleMaywood Sep 19, 2024
eb857c1
fix: refer to agent_id instead of job_id in timings
DanielleMaywood Sep 19, 2024
586d88f
fix: JobID -> AgentID in dbauthz_test
DanielleMaywood Sep 19, 2024
b6289bb
fix: add 'id' to scripts, make timing refer to script id
DanielleMaywood Sep 19, 2024
863c3dc
fix: fix broken tests and convert bug
DanielleMaywood Sep 19, 2024
b8d5d1d
fix: update testdata fixtures
DanielleMaywood Sep 19, 2024
61c26ea
fix: update testdata fixtures again
DanielleMaywood Sep 19, 2024
7f8b6f9
feat: capture stage and if script timed out
DanielleMaywood Sep 20, 2024
c20ac32
fix: update migration number
DanielleMaywood Sep 20, 2024
c652133
test: add test for script api
DanielleMaywood Sep 20, 2024
1199b64
fix: fake db query
DanielleMaywood Sep 20, 2024
afa61eb
fix: use UTC time
DanielleMaywood Sep 20, 2024
8d325e2
fix: ensure r.scriptComplete is not nil
DanielleMaywood Sep 20, 2024
aeee582
fix: move err check to right after call
DanielleMaywood Sep 20, 2024
424069c
fix: uppercase sql
DanielleMaywood Sep 20, 2024
9b43a94
fix: use dbtime.Now()
DanielleMaywood Sep 20, 2024
ed31199
fix: debug log on r.scriptCompleted being nil
DanielleMaywood Sep 20, 2024
8814711
fix: ensure correct rbac permissions
DanielleMaywood Sep 20, 2024
0414623
chore: remove DisplayName
DanielleMaywood Sep 20, 2024
a8192a5
Merge branch 'main' into dm-add-agent-timings
DanielleMaywood Sep 20, 2024
08a466a
fix: get tests passing
DanielleMaywood Sep 20, 2024
8e7c757
fix: remove space in sql up
DanielleMaywood Sep 20, 2024
621071e
docs: document ExecuteOption
DanielleMaywood Sep 20, 2024
3b4df92
fix: drop 'RETURNING' from sql
DanielleMaywood Sep 20, 2024
44127b8
chore: remove 'display_name' from timing table
DanielleMaywood Sep 20, 2024
5846216
fix: testdata fixture
DanielleMaywood Sep 20, 2024
c43a143
fix: put r.scriptCompleted call in goroutine
DanielleMaywood Sep 23, 2024
13889bf
fix: track goroutine for test + use separate context for reporting
DanielleMaywood Sep 23, 2024
bf32b89
fix: appease linter, handle trackCommandGoroutine error
DanielleMaywood Sep 23, 2024
7fe6d8c
fix: resolve race condition
DanielleMaywood Sep 23, 2024
d7e86c6
feat: replace timed_out column with status column
DanielleMaywood Sep 23, 2024
6e338f2
test: update testdata fixture
DanielleMaywood Sep 23, 2024
79a620b
fix: apply suggestions from review
DanielleMaywood Sep 24, 2024
180307f
revert: linter changes
DanielleMaywood Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: apply suggestions from review
  • Loading branch information
DanielleMaywood committed Sep 24, 2024
commit 79a620b43e1527d143a33a2a1699eaef2ad4f56b
8 changes: 4 additions & 4 deletions agent/agentscripts/agentscripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript,

var status proto.Timing_Status
switch {
case !timedOut && !pipesLeftOpen && exitCode == 0:
status = proto.Timing_OK
case !timedOut && !pipesLeftOpen && exitCode != 0:
status = proto.Timing_EXIT_FAILURE
case timedOut:
status = proto.Timing_TIMED_OUT
case pipesLeftOpen:
status = proto.Timing_PIPES_LEFT_OPEN
case exitCode != 0:
status = proto.Timing_EXIT_FAILURE
default:
status = proto.Timing_OK
}

reportTimeout := 30 * time.Second
Expand Down
4 changes: 4 additions & 0 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ CREATE TYPE workspace_agent_script_timing_stage AS ENUM (
'start',
'stop',
'cron'
);
);

COMMENT ON TYPE workspace_agent_script_timing_stage IS 'What stage the script was ran in.';

CREATE TYPE workspace_agent_script_timing_status AS ENUM (
'ok',
'exit_failure',
'timed_out',
'pipes_left_open'
);
);

COMMENT ON TYPE workspace_agent_script_timing_status IS 'What the exit status of the script is.';

CREATE TABLE workspace_agent_script_timings
(
Expand All @@ -20,7 +24,8 @@ CREATE TABLE workspace_agent_script_timings
ended_at timestamp with time zone NOT NULL,
exit_code int NOT NULL,
stage workspace_agent_script_timing_stage NOT NULL,
status workspace_agent_script_timing_status NOT NULL
status workspace_agent_script_timing_status NOT NULL,
UNIQUE (script_id, started_at)
);

ALTER TABLE workspace_agent_script_timings ADD UNIQUE (script_id, started_at);
COMMENT ON TYPE workspace_agent_script_timings IS 'Timing and execution information about a script run.';
2 changes: 2 additions & 0 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading