Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/envd/internal/api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var pinMMDSWarnLimit = ratelimit.New(10 * time.Second)
var (
ErrAccessTokenMismatch = errors.New("access token validation failed")
ErrAccessTokenResetNotAuthorized = errors.New("access token reset not authorized")
ErrConcurrentNFSInit = errors.New("NFS mount already in progress")
)

const (
Expand Down Expand Up @@ -334,6 +335,12 @@ func writeInitError(w http.ResponseWriter, logger zerolog.Logger, err error) {
switch {
case errors.Is(err, ErrAccessTokenMismatch), errors.Is(err, ErrAccessTokenResetNotAuthorized):
w.WriteHeader(http.StatusUnauthorized)
case errors.Is(err, ErrConcurrentNFSInit):
// Transient: a previous /init is still mounting NFS (setupNFS uses
// context.WithoutCancel so it outlives a request cancelled by EnvdInitRequestTimeout).
// The orchestrator retries on 503.
logger.Warn().Err(err).Msg("NFS mount already in progress, retrying")
w.WriteHeader(http.StatusServiceUnavailable)
case errors.Is(err, host.ErrCAInstallInProgress):
// Not a failure, a concurrent install still holds the CA lock.
logger.Warn().Err(err).Msg("CA initialization still in progress, retrying")
Expand Down Expand Up @@ -371,7 +378,7 @@ func (a *API) setupNFS(ctx context.Context, logger zerolog.Logger, lifecycleID *
if !a.isMountingNFS.CompareAndSwap(false, true) {
logger.Debug().Msg("NFS volumes already mounting")

return e
return ErrConcurrentNFSInit
Comment thread
AdaAibaby marked this conversation as resolved.
Resolved
Comment thread
AdaAibaby marked this conversation as resolved.
Resolved
}
defer a.isMountingNFS.Store(false)

Expand Down
2 changes: 1 addition & 1 deletion packages/envd/pkg/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package pkg

const Version = "0.6.13" // x-release-please-version
const Version = "0.6.14" // x-release-please-version
9 changes: 8 additions & 1 deletion packages/orchestrator/pkg/sandbox/envd.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ func (s *Sandbox) doRequestWithInfiniteRetries(
cancel()

if err == nil {
return response, requestCount, nil
// Treat 503 as a transient failure and retry: envd returns 503 when a
// concurrent /init is still in progress (e.g. an NFS mount outlived the
// previous per-request timeout). Discard the body and loop.
if response.StatusCode == http.StatusServiceUnavailable {
response.Body.Close()
} else {
return response, requestCount, nil
}
}

select {
Expand Down