@@ -1115,8 +1115,13 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
1115
1115
}
1116
1116
}
1117
1117
1118
+ // Any defined Dev Containers may be autostarted after the start
1119
+ // scripts have completed.
1118
1120
var postStartScripts []codersdk.WorkspaceAgentScript
1119
1121
for _ , dc := range manifest .Devcontainers {
1122
+ // TODO(mafredri): Verify `@devcontainers/cli` presence.
1123
+ // TODO(mafredri): Verify workspace folder exists.
1124
+ // TODO(mafredri): If set, verify config path exists.
1120
1125
postStartScripts = append (postStartScripts , agentcontainers .DevcontainerStartupScript (dc ))
1121
1126
}
1122
1127
@@ -1126,11 +1131,18 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
1126
1131
}
1127
1132
err = a .trackGoroutine (func () {
1128
1133
start := time .Now ()
1129
- // here we use the graceful context because the script runner is not directly tied
1130
- // to the agent API.
1134
+ // Here we use the graceful context because the script runner is
1135
+ // not directly tied to the agent API.
1136
+ //
1137
+ // First we run the start scripts to ensure the workspace has
1138
+ // been initialized and then the post start scripts which may
1139
+ // depend on the workspace start scripts.
1140
+ //
1141
+ // Measure the time immediately after the start scripts have
1142
+ // finished (both start and post start). For instance, an
1143
+ // autostarted devcontainer will be included in this time.
1131
1144
err := a .scriptRunner .Execute (a .gracefulCtx , agentscripts .ExecuteStartScripts )
1132
1145
err = errors .Join (err , a .scriptRunner .Execute (a .gracefulCtx , agentscripts .ExecutePostStartScripts ))
1133
- // Measure the time immediately after the script has finished
1134
1146
dur := time .Since (start ).Seconds ()
1135
1147
if err != nil {
1136
1148
a .logger .Warn (ctx , "startup script(s) failed" , slog .Error (err ))
0 commit comments