Skip to content

Commit

Permalink
Set lengthier timeout for CVD creation under Docker
Browse files Browse the repository at this point in the history
Running CVD under docker can take much longer time to complete
creation. To prevent CVD instance being killed by host orchestrator
while booting instance, set lengthier timeout for CVD creation.
  • Loading branch information
k311093 committed Mar 15, 2024
1 parent 690c6a0 commit a7cfa1b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/host_orchestrator/orchestrator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func newCreateCVDHandler(c Config, om OperationManager, uadr UserArtifactsManage
}
}

func isRunningInDocker() bool {
_, err := os.Stat("/.dockerenv")
return err == nil
}

func (h *createCVDHandler) Handle(r *http.Request) (interface{}, error) {
req := &apiv1.CreateCVDRequest{}
err := json.NewDecoder(r.Body).Decode(req)
Expand All @@ -177,7 +182,11 @@ func (h *createCVDHandler) Handle(r *http.Request) (interface{}, error) {
artifactsFetcher := newBuildAPIArtifactsFetcher(buildAPI)
cvdBundleFetcher := newFetchCVDCommandArtifactsFetcher(exec.CommandContext, creds)
cvdStartTimeout := 3 * time.Minute
if req.EnvConfig != nil {
if isRunningInDocker() {
// Use a lengthier timeout when running within a docker because it could race resource with
// other containers and take much longer time than normal status.
cvdStartTimeout = 30 * time.Minute
} else if req.EnvConfig != nil {
// Use a lengthier timeout when using canonical configs as this operation downloads artifacts as well.
cvdStartTimeout = 7 * time.Minute
}
Expand Down

0 comments on commit a7cfa1b

Please sign in to comment.