Skip to content

Add new WorkspaceUpdates tailnet RPC #14716

Closed
1 of 1 issue completed
Closed

Description

@spikecurtis

Today, tailnet clients connect to exactly one workspace Agent known at start of day. In order to support a desktop native VPN to Coder workspaces, we need a new tailnet RPC that delivers a stream of updates about workspaces being created, started, stopped and deleted, so that the native RPC can automatically connect to available agents.

The RPC will be part of the Tailnet API, and adds the following messages and RPC calls:

message WorkspaceUpdatesRequest {}

message WorkspaceUpdate {
	repeated Workspace upserted_workspaces = 1;
	repeated Agent upserted_agents = 2;
	repeated Workspace deleted_workspaces = 3;
	repeated Agent deleted_agents = 4;
}

message Workspace {
	bytes id = 1; // UUID
	string name = 2;

	enum Status {
		UNKNOWN = 0;
		PENDING = 1;
		STARTING = 2;
		RUNNING = 3;
		STOPPING = 4;
		STOPPED = 5;
		FAILED = 6;
		CANCELING = 7;
		CANCELED = 8;
		DELETING = 9;
		DELETED = 10;
	}
	Status status = 3;
}

message Agent {
	bytes id = 1; // UUID
	string name = 2;
	bytes workspace_id = 3; // UUID
}

service Tailnet {
	rpc WorkspaceUpdates(WorkspaceUpdatesRequest) returns (stream WorkspaceUpdate);
}

Because the RPC is not tied to a specific agent, it will not be available on the existing api/v2/workspaceagents/<agent>/coordinate HTTP endpoint, and needs to be added to a new api/v2/users/me/tailnet endpoint.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    needs decision
    on Sep 18, 2024
  2. removed
    needs decision
    on Sep 18, 2024
  3. ethanndickson commented on Sep 24, 2024

    @ethanndickson
    Member

    Since this workspace status isn't an existing type, I assume it's to be set using the provisioner job status and the build transition? I'm proposing:

    WHEN job_status = 'running' AND transition = 'start' THEN 'starting'
    WHEN job_status = 'succeeded' AND transition = 'start' THEN 'running'
    WHEN job_status = 'running' AND transition = 'stop' THEN 'stopping'
    WHEN job_status = 'succeeded' AND transition = 'stop' THEN 'stopped'
    WHEN job_status = 'succeeded' AND transition = 'delete' THEN 'deleted'
    WHEN job_status = 'running' AND transition = 'delete' THEN 'deleting'
    WHEN job_status = 'pending' THEN 'pending'
    WHEN job_status = 'failed' THEN 'failed'
    WHEN job_status = 'canceling' THEN 'canceling'
    WHEN job_status = 'canceled' THEN 'canceled'
    ELSE 'unknown'
    
  4. spikecurtis commented on Sep 24, 2024

    @spikecurtis
    CollaboratorAuthor

    There is a derived type and conversion algorithm:

    func convertWorkspaceStatus(jobStatus codersdk.ProvisionerJobStatus, transition codersdk.WorkspaceTransition) codersdk.WorkspaceStatus {

  5. added a commit that references this issue on Nov 1, 2024
    b1298a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

networking

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions