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

Commit02eb455

Browse files
committed
review
1 parent3a57c5f commit02eb455

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎scaletest/autostart/run.go‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
7272
codersdk.WithLogger(logger),
7373
codersdk.WithLogBodies())
7474

75-
logger.Info(ctx,fmt.Sprintf("user %q created",newUser.Username),slog.F("id",newUser.ID.String()))
75+
//nolint:gocritic // short log is fine
76+
logger.Info(ctx,"user created",slog.F("username",newUser.Username),slog.F("user_id",newUser.ID.String()))
7677

7778
workspaceBuildConfig:=r.cfg.Workspace
7879
workspaceBuildConfig.OrganizationID=r.cfg.User.OrganizationID
@@ -107,7 +108,7 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
107108
returnxerrors.Errorf("timeout waiting for initial workspace build to complete: %w",err)
108109
}
109110

110-
logger.Info(ctx,fmt.Sprintf("stopping workspace %q",workspace.Name))
111+
logger.Info(ctx,"stopping workspace",slog.F("workspace_name",workspace.Name))
111112

112113
_,err=newUserClient.CreateWorkspaceBuild(ctx,workspace.ID, codersdk.CreateWorkspaceBuildRequest{
113114
Transition:codersdk.WorkspaceTransitionStop,
@@ -129,20 +130,19 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
129130
returnxerrors.Errorf("timeout waiting for stop build to complete: %w",err)
130131
}
131132

132-
logger.Info(ctx,fmt.Sprintf("workspace%qstopped successfully",workspace.Name))
133+
logger.Info(ctx,"workspace stopped successfully",slog.F("workspace_name",workspace.Name))
133134

134135
logger.Info(ctx,"waiting for all runners to reach barrier")
135136
reachedBarrier=true
136137
r.cfg.SetupBarrier.Done()
137138
r.cfg.SetupBarrier.Wait()
138139
logger.Info(ctx,"all runners reached barrier, proceeding with autostart schedule")
139140

140-
testStartTime:=time.Now()
141+
testStartTime:=time.Now().UTC()
141142
autostartTime:=testStartTime.Add(r.cfg.AutostartDelay).Round(time.Minute)
142-
timeUntilAutostart:=autostartTime.Sub(testStartTime)
143143
schedule:=fmt.Sprintf("CRON_TZ=UTC %d %d * * *",autostartTime.Minute(),autostartTime.Hour())
144144

145-
logger.Info(ctx,fmt.Sprintf("setting autostart schedule for workspace %q: %s",workspace.Name,schedule))
145+
logger.Info(ctx,"setting autostart schedule for workspace",slog.F("workspace_name",workspace.Name),slog.F("schedule",schedule))
146146

147147
err=newUserClient.UpdateWorkspaceAutostart(ctx,workspace.ID, codersdk.UpdateWorkspaceAutostartRequest{
148148
Schedule:&schedule,
@@ -152,9 +152,9 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
152152
returnxerrors.Errorf("update workspace autostart: %w",err)
153153
}
154154

155-
logger.Info(ctx,fmt.Sprintf("waiting for workspace%qto autostart",workspace.Name))
155+
logger.Info(ctx,"waiting for workspace to autostart",slog.F("workspace_name",workspace.Name))
156156

157-
autostartInitiateCtx,cancel4:=context.WithTimeout(ctx,timeUntilAutostart+r.cfg.AutostartTimeout)
157+
autostartInitiateCtx,cancel4:=context.WithDeadline(ctx,autostartTime.Add(r.cfg.AutostartDelay))
158158
defercancel4()
159159

160160
logger.Info(ctx,"listening for workspace updates to detect autostart build")
@@ -189,7 +189,7 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
189189

190190
r.autostartTotalLatency=time.Since(autostartTime)
191191

192-
logger.Info(ctx,fmt.Sprintf("autostartcompleted in %v",r.autostartTotalLatency))
192+
logger.Info(ctx,"autostartworkspace build complete",slog.F("duration",r.autostartTotalLatency))
193193
r.cfg.Metrics.RecordCompletion(r.autostartTotalLatency,newUser.Username,workspace.Name)
194194

195195
returnnil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp