Skip to content

feat(agent): add ParentId to agent manifest #17888

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 5 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: broken tests
  • Loading branch information
DanielleMaywood committed May 19, 2025
commit da47a73eef4ca1804c85b3e6617b5c23ef06cf00
6 changes: 3 additions & 3 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ type Options struct {
}

type Client interface {
ConnectRPC24(ctx context.Context) (
proto.DRPCAgentClient24, tailnetproto.DRPCTailnetClient24, error,
ConnectRPC25(ctx context.Context) (
proto.DRPCAgentClient25, tailnetproto.DRPCTailnetClient25, error,
)
RewriteDERPMap(derpMap *tailcfg.DERPMap)
}
Expand Down Expand Up @@ -908,7 +908,7 @@ func (a *agent) run() (retErr error) {
a.sessionToken.Store(&sessionToken)

// ConnectRPC returns the dRPC connection we use for the Agent and Tailnet v2+ APIs
aAPI, tAPI, err := a.client.ConnectRPC24(a.hardCtx)
aAPI, tAPI, err := a.client.ConnectRPC25(a.hardCtx)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/agenttest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func (c *Client) Close() {
c.derpMapOnce.Do(func() { close(c.derpMapUpdates) })
}

func (c *Client) ConnectRPC24(ctx context.Context) (
agentproto.DRPCAgentClient24, proto.DRPCTailnetClient24, error,
func (c *Client) ConnectRPC25(ctx context.Context) (
agentproto.DRPCAgentClient25, proto.DRPCTailnetClient25, error,
) {
conn, lis := drpcsdk.MemTransportPipe()
c.LastWorkspaceAgent = func() {
Expand Down
5 changes: 5 additions & 0 deletions agent/proto/agent_drpc_old.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ type DRPCAgentClient24 interface {
PushResourcesMonitoringUsage(ctx context.Context, in *PushResourcesMonitoringUsageRequest) (*PushResourcesMonitoringUsageResponse, error)
ReportConnection(ctx context.Context, in *ReportConnectionRequest) (*emptypb.Empty, error)
}

// DRPCAgentClient25 is the Agent API at v2.5.
type DRPCAgentClient25 interface {
DRPCAgentClient24
}
2 changes: 1 addition & 1 deletion coderd/workspaceagents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ func requireGetManifest(ctx context.Context, t testing.TB, aAPI agentproto.DRPCA
}

func postStartup(ctx context.Context, t testing.TB, client agent.Client, startup *agentproto.Startup) error {
aAPI, _, err := client.ConnectRPC24(ctx)
aAPI, _, err := client.ConnectRPC25(ctx)
require.NoError(t, err)
defer func() {
cErr := aAPI.DRPCConn().Close()
Expand Down
14 changes: 13 additions & 1 deletion codersdk/agentsdk/agentsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (c *Client) ConnectRPC23(ctx context.Context) (
}

// ConnectRPC24 returns a dRPC client to the Agent API v2.4. It is useful when you want to be
// maximally compatible with Coderd Release Versions from 2.xx+ // TODO @vincent: define version
// maximally compatible with Coderd Release Versions from 2.20+
func (c *Client) ConnectRPC24(ctx context.Context) (
proto.DRPCAgentClient24, tailnetproto.DRPCTailnetClient24, error,
) {
Expand All @@ -257,6 +257,18 @@ func (c *Client) ConnectRPC24(ctx context.Context) (
return proto.NewDRPCAgentClient(conn), tailnetproto.NewDRPCTailnetClient(conn), nil
}

// ConnectRPC25 returns a dRPC client to the Agent API v2.5. It is useful when you want to be
// maximally compatible with Coderd Release Versions from 2.xx+ // TODO(DanielleMaywood): Update version
func (c *Client) ConnectRPC25(ctx context.Context) (
proto.DRPCAgentClient25, tailnetproto.DRPCTailnetClient25, error,
) {
conn, err := c.connectRPCVersion(ctx, apiversion.New(2, 5))
if err != nil {
return nil, nil, err
}
return proto.NewDRPCAgentClient(conn), tailnetproto.NewDRPCTailnetClient(conn), nil
}

// ConnectRPC connects to the workspace agent API and tailnet API
func (c *Client) ConnectRPC(ctx context.Context) (drpc.Conn, error) {
return c.connectRPCVersion(ctx, proto.CurrentVersion)
Expand Down
5 changes: 5 additions & 0 deletions tailnet/proto/tailnet_drpc_old.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ type DRPCTailnetClient23 interface {
type DRPCTailnetClient24 interface {
DRPCTailnetClient23
}

// DRPCTailnetClient25 is the Tailnet API at v2.5.
type DRPCTailnetClient25 interface {
DRPCTailnetClient24
}
1 change: 1 addition & 0 deletions tailnet/proto/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
// ReportConnection RPC on the Agent API.
//
// API v2.5:
// - Shipped in Coder v2.xx.x // TODO(DanielleMaywood): Update version
Copy link
Member

Choose a reason for hiding this comment

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

I think we can make an educated guess at 2.23 :) but this is fine for now.

// - Added `ParentId` to the agent manifest.
const (
CurrentMajor = 2
Expand Down
Loading