diff --git a/cli/list.go b/cli/list.go
index a38497b315..12d0a48149 100644
--- a/cli/list.go
+++ b/cli/list.go
@@ -30,6 +30,7 @@ type workspaceListRow struct {
Outdated bool `json:"-" table:"outdated"`
StartsAt string `json:"-" table:"starts at"`
StopsAfter string `json:"-" table:"stops after"`
+ DailyCost string `json:"-" table:"daily cost"`
}
func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]codersdk.User, workspace codersdk.Workspace) workspaceListRow {
@@ -68,6 +69,7 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
Outdated: workspace.Outdated,
StartsAt: autostartDisplay,
StopsAfter: autostopDisplay,
+ DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
}
}
@@ -78,7 +80,19 @@ func (r *RootCmd) list() *clibase.Cmd {
searchQuery string
displayWorkspaces []workspaceListRow
formatter = cliui.NewOutputFormatter(
- cliui.TableFormat([]workspaceListRow{}, nil),
+ cliui.TableFormat(
+ []workspaceListRow{},
+ []string{
+ "workspace",
+ "template",
+ "status",
+ "healthy",
+ "last built",
+ "outdated",
+ "starts at",
+ "stops after",
+ },
+ ),
cliui.JSONFormat(),
)
)
diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden
index a9bb8218ba..e4e6f5dd35 100644
--- a/cli/testdata/coder_list_--help.golden
+++ b/cli/testdata/coder_list_--help.golden
@@ -11,7 +11,7 @@ Aliases: ls
-c, --column string-array (default: workspace,template,status,healthy,last built,outdated,starts at,stops after)
Columns to display in table output. Available columns: workspace,
template, status, healthy, last built, outdated, starts at, stops
- after.
+ after, daily cost.
-o, --output string (default: table)
Output format. Available formats: table, json.
diff --git a/docs/cli/list.md b/docs/cli/list.md
index 7a1aa0defb..b840a32acb 100644
--- a/docs/cli/list.md
+++ b/docs/cli/list.md
@@ -31,7 +31,7 @@ Specifies whether all workspaces will be listed or not.
| Type | string-array |
| Default | workspace,template,status,healthy,last built,outdated,starts at,stops after |
-Columns to display in table output. Available columns: workspace, template, status, healthy, last built, outdated, starts at, stops after.
+Columns to display in table output. Available columns: workspace, template, status, healthy, last built, outdated, starts at, stops after, daily cost.
### -o, --output
diff --git a/provisionerd/provisionerd.go b/provisionerd/provisionerd.go
index b66b834829..f127ab7b58 100644
--- a/provisionerd/provisionerd.go
+++ b/provisionerd/provisionerd.go
@@ -404,7 +404,7 @@ func (p *Server) acquireJob(ctx context.Context) {
runner.Options{
Updater: p,
QuotaCommitter: p,
- Logger: p.opts.Logger,
+ Logger: p.opts.Logger.Named("runner"),
Filesystem: p.opts.Filesystem,
WorkDirectory: p.opts.WorkDirectory,
Provisioner: provisioner,
diff --git a/provisionerd/runner/runner.go b/provisionerd/runner/runner.go
index d6c3e6e47b..a42ce5c2da 100644
--- a/provisionerd/runner/runner.go
+++ b/provisionerd/runner/runner.go
@@ -964,6 +964,9 @@ func (r *Runner) buildWorkspace(ctx context.Context, stage string, req *sdkproto
}
func (r *Runner) commitQuota(ctx context.Context, resources []*sdkproto.Resource) *proto.FailedJob {
+ r.logger.Debug(ctx, "committing quota",
+ slog.F("resources", resources),
+ )
cost := sumDailyCost(resources)
if cost == 0 {
return nil