Skip to content

Commit 15787c0

Browse files
committed
Allow overriding UVM start timeout.
Currently the uvm.Start() method hardcodes 2 minute timeout value in the context that gets used when making hvsocket connections to the UVM (for entropy, output handling & GCS) . This timeout is good enough for general scenario but is very restrictive when debugging uvm boot issues. This change allows overriding the default timeout via environment variables. Another option that was considered, was to use the deadline/timeout passed in the context instead of hardcoding it. However, there is code in the Start method that explicitly assumes that the parent context won't have a timeout(we could probably get around that problem by creating a new context without a deadline). Another problem is that there are lot of existing callers of the Start method who may or may not include a proper timeout/deadline in the context. If we suddenly start using that value, they might start seeing unexpected timeouts (for smaller context deadlines) or they may start noticing uvm start hanging (for longer deadlines). Signed-off-by: Amit Barve <[email protected]>
1 parent cb6213a commit 15787c0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/timeout/timeout.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ var (
4747

4848
// TestDRetryLoop is the timeout for testd retry loop when onlining a SCSI disk in LCOW
4949
TestDRetryLoop = defaultTimeoutTestdRetry
50+
51+
// This timeout is used for GCS connection after uvm boot as well as the entropy
52+
// and log connection setup during uvm boot. This is different than the
53+
// SystemStart timeout defined above.
54+
GCSConnectionTimeout = 2 * time.Minute
5055
)
5156

5257
func init() {
@@ -60,6 +65,7 @@ func init() {
6065
ExternalCommandToStart = durationFromEnvironment("HCSSHIM_TIMEOUT_EXTERNALCOMMANDSTART", ExternalCommandToStart)
6166
ExternalCommandToComplete = durationFromEnvironment("HCSSHIM_TIMEOUT_EXTERNALCOMMANDCOMPLETE", ExternalCommandToComplete)
6267
TestDRetryLoop = durationFromEnvironment("HCSSHIM_TIMEOUT_TESTDRETRYLOOP", TestDRetryLoop)
68+
GCSConnectionTimeout = durationFromEnvironment("HCSSHIM_TIMEOUT_GCSCONNECTION", GCSConnectionTimeout)
6369
}
6470

6571
func durationFromEnvironment(env string, defaultValue time.Duration) time.Duration {

internal/uvm/start.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/Microsoft/hcsshim/internal/logfields"
2727
"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
2828
"github.com/Microsoft/hcsshim/internal/protocol/guestresource"
29+
"github.com/Microsoft/hcsshim/internal/timeout"
2930
"github.com/Microsoft/hcsshim/internal/uvm/scsi"
3031
)
3132

@@ -157,7 +158,9 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) {
157158
func (uvm *UtilityVM) Start(ctx context.Context) (err error) {
158159
// save parent context, without timeout to use in terminate
159160
pCtx := ctx
160-
ctx, cancel := context.WithTimeout(pCtx, 2*time.Minute)
161+
ctx, cancel := context.WithTimeout(pCtx, timeout.GCSConnectionTimeout)
162+
log.G(ctx).Debugf("using gcs connection timeout: %s\n", timeout.GCSConnectionTimeout)
163+
161164
g, gctx := errgroup.WithContext(ctx)
162165
defer func() {
163166
_ = g.Wait()

0 commit comments

Comments
 (0)