Skip to content

Commit ba8f7ae

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/warn-unplished-changes
2 parents 9a9f83e + 8585863 commit ba8f7ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1030
-220
lines changed

cli/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
149149

150150
// DumpHandler does signal handling, so we call it after the
151151
// reaper.
152-
go DumpHandler(ctx)
152+
go DumpHandler(ctx, "agent")
153153

154154
logWriter := &lumberjackWriteCloseFixer{w: &lumberjack.Logger{
155155
Filename: filepath.Join(logDir, "coder-agent.log"),

cli/root.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ func (r *RootCmd) Verbosef(inv *clibase.Invocation, fmtStr string, args ...inter
937937
// A SIGQUIT handler will not be registered if GOTRACEBACK=crash.
938938
//
939939
// On Windows this immediately returns.
940-
func DumpHandler(ctx context.Context) {
940+
func DumpHandler(ctx context.Context, name string) {
941941
if runtime.GOOS == "windows" {
942942
// free up the goroutine since it'll be permanently blocked anyways
943943
return
@@ -992,7 +992,11 @@ func DumpHandler(ctx context.Context) {
992992
if err != nil {
993993
dir = os.TempDir()
994994
}
995-
fpath := filepath.Join(dir, fmt.Sprintf("coder-agent-%s.dump", time.Now().Format("2006-01-02T15:04:05.000Z")))
995+
// Make the time filesystem-safe, for example ":" is not
996+
// permitted on many filesystems. Note that Z here only appends
997+
// Z to the string, it does not actually change the time zone.
998+
filesystemSafeTime := time.Now().UTC().Format("2006-01-02T15-04-05.000Z")
999+
fpath := filepath.Join(dir, fmt.Sprintf("coder-%s-%s.dump", name, filesystemSafeTime))
9961000
_, _ = fmt.Fprintf(os.Stderr, "writing dump to %q\n", fpath)
9971001

9981002
f, err := os.Create(fpath)

cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
289289
cliui.Warnf(inv.Stderr, "YAML support is experimental and offers no compatibility guarantees.")
290290
}
291291

292-
go DumpHandler(ctx)
292+
go DumpHandler(ctx, "coderd")
293293

294294
// Validate bind addresses.
295295
if vals.Address.String() != "" {

coderd/database/dbauthz/dbauthz.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ var (
170170
rbac.ResourceWorkspaceBuild.Type: {rbac.ActionRead, rbac.ActionUpdate, rbac.ActionDelete},
171171
rbac.ResourceUserData.Type: {rbac.ActionRead, rbac.ActionUpdate},
172172
rbac.ResourceAPIKey.Type: {rbac.WildcardSymbol},
173+
// When org scoped provisioner credentials are implemented,
174+
// this can be reduced to read a specific org.
175+
rbac.ResourceOrganization.Type: {rbac.ActionRead},
173176
}),
174177
Org: map[string][]rbac.Permission{},
175178
User: []rbac.Permission{},

coderd/database/dbmem/dbmem.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func mapAgentStatus(dbAgent database.WorkspaceAgent, agentInactiveDisconnectTime
345345
return status
346346
}
347347

348-
func (q *FakeQuerier) convertToWorkspaceRowsNoLock(ctx context.Context, workspaces []database.Workspace, count int64) []database.GetWorkspacesRow {
348+
func (q *FakeQuerier) convertToWorkspaceRowsNoLock(ctx context.Context, workspaces []database.Workspace, count int64, withSummary bool) []database.GetWorkspacesRow { //nolint:revive // withSummary flag ensures the extra technical row
349349
rows := make([]database.GetWorkspacesRow, 0, len(workspaces))
350350
for _, w := range workspaces {
351351
wr := database.GetWorkspacesRow{
@@ -389,6 +389,12 @@ func (q *FakeQuerier) convertToWorkspaceRowsNoLock(ctx context.Context, workspac
389389

390390
rows = append(rows, wr)
391391
}
392+
if withSummary {
393+
rows = append(rows, database.GetWorkspacesRow{
394+
Name: "**TECHNICAL_ROW**",
395+
Count: count,
396+
})
397+
}
392398
return rows
393399
}
394400

@@ -8278,12 +8284,12 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
82788284
}
82798285
if arg.Limit > 0 {
82808286
if int(arg.Limit) > len(workspaces) {
8281-
return q.convertToWorkspaceRowsNoLock(ctx, workspaces, int64(beforePageCount)), nil
8287+
return q.convertToWorkspaceRowsNoLock(ctx, workspaces, int64(beforePageCount), arg.WithSummary), nil
82828288
}
82838289
workspaces = workspaces[:arg.Limit]
82848290
}
82858291

8286-
return q.convertToWorkspaceRowsNoLock(ctx, workspaces, int64(beforePageCount)), nil
8292+
return q.convertToWorkspaceRowsNoLock(ctx, workspaces, int64(beforePageCount), arg.WithSummary), nil
82878293
}
82888294

82898295
func (q *FakeQuerier) GetAuthorizedUsers(ctx context.Context, arg database.GetUsersParams, prepared rbac.PreparedAuthorized) ([]database.GetUsersRow, error) {

coderd/database/modelqueries.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
231231
arg.RequesterID,
232232
arg.Offset,
233233
arg.Limit,
234+
arg.WithSummary,
234235
)
235236
if err != nil {
236237
return nil, err
@@ -258,6 +259,11 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
258259
&i.TemplateName,
259260
&i.TemplateVersionID,
260261
&i.TemplateVersionName,
262+
&i.Username,
263+
&i.LatestBuildCompletedAt,
264+
&i.LatestBuildCanceledAt,
265+
&i.LatestBuildError,
266+
&i.LatestBuildTransition,
261267
&i.Count,
262268
); err != nil {
263269
return nil, err

coderd/database/queries.sql.go

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

0 commit comments

Comments
 (0)