Skip to content

Commit 9cb1252

Browse files
feat: add 'ran_on_start' and 'blocked_login' fields
1 parent 3580069 commit 9cb1252

File tree

10 files changed

+154
-110
lines changed

10 files changed

+154
-110
lines changed

agent/agentscripts/agentscripts.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,12 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript)
323323

324324
_, err = r.scriptCompleted(ctx, &proto.WorkspaceAgentScriptCompletedRequest{
325325
Timing: &proto.Timing{
326-
DisplayName: script.DisplayName,
327-
Start: timestamppb.New(start),
328-
End: timestamppb.New(end),
329-
ExitCode: int32(exitCode),
326+
DisplayName: script.DisplayName,
327+
Start: timestamppb.New(start),
328+
End: timestamppb.New(end),
329+
ExitCode: int32(exitCode),
330+
RanOnStart: script.RunOnStart,
331+
BlockedLogin: script.StartBlocksLogin,
330332
},
331333
})
332334
}()

agent/proto/agent.pb.go

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

agent/proto/agent.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ message Timing {
277277
google.protobuf.Timestamp start = 2;
278278
google.protobuf.Timestamp end = 3;
279279
int32 exit_code = 4;
280+
bool ran_on_start = 5;
281+
bool blocked_login = 6;
280282
}
281283

282284
service Agent {

coderd/agentapi/scripts.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ func (s *ScriptsAPI) ScriptCompleted(ctx context.Context, req *agentproto.Worksp
2929
}
3030

3131
_, err = s.Database.InsertWorkspaceAgentScriptTimings(ctx, database.InsertWorkspaceAgentScriptTimingsParams{
32-
JobID: resource.JobID,
33-
DisplayName: req.Timing.DisplayName,
34-
StartedAt: req.Timing.Start.AsTime(),
35-
EndedAt: req.Timing.End.AsTime(),
36-
ExitCode: req.Timing.ExitCode,
32+
JobID: resource.JobID,
33+
DisplayName: req.Timing.DisplayName,
34+
StartedAt: req.Timing.Start.AsTime(),
35+
EndedAt: req.Timing.End.AsTime(),
36+
ExitCode: req.Timing.ExitCode,
37+
RanOnStart: req.Timing.RanOnStart,
38+
BlockedLogin: req.Timing.BlockedLogin,
3739
})
3840
if err != nil {
3941
return nil, xerrors.Errorf("insert workspace agent script timings into database: %w", err)

coderd/database/dbmem/dbmem.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7838,11 +7838,13 @@ func (q *FakeQuerier) InsertWorkspaceAgentScriptTimings(_ context.Context, arg d
78387838

78397839
//nolint:gosimple // Stop linter suggesting 'arg' should be of type database.WorkspaceAgentScriptTiming
78407840
scriptTiming := database.WorkspaceAgentScriptTiming{
7841-
StartedAt: arg.StartedAt,
7842-
EndedAt: arg.EndedAt,
7843-
ExitCode: arg.ExitCode,
7844-
DisplayName: arg.DisplayName,
7845-
JobID: arg.JobID,
7841+
StartedAt: arg.StartedAt,
7842+
EndedAt: arg.EndedAt,
7843+
ExitCode: arg.ExitCode,
7844+
DisplayName: arg.DisplayName,
7845+
JobID: arg.JobID,
7846+
RanOnStart: arg.RanOnStart,
7847+
BlockedLogin: arg.BlockedLogin,
78467848
}
78477849

78487850
q.workspaceAgentScriptTimings = append(q.workspaceAgentScriptTimings, scriptTiming)

coderd/database/dump.sql

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
CREATE TABLE workspace_agent_script_timings
22
(
3-
job_id uuid not null references provisioner_jobs (id) on delete cascade,
4-
display_name text not null,
5-
started_at timestamp with time zone not null,
6-
ended_at timestamp with time zone not null,
7-
exit_code int not null
3+
job_id uuid not null references provisioner_jobs (id) on delete cascade,
4+
display_name text not null,
5+
started_at timestamp with time zone not null,
6+
ended_at timestamp with time zone not null,
7+
exit_code int not null,
8+
ran_on_start bool not null,
9+
blocked_login bool not null
810
);
911

1012
ALTER TABLE workspace_agent_scripts ADD COLUMN display_name text not null default '';

coderd/database/models.go

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

coderd/database/queries.sql.go

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

coderd/database/queries/workspaceagents.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ INSERT INTO
295295
display_name,
296296
started_at,
297297
ended_at,
298-
exit_code
298+
exit_code,
299+
ran_on_start,
300+
blocked_login
299301
)
300302
VALUES
301-
($1, $2, $3, $4, $5) RETURNING *;
303+
($1, $2, $3, $4, $5, $6, $7) RETURNING *;

0 commit comments

Comments
 (0)