-
Notifications
You must be signed in to change notification settings - Fork 43
feat: send logs using agent api v2 if available #264
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
Conversation
…nually vendored codersdk
e629778
to
9a0f335
Compare
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_sendLogs(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's no longer easy to test this via integration without standing up an entire Coder instance, so removed this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an integration test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not yet. I think this could be a good candidate for a follow-up, but it would mean we need to:
- Stand up an in-memory Coder instance
- Create an envbuilder template (we currently keep envbuilder templates in coder/coder)
- Assert the logs get sent to Coder
It would be fairly heavyweight all in all. What I'd really like is a more lightweight fluentd
-like utility that just consumes stdin and forwards to a Coder instance.
internal/eblog/coder.go
Outdated
// coderURL and authenticates using token. It then establishes a | ||
// dRPC connection to the Agent API and begins sending logs. | ||
// The returned function is used to block until all logs are sent. | ||
func Coder(ctx context.Context, coderURL *url.URL, token string) (LogFunc, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove the possibility of this breaking older users, I can check the Coder version and conditionally return a different implementation that uses the old deprecated endpoint. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can technically break as we are bumping a major version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding support for backward compatibility based on a similar commit in envbox.
-e GIT_URL=https://github.com/denoland/deno \ | ||
-e INIT_SCRIPT="bash" \ | ||
-e ENVBUILDER_GIT_URL=https://github.com/denoland/deno \ | ||
-e ENVBUILDER_INIT_SCRIPT="bash" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review: drive-by
require ( | ||
cdr.dev/slog v1.6.2-0.20240126064726-20367d4aede6 | ||
github.com/GoogleContainerTools/kaniko v1.9.2 | ||
github.com/breml/rootcerts v0.2.10 | ||
github.com/chainguard-dev/git-urls v1.0.2 | ||
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version includes ConnectRPC20
and LogDest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that it still shows v2.10.1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I noticed that too, I think it's related to the last tag on main
:
git tag --merged main | sort -V | tail -1
v2.10.0
After that, we started using branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except in go.mod
it's v2.10.1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I care about is that the commit is present 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nit picks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor points
require ( | ||
cdr.dev/slog v1.6.2-0.20240126064726-20367d4aede6 | ||
github.com/GoogleContainerTools/kaniko v1.9.2 | ||
github.com/breml/rootcerts v0.2.10 | ||
github.com/chainguard-dev/git-urls v1.0.2 | ||
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that it still shows v2.10.1
.
rpcConnectTimeout = 10 * time.Second | ||
logSendGracePeriod = 10 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I wonder if these should be configurable; at least the timeout feels like it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this as a follow up, we may not end up needing an extra knob.
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_sendLogs(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an integration test for this?
Closes #260 - Removes manually vendored codersdk, we're back on the real deal now - Moves logging setup to package internal/eblog - Modifies logging to use new agent api v2 methods, falling back to PatchLogs - Adds ENVBUILDER_VERBOSE Tested manually against Coder version 2.8.0, 2.9.0, and 2.13.0. (cherry picked from commit 5be0611)
Closes #260
internal/eblog
ENVBUILDER_VERBOSE
Tested manually against Coder version 2.8.0, 2.9.0, and 2.13.0.