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

Commite4dc2d9

Browse files
authored
fix: add constraint and runtime check for provisioner logs size limit (#18893)
This PR sets a constraint of 1MB on the provisioner job logs written tothe database. This is consistent with the constraint we place onworkspace agent logs:https://github.com/coder/coder/blob/4ac6be6d835dc36c242e35a26b584b784040bf28/coderd/database/dump.sql#L2030It also adds a message printed to the front end about the provisionerlog overflow, and updates the message printed to the front end whenworkspace startup logs exceed the max, as it was causing some customersto think their startup script had failed to run.
1 parenteeb0bbe commite4dc2d9

File tree

38 files changed

+506
-35
lines changed

38 files changed

+506
-35
lines changed

‎cli/testdata/coder_list_--output_json.golden‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"template_name": "",
5656
"template_display_name": "",
5757
"template_icon": ""
58-
}
58+
},
59+
"logs_overflowed": false
5960
},
6061
"reason": "initiator",
6162
"resources": [],

‎cli/testdata/coder_provisioner_jobs_list_--help.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OPTIONS:
1111
-O, --org string, $CODER_ORGANIZATION
1212
Select which organization (uuid or name) to use.
1313

14-
-c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|worker name|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
14+
-c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|worker name|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|logs overflowed|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
1515
Columns to display in table output.
1616

1717
-l, --limit int, $CODER_PROVISIONER_JOB_LIST_LIMIT (default: 50)

‎cli/testdata/coder_provisioner_jobs_list_--output_json.golden‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"template_display_name": "",
2727
"template_icon": ""
2828
},
29+
"logs_overflowed": false,
2930
"organization_name": "Coder"
3031
},
3132
{
@@ -57,6 +58,7 @@
5758
"workspace_id": "===========[workspace ID]===========",
5859
"workspace_name": "test-workspace"
5960
},
61+
"logs_overflowed": false,
6062
"organization_name": "Coder"
6163
}
6264
]

‎coderd/apidoc/docs.go‎

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

‎coderd/apidoc/swagger.json‎

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

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,6 +4489,22 @@ func (q *querier) UpdateProvisionerJobByID(ctx context.Context, arg database.Upd
44894489
returnq.db.UpdateProvisionerJobByID(ctx,arg)
44904490
}
44914491

4492+
func (q*querier)UpdateProvisionerJobLogsLength(ctx context.Context,arg database.UpdateProvisionerJobLogsLengthParams)error {
4493+
// Not sure what the rbac should be here, going with this for now
4494+
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceProvisionerJobs);err!=nil {
4495+
returnerr
4496+
}
4497+
returnq.db.UpdateProvisionerJobLogsLength(ctx,arg)
4498+
}
4499+
4500+
func (q*querier)UpdateProvisionerJobLogsOverflowed(ctx context.Context,arg database.UpdateProvisionerJobLogsOverflowedParams)error {
4501+
// Not sure what the rbac should be here, going with this for now
4502+
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceProvisionerJobs);err!=nil {
4503+
returnerr
4504+
}
4505+
returnq.db.UpdateProvisionerJobLogsOverflowed(ctx,arg)
4506+
}
4507+
44924508
func (q*querier)UpdateProvisionerJobWithCancelByID(ctx context.Context,arg database.UpdateProvisionerJobWithCancelByIDParams)error {
44934509
// TODO: Remove this once we have a proper rbac check for provisioner jobs.
44944510
// Details in https://github.com/coder/coder/issues/16160

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,6 +4341,20 @@ func (s *MethodTestSuite) TestSystemFunctions() {
43414341
UpdatedAt:time.Now(),
43424342
}).Asserts(rbac.ResourceProvisionerJobs,policy.ActionUpdate)
43434343
}))
4344+
s.Run("UpdateProvisionerJobLogsLength",s.Subtest(func(db database.Store,check*expects) {
4345+
j:=dbgen.ProvisionerJob(s.T(),db,nil, database.ProvisionerJob{})
4346+
check.Args(database.UpdateProvisionerJobLogsLengthParams{
4347+
ID:j.ID,
4348+
LogsLength:100,
4349+
}).Asserts(rbac.ResourceProvisionerJobs,policy.ActionUpdate)
4350+
}))
4351+
s.Run("UpdateProvisionerJobLogsOverflowed",s.Subtest(func(db database.Store,check*expects) {
4352+
j:=dbgen.ProvisionerJob(s.T(),db,nil, database.ProvisionerJob{})
4353+
check.Args(database.UpdateProvisionerJobLogsOverflowedParams{
4354+
ID:j.ID,
4355+
LogsOverflowed:true,
4356+
}).Asserts(rbac.ResourceProvisionerJobs,policy.ActionUpdate)
4357+
}))
43444358
s.Run("InsertProvisionerJob",s.Subtest(func(db database.Store,check*expects) {
43454359
dbtestutil.DisableForeignKeysAndTriggers(s.T(),db)
43464360
check.Args(database.InsertProvisionerJobParams{

‎coderd/database/dbfake/dbfake.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ func (b WorkspaceBuildBuilder) Do() WorkspaceResponse {
179179
Input:payload,
180180
Tags:map[string]string{},
181181
TraceMetadata: pqtype.NullRawMessage{},
182+
LogsOverflowed:false,
182183
})
183184
require.NoError(b.t,err,"insert job")
184185

‎coderd/database/dbgen/dbgen.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ func ProvisionerJob(t testing.TB, db database.Store, ps pubsub.Pubsub, orig data
775775
Input:takeFirstSlice(orig.Input, []byte("{}")),
776776
Tags:tags,
777777
TraceMetadata: pqtype.NullRawMessage{},
778+
LogsOverflowed:false,
778779
})
779780
require.NoError(t,err,"insert job")
780781
ifps!=nil {

‎coderd/database/dbmetrics/querymetrics.go‎

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp