Skip to content

Conversation

@jakubno
Copy link
Member

@jakubno jakubno commented Sep 29, 2025

Increasing the timeout didn't affect start times, but the number of initialization requests went down.
image


Note

Envd init now uses a feature-flagged per-request timeout, records init attempt counts and duration with envd version attributes, and adds a logger field for envd version.

  • Sandbox/Envd:
    • Make envd init request timeout configurable via feature flag (envd-init-request-timeout-milliseconds); store in internalConfig and use per-request.
    • Refactor initEnvd to use sandbox config directly; doRequestWithInfiniteRetries now takes timeout, returns attempt count, and logs retries with sandbox_id and envd.version.
    • Record successful and failed init attempts via telemetry.EnvdInitCalls with {success: true|false}, envd.version, and timeout_ms attributes.
    • Measure WaitForEnvd duration via telemetry.WaitForEnvdDurationHistogramName with envd.version and timeout_ms.
  • Telemetry:
    • Add counter orchestrator.sandbox.envd.init.calls and histogram orchestrator.sandbox.envd.init.duration with units/descriptions.
    • Add telemetry.WithEnvdVersion attribute helper and wire through spans.
  • Feature Flags:
    • Introduce EnvdInitTimeoutSeconds (envd-init-request-timeout-milliseconds) int flag with default 50.
  • Logging:
    • Add logger.WithEnvdVersion and use it in retry logs and clock-drift warnings.
  • Minor:
    • Formatting-only changes in template build phase builders.

Written by Cursor Bugbot for commit ce9c48c. This will update automatically on new commits. Configure here.

@jakubno jakubno added the improvement Improvement for current functionality label Sep 29, 2025
@linear
Copy link

linear bot commented Sep 29, 2025

@jakubno jakubno force-pushed the make-envd-init-request-time-out-customizable-eng-3083 branch from 0438b7f to bee7be0 Compare September 30, 2025 09:50
@jakubno jakubno changed the title [WIP] Dynamically customizable timeout for envd init Dynamically customizable timeout for envd init Sep 30, 2025
@jakubno jakubno marked this pull request as ready for review September 30, 2025 09:52
cursor[bot]

This comment was marked as outdated.

@jakubno
Copy link
Member Author

jakubno commented Sep 30, 2025

Bug: Envd Initialization Timeout Defaults Incorrectly

If the EnvdInitTimeoutSeconds feature flag fails to load, the envdInitRequestTimeout becomes 0 milliseconds. This causes immediate timeouts for envd initialization, despite the log message indicating a default value is used.

packages/orchestrator/internal/server/sandboxes.go#L107-L112

// Get timeout from feature flag
envdInitRequestTimeoutMs, err := s.featureFlags.IntFlag(ctx, featureflags.EnvdInitTimeoutSeconds)
if err != nil {
zap.L().Warn("failed to get envd timeout from feature flag, using default", zap.Error(err))
}
envdInitRequestTimeout := time.Duration(envdInitRequestTimeoutMs) * time.Millisecond

Fix in Cursor Fix in Web

it's not it will use fallback - 50ms

Copy link
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we won't be able to track how many attempts are required per one sandbox start, correct?

@jakubno
Copy link
Member Author

jakubno commented Sep 30, 2025

we won't be able to track how many attempts are required per one sandbox start, correct?

we will - it's total/success

# Conflicts:
#	packages/orchestrator/internal/server/sandboxes.go
@jakubno jakubno force-pushed the make-envd-init-request-time-out-customizable-eng-3083 branch from c347dc8 to 1302578 Compare October 1, 2025 13:30
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@jakubno jakubno requested a review from dobrac October 1, 2025 15:23
@jakubno jakubno force-pushed the make-envd-init-request-time-out-customizable-eng-3083 branch from c195b94 to 820b387 Compare October 1, 2025 16:13
@jakubno jakubno requested a review from dobrac October 1, 2025 16:18
@jakubno jakubno merged commit be748c2 into main Oct 1, 2025
26 checks passed
@jakubno jakubno deleted the make-envd-init-request-time-out-customizable-eng-3083 branch October 1, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants