Files
coder/tailnet/proto/version.go
Spike Curtis 40802958e9 fix: use explicit api versions for agent and tailnet (#15508)
Bumps the Tailnet and Agent API version 2.3, and creates some extra controls and machinery around these versions.

What happened is that we accidentally shipped two new API features without bumping the version.  `ScriptCompleted` on the Agent API in Coder v2.16 and `RefreshResumeToken` on the Tailnet API in Coder v2.15.

Since we can't easily retroactively bump the versions, we'll roll these changes into API version 2.3 along with the new WorkspaceUpdates RPC, which hasn't been released yet.  That means there is some ambiguity in Coder v2.15-v2.17 about exactly what methods are supported on the Tailnet and Agent APIs.  This isn't great, but hasn't caused us major issues because 

1. RefreshResumeToken is considered optional, and clients just log and move on if the RPC isn't supported. 
2. Agents basically never get started talking to a Coderd that is older than they are, since the agent binary is normally downloaded from Coderd at workspace start.

Still it's good to get things squared away in terms of versions for SDK users and possible edge cases around client and server versions.

To mitigate against this thing happening again, this PR also:

1. adds a CODEOWNERS for the API proto packages, so I'll review changes
2. defines interface types for different API versions, and has the agent explicitly use a specific version.  That way, if you add a new method, and try to use it in the agent without thinking explicitly about versions, it won't compile.

With the protocol controllers stuff, we've sort of already abstracted the Tailnet API such that the interface type strategy won't work, but I'll work on getting the Controller to be version aware, such that it can check the API version it's getting against the controllers it has -- in a later PR.
2024-11-15 11:16:28 +04:00

47 lines
1.6 KiB
Go

package proto
import (
"github.com/coder/coder/v2/apiversion"
)
// Version history:
//
// API v1:
// - retroactively applied name for the HTTP Rest APIs for the Agent and the
// JSON over websocket coordination and DERP Map APIs for Tailnet
//
// API v2.0:
// - Shipped in Coder v2.8.0
// - first dRPC over yamux over websocket APIs for tailnet and agent
//
// API v2.1:
// - Shipped in Coder v2.12.0
// - Added support for multiple banners via the GetAnnouncementBanners RPC on
// the Agent API.
// - No changes to the Tailnet API.
//
// API v2.2:
// - Shipped in Coder v2.13.0
// - Added support for network telemetry via the PostTelemetry RPC on the
// Tailnet API.
// - No changes to the Agent API.
//
// API v2.3:
// - Shipped in Coder v2.18.0
// - Added support for client Resume Tokens on the Tailnet API via the
// RefreshResumeToken RPC. (This actually shipped in Coder v2.15.0, but we
// forgot to increment the API version. If you dial for API v2.2, you MAY
// be connected to a server that supports RefreshResumeToken, but be
// prepared to process "unsupported" errors.)
// - Added support for WorkspaceUpdates RPC on the Tailnet API.
// - Added support for ScriptCompleted RPC on the Agent API. (This actually
// shipped in Coder v2.16.0, but we forgot to increment the API version. If
// you dial for API v2.2, you MAY be connected to a server that supports
// ScriptCompleted, but be prepared to process "unsupported" errors.)
const (
CurrentMajor = 2
CurrentMinor = 3
)
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor)