Skip to content

Commit 79a620b

Browse files
fix: apply suggestions from review
1 parent 6e338f2 commit 79a620b

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

agent/agentscripts/agentscripts.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript,
355355

356356
var status proto.Timing_Status
357357
switch {
358-
case !timedOut && !pipesLeftOpen && exitCode == 0:
359-
status = proto.Timing_OK
360-
case !timedOut && !pipesLeftOpen && exitCode != 0:
361-
status = proto.Timing_EXIT_FAILURE
362358
case timedOut:
363359
status = proto.Timing_TIMED_OUT
364360
case pipesLeftOpen:
365361
status = proto.Timing_PIPES_LEFT_OPEN
362+
case exitCode != 0:
363+
status = proto.Timing_EXIT_FAILURE
364+
default:
365+
status = proto.Timing_OK
366366
}
367367

368368
reportTimeout := 30 * time.Second

coderd/database/dump.sql

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/migrations/000257_workspace_agent_script_timings.up.sql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ CREATE TYPE workspace_agent_script_timing_stage AS ENUM (
44
'start',
55
'stop',
66
'cron'
7-
);
7+
);
8+
9+
COMMENT ON TYPE workspace_agent_script_timing_stage IS 'What stage the script was ran in.';
810

911
CREATE TYPE workspace_agent_script_timing_status AS ENUM (
1012
'ok',
1113
'exit_failure',
1214
'timed_out',
1315
'pipes_left_open'
14-
);
16+
);
17+
18+
COMMENT ON TYPE workspace_agent_script_timing_status IS 'What the exit status of the script is.';
1519

1620
CREATE TABLE workspace_agent_script_timings
1721
(
@@ -20,7 +24,8 @@ CREATE TABLE workspace_agent_script_timings
2024
ended_at timestamp with time zone NOT NULL,
2125
exit_code int NOT NULL,
2226
stage workspace_agent_script_timing_stage NOT NULL,
23-
status workspace_agent_script_timing_status NOT NULL
27+
status workspace_agent_script_timing_status NOT NULL,
28+
UNIQUE (script_id, started_at)
2429
);
2530

26-
ALTER TABLE workspace_agent_script_timings ADD UNIQUE (script_id, started_at);
31+
COMMENT ON TYPE workspace_agent_script_timings IS 'Timing and execution information about a script run.';

coderd/database/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)