Skip to content

feat: switch agent to use v2 API for sending logs #12068

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 1 commit into from
Feb 23, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Feb 8, 2024

Changes the agent to use the new v2 API for sending logs, via the logSender component.

We keep the PatchLogs function around, but deprecate it so that we can test the v1 endpoint.

Copy link
Contributor Author

spikecurtis commented Feb 8, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @spikecurtis and the rest of your teammates on Graphite Graphite

@spikecurtis spikecurtis changed the title feat: use agent v2 API to send agent logs feat: change agent to use v2 API to send agent logs Feb 8, 2024
@spikecurtis spikecurtis marked this pull request as ready for review February 8, 2024 11:50
@spikecurtis spikecurtis force-pushed the spike/10534-log-queue-limit branch from 4a32bba to 14d0583 Compare February 9, 2024 11:54
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 1c29364 to 6f02c02 Compare February 9, 2024 11:55
@spikecurtis spikecurtis force-pushed the spike/10534-log-queue-limit branch from 14d0583 to 2014110 Compare February 9, 2024 12:05
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 6f02c02 to 7d7df61 Compare February 9, 2024 12:05
@spikecurtis spikecurtis force-pushed the spike/10534-log-queue-limit branch from 2014110 to 446cb12 Compare February 9, 2024 12:54
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 7d7df61 to 3106dac Compare February 9, 2024 12:54
Base automatically changed from spike/10534-log-queue-limit to spike/10534-log-sender February 9, 2024 12:57
@spikecurtis spikecurtis force-pushed the spike/10534-log-sender branch 2 times, most recently from 5f74643 to f25da2c Compare February 15, 2024 12:46
Base automatically changed from spike/10534-log-sender to main February 15, 2024 12:57
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 3106dac to 72a8e58 Compare February 20, 2024 11:16
@spikecurtis spikecurtis changed the base branch from main to spike/10534-agent-api-routines February 20, 2024 11:16
@spikecurtis spikecurtis changed the title feat: change agent to use v2 API to send agent logs feat: switch agent to use v2 API for sending logs Feb 20, 2024
@spikecurtis spikecurtis requested a review from mafredri February 20, 2024 11:21
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 40bd260 to 08764ff Compare February 20, 2024 12:15
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 72a8e58 to 67539d6 Compare February 20, 2024 12:15
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 08764ff to 4ce9f1d Compare February 20, 2024 12:37
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 67539d6 to d92399d Compare February 20, 2024 12:37
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 4ce9f1d to 7ecf10e Compare February 20, 2024 12:58
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from d92399d to 6b20b22 Compare February 20, 2024 12:58
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 7ecf10e to 2f05031 Compare February 20, 2024 16:19
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 6b20b22 to 249076e Compare February 20, 2024 16:19
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 2f05031 to 5cf1bb4 Compare February 22, 2024 05:42
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 249076e to 103c6e3 Compare February 22, 2024 05:42
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from 5cf1bb4 to f9ca6b2 Compare February 22, 2024 06:14
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 103c6e3 to 8e4eab1 Compare February 22, 2024 06:14
@spikecurtis spikecurtis force-pushed the spike/10534-agent-api-routines branch from f9ca6b2 to d9b360c Compare February 22, 2024 08:15
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 8e4eab1 to 425a947 Compare February 22, 2024 08:15
// shutdown scripts.
connMan.start("send logs", gracefulShutdownBehaviorRemain,
func(ctx context.Context, conn drpc.Conn) error {
err := a.logSender.SendLoop(ctx, proto.NewDRPCAgentClient(conn))
Copy link
Member

Choose a reason for hiding this comment

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

Is it good practice to use multiple clients over the same conn, or should we define the client in the parent scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The client contains no state other than the conn itself. It just maps RPC methods to Invoke or NewStream calls on the conn.

So, I think it's totally reasonable to make a new one per routine. That allows me to keep the connMan generic with a drpc.Conn. There are actually 2 different proto APIs (tailnet and agent) with their own client types.

@@ -2062,6 +2062,80 @@ func TestAgent_DebugServer(t *testing.T) {
})
}

func TestAgent_ScriptLogging(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

❤️

RunOnStop: true,
Script: `#!/bin/sh
i=0
while [ $i -ne 3000 ]
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if 3000 is flake-risky, considering we're using WaitMedium?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running on its own, the script part completes in ~100ms, including queueing all the logs, sending them, and asserting them in the test. If it flakes, something else is very wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Sure 👍🏻. I was mostly just worried about Windows, it can be unfathomably slow 😄

Base automatically changed from spike/10534-agent-api-routines to main February 23, 2024 07:04
@spikecurtis spikecurtis force-pushed the spike/10534-agent-logs-v2-api branch from 425a947 to 943991f Compare February 23, 2024 07:20
@spikecurtis spikecurtis merged commit 4cc132c into main Feb 23, 2024
@spikecurtis spikecurtis deleted the spike/10534-agent-logs-v2-api branch February 23, 2024 07:27
Copy link
Contributor Author

Merge activity

@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
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.

2 participants