Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: use explicit api versions for agent and tailnet#15508

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/agent-tailnet-explicit-versions
Nov 15, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedNov 14, 2024
edited
Loading

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 andRefreshResumeToken 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.

@spikecurtisGraphite App
Copy link
ContributorAuthor

spikecurtis commentedNov 14, 2024
edited
Loading

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

Some comments but nothing blocking from my side.

Copy link
Member

@mafredrimafredri left a comment
edited
Loading

Choose a reason for hiding this comment

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

Does this PR cover the case where proto changes are introduced without bumping the version? If it is I didn't quite catch how that results in a build failure. (I.e. is anything stopping me from appending a new method toDRPCAgentClient23?)

Other than that, looks good. If we can automate more of this process in the future that'd be good. 👍🏻

return nil, nil, err
}
return proto.NewDRPCAgentClient(conn), tailnetproto.NewDRPCTailnetClient(conn), nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Could some or most of these changes be automated via code-gen? How easy is it for someone unfamiliar with this domain to add a new API version without forgetting something in the process?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hard to automate directly from the.proto because it requires knowing which methods were added in which version.

We could annotate the RPCs somehow, in comments, but I'm hesitant to do that.

  1. As a matter of automation, I don't think the time spent to implement will save us time overall, considering this is something we change a few times per year.
  2. What I'm doing here only covers API changes that add newmethods. You could also imagine adding new fields to existing messages in a back-compatible way.
  3. I don't want to entrench us too much into this particular paradigm by building a bunch of infrastructure around it. I'm not totally sure this is the right long-term way to manage the versions, so I want to keep it lightweight. We might change it depending on future changes to the API.

mafredri and Emyrk reacted with thumbs up emoji
@spikecurtis
Copy link
ContributorAuthor

Does this PR cover the case where proto changes are introduced without bumping the version? If it is I didn't quite catch how that results in a build failure. (I.e. is anything stopping me from appending a new method to DRPCAgentClient23?)

My assumption is that we just editedagent.proto andtailnet.proto, then ranmake gen and forgot/didn't know we needed to care about the version. So, having a separateDRPCAgentClient23 piped around theagent means that when you go to use your fancy new method, it isn't on the interface and your build will fail. Youcould just add it to the interface manually, but my hope is that the comment on that interface makes it a bit more obvious that this is a versioned interface and you shouldn't do that. Before we were just passing around thedrpc.Conn, and constructing aDRPCAgentClient, which is autogenerated from the.proto, so it was very easy not to realize the protocol is versioned.

@spikecurtisspikecurtisforce-pushed thespike/14730-set-dns branch 2 times, most recently from700a82f to0d7aa15CompareNovember 14, 2024 12:16
@spikecurtisspikecurtisforce-pushed thespike/agent-tailnet-explicit-versions branch from0dc33fb to50f124fCompareNovember 14, 2024 12:17
@spikecurtisspikecurtisforce-pushed thespike/agent-tailnet-explicit-versions branch from50f124f to7b37b40CompareNovember 14, 2024 13:03
@mafredri
Copy link
Member

mafredri commentedNov 14, 2024
edited
Loading

@spikecurtis ok, thanks for the explanation. This got me thinking though, could we instead make the protocol version a type alias so you don't need to change all the code every time you're switching? I.e.

typeDRPCAgentClientLatest=DRPCAgentClient23func (c*Client)ConnectRPCLatest(...) {return c.ConnectRPC23(...) }

Edit: Thinking about this some more, this would essentially automatically bump the protocol in the common case for all consumers when you change the alias. Maybe that's not what we want. I was hoping to avoid the yank renaming across the code-base but may be unavoidable without some rethinking of the API.

@Emyrk
Copy link
Member

@spikecurtis ok, thanks for the explanation. This got me thinking though, could we instead make the protocol version a type alias so you don't need to change all the code every time you're switching? I.e.

typeDRPCAgentClientLatest=DRPCAgentClient23func (c*Client)ConnectRPCLatest(...) {return c.ConnectRPC23(...) }

Edit: Thinking about this some more, this would essentially automatically bump the protocol in the common case for all consumers when you change the alias. Maybe that's not what we want. I was hoping to avoid the yank renaming across the code-base but may be unavoidable without some rethinking of the API.

@mafredri I think if you did this, maybe we could do something with golden files and dump a JSON representation of the interface somewhere. If it changes, via a argument field change, new method, etc. The test would fail until youupdate-golden-files again.

Just an idea to "snapshot" what the API is from a JSON POV and dump it into a test that can detect changes.

@spikecurtis I know you mentioned it might not be worth spending a lot of time on this infrastructure. I'll defer to ya'll on it.

@spikecurtis
Copy link
ContributorAuthor

maybe we could do something with golden files and dump a JSON representation of the interface somewhere. If it changes, via a argument field change, new method, etc. The test would fail until you update-golden-files again.

Just an idea to "snapshot" what the API is from a JSON POV and dump it into a test that can detect changes.

Look, if we wanted to snapshot the API definition, we could just make a copy of the.proto file. No need to involve JSON.

This isn't like a "golden file" where you're testing that the code gives some complex output that's easier to just compare wholesale rather than asserting individual facts about it.

We could stash a snapshot of the current version in testdata and directly compare, so that if you edited the proto without creating a new version, tests would fail. Personally, I think CODEOWNERS should help here, but if y'all really want another robot to complain to you about stuff, we can do it.

Emyrk reacted with thumbs up emoji

@Emyrk
Copy link
Member

we could just make a copy of the.proto file. No need to involve JSON.

Oh yea 🤦. Nah, this is all fine with me 👍

@mafredri
Copy link
Member

Let's go with this for now, we can always revisit if the process is too cumbersome or has other shortcomings 👍🏻.

@spikecurtisspikecurtis changed the base branch fromspike/14730-set-dns tographite-base/15508November 15, 2024 07:00
@spikecurtisspikecurtisforce-pushed thespike/agent-tailnet-explicit-versions branch from7b37b40 to7d0d79dCompareNovember 15, 2024 07:00
@spikecurtisspikecurtis changed the base branch fromgraphite-base/15508 tomainNovember 15, 2024 07:01
@spikecurtisspikecurtisforce-pushed thespike/agent-tailnet-explicit-versions branch from7d0d79d to46718e6CompareNovember 15, 2024 07:01
@spikecurtisspikecurtis merged commit4080295 intomainNov 15, 2024
27 checks passed
@spikecurtisGraphite App
Copy link
ContributorAuthor

Merge activity

  • Nov 15, 2:16 AM EST: A user merged this pull request withGraphite.

@spikecurtisspikecurtis deleted the spike/agent-tailnet-explicit-versions branchNovember 15, 2024 07:16
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mafredrimafredrimafredri approved these changes

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@spikecurtisspikecurtis

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@spikecurtis@mafredri@Emyrk@johnstcn@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp