Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Add workspace agent lifecycle state reporting #5785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 24, 2023

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jan 19, 2023

This PR adds workspace agent lifecycle state reporting as an additional property on the agent.

Ref: #5749

  • Relies on terraform-provider-coder v0.6.7 (feat: Add startup_script_timeout and delay_login_until_ready terraform-provider-coder#84)
  • Introduce new agent property describing workspace agent state, WorkspaceAgentLifecycle: created, starting, start_timeout, start_error, ready
  • Add new database fields to workspace_agents (startup_script_timeout_seconds, delay_login_until_ready, lifecycle_state)
  • Initial state is created, only changes once the agent reports a new state
    • An agent that never connects will only ever return created status, since we simply don't know
    • (Implementation detail) State changes can be missed if the agent loses connection and any state is allowed to move to any other state (e.g. ready -> agent crashes and restarts -> starting -> ...)
  • Plumbing for provider values -> database

Examples uses:

  • If state is starting and delay_login_until_ready = true, keep users waiting e.g. during ssh coder.workspace (loading indicator, stream startup log, etc.)
  • If state is start_timeout (or error), show users a warning
  • If startup script exits with non-zero status, the start_error state lets us direct users towards inspecting the startup log

@mafredri mafredri force-pushed the mafredri/feat-add-workspace-agent-ready-status branch from ec6def8 to 534f954 Compare January 23, 2023 13:08
@mafredri mafredri changed the title feat: Add workspace agent readyness state reporting feat: Add workspace agent lifecycle state reporting Jan 23, 2023
@mafredri mafredri force-pushed the mafredri/feat-add-workspace-agent-ready-status branch from 9d03a6a to e2dda7d Compare January 23, 2023 15:47
@mafredri mafredri force-pushed the mafredri/feat-add-workspace-agent-ready-status branch from e2dda7d to 60f414f Compare January 23, 2023 15:56
@mafredri mafredri marked this pull request as ready for review January 23, 2023 16:42
@mafredri mafredri requested a review from a team as a code owner January 23, 2023 16:42
@mafredri mafredri requested review from Kira-Pilot, kylecarbs, BrunoQuaresma and a team and removed request for a team and Kira-Pilot January 23, 2023 16:42
if metadata.GitAuthConfigs > 0 {
err := gitauth.OverrideVSCodeConfigs(a.filesystem)
if err != nil {
a.logger.Warn(ctx, "failed to override vscode git auth configs", slog.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

nit: should the agent quit here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We probably shouldn't, this could fail for a multitude of reasons, like a user setting chmod 0000 on a folder. The worst that can happen is a degraded user experience (git auth in vscode not working). Ultimately we might want to:

  • Continue executing startup script after this
  • Set lifecycle to start_error because this failed
  • Result (error message) must be visible in build/startup logs

Copy link
Member

Choose a reason for hiding this comment

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

The worst that can happen is a degraded user experience (git auth in vscode not working).

Yes, that's the situation I was considering. What can user do in this case? Restart the workspace until it works?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the change was done before, failure here doesn't really matter either (btw). Restarting will most likely not help, unless it's a problem mounting FS or similar. They'll most likely need to resolve the issue in the workspace, then restart, or create a new one.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, I've only added a note. I'll revisit this behavior when I add startup log streaming 👍🏻.

@mtojek mtojek self-requested a review January 24, 2023 11:41
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Ship it!

@mafredri mafredri merged commit 138887d into main Jan 24, 2023
@mafredri mafredri deleted the mafredri/feat-add-workspace-agent-ready-status branch January 24, 2023 12:24
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants