summaryrefslogtreecommitdiffhomepage
path: root/logtail
AgeCommit message (Collapse)AuthorFilesLines
2021-05-04logtail/filch: add staticcheck annotationJosh Bleecher Snyder1-0/+1
To work around a staticcheck bug when running with GOOS=windows. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-15logtail: reduce PublicID.UnmarshalText from 2 allocs to 0Brad Fitzpatrick2-6/+32
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-02logtail: use link monitor to determine when to retry after upload failureBrad Fitzpatrick1-0/+34
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-01cmd/tailscaled, logtail: share link monitor from wgengine to logtailBrad Fitzpatrick1-0/+10
Part of overall effort to clean up, unify, use link monitoring more, and make Tailscale quieter when all networks are down. This is especially bad on macOS where we can get killed for not being polite it seems. (But we should be polite in any case) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-01-15logtail: add testsDenton Gentry1-14/+242
+ add a test for parseAndRemoveLogLevel() + add a test for drainPendingMessages() + test JSON log encoding including several special cases Other tests frequently send logs but a) don't check the result and b) do so by happenstance, such that the code in encode() was not consistently being exercised and leading to spurious changes in code coverage. These tests attempt to more systematically test the logging function. This is the second attempt to add these tests, the first attempt (in https://github.com/tailscale/tailscale/pull/1114) had two issues: 1. httptest.NewServer creates multiple goroutine handlers, and logtail uses goroutines to upload, but the first version had no locking in the server to guard this. Moved data handling into channels to get synchronization. 2. The channel to notify the test of the arrival of data had a depth of 1, in cases where the Logger sent multiple uploads it would block the server. This resulted in the first iteration of these tests being flaky, and we reverted it. This new version of the tests has passed with go test -race -count=10000 and seems solid. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-01-12Revert "Add logtail tests (#1114)" (#1116)Denton Gentry1-209/+7
This reverts commit e4f53e9b6f1a4d3d6f00091ddef617989b1ea3e4. At least two of these tests are flakey, reverting until they can be made more robust. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-01-12Add logtail tests (#1114)Denton Gentry1-7/+209
* logtail: test parseAndRemoveLogLevel() Signed-off-by: Denton Gentry <dgentry@tailscale.com> * logtail: test JSON log encoding. Expand TestUploadMessages to also exercise the encoding functions in logtail, like JSON logging and timestamps. Other tests frequently send logs but a) don't check the result and b) do so by happenstance, such that the lines in encode() were not consistently being exercised and leading to spurious changes in code coverage. Signed-off-by: Denton Gentry <dgentry@tailscale.com> * logtail: add a test for drainPendingMessages Make the client buffer some messages before the upload server becomes available. Signed-off-by: Denton Gentry <dgentry@tailscale.com> * logtail: use %q, raw strings, and io.WriteString %q escapes binary characters for us. raw strings avoid so much backslash escaping Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-01-12logtail: start a local server for TestFastShutdownDenton Gentry1-1/+6
Right now TestFastShutdown tries to upload logs to localhost:1234, which will most likely respond with an error. However if one has an actual service running on port 1234, it would receive a connection attempting to POST every time the unit test runs. Start a local server and direct the upload there instead. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-01-12logtail: add a test to upload logs to local serverDenton Gentry1-0/+23
Start an HTTP server to accept POST requests, and upload some logs to it. Check that uploaded logs were received. Code in logtail:drainPending was not being reliably exercised by other tests. This shows up in code coverage reports, as lines of code in drainPending are alternately added and subtracted from code coverage. This test will reliably exercise and verify this code. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-01-11all: adjust Unix permissions for those without umasksBrad Fitzpatrick1-2/+2
Fixes tailscale/corp#1165 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-12-21cmd/tailscaled, logpolicy, logtail: support log levelsBrad Fitzpatrick1-1/+34
Log levels can now be specified with "[v1] " or "[v2] " substrings that are then stripped and filtered at the final logger. This follows our existing "[unexpected]" etc convention and doesn't require a wholesale reworking of our logging at the moment. cmd/tailscaled then gets a new --verbose=N flag to take a log level that controls what gets logged to stderr (and thus systemd, syslog, etc). Logtail is unaffected by --verbose. This commit doesn't add annotations to any existing log prints. That is in the next commit. Updates #924 Updates #282 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-12-21logtail, logpolicy: remove an unidiomatic use of an interfaceBrad Fitzpatrick3-46/+38
2020-11-24logtail: help the server be more efficientJosh Bleecher Snyder1-6/+20
Add content length hints to headers. The server can use these hints to more efficiently select buffers. Stop attempting to compress tiny requests. The bandwidth savings are negligible (and sometimes negative!), and it makes extra work for the server. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-11-17logtail: fix typo in commentJosh Bleecher Snyder1-1/+1
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-10-14logtail/filch: skip a broken test on WindowsBrad Fitzpatrick1-0/+9
Add a TODO with some notes about why it's skipped for now. Updates #50
2020-10-02all: use testing.T.TempDirJosh Bleecher Snyder1-21/+5
Bit of Friday cleanup. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-08-09backoff: update to Go style, document a bit, make 30s explicitBrad Fitzpatrick2-36/+53
Also, bit of behavior change: on non-nil err but expired context, don't reset the consecutive failure count. I don't think the old behavior was intentional. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-27logtail: return correct write size from logger.WriteElias Naur2-1/+17
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-05logtail: we missed a case for the backoff timer.Avery Pennarun1-1/+1
We want to run bo.Backoff() after every upload, regardless. If upload==true but err!=nil, we weren't backing off, which caused some very-high-throughput log upload retries in bad network conditions. Updates #282. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-27filch_test: clarify the use of os.RemoveAll().Avery Pennarun1-13/+13
Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-13magicsock/test: oops, fix a data race in nested-test logf hack.Avery Pennarun1-1/+1
Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-13Add tstest.PanicOnLog(), and fix various problems detected by this.Avery Pennarun3-13/+19
If a test calls log.Printf, 'go test' horrifyingly rearranges the output to no longer be in chronological order, which makes debugging virtually impossible. Let's stop that from happening by making log.Printf panic if called from any module, no matter how deep, during tests. This required us to change the default error handler in at least one http.Server, as well as plumbing a bunch of logf functions around, especially in magicsock and wgengine, but also in logtail and backoff. To add insult to injury, 'go test' also rearranges the output when a parent test has multiple sub-tests (all the sub-test's t.Logf is always printed after all the parent tests t.Logf), so we need to screw around with a special Logf that can point at the "current" t (current_t.Logf) in some places. Probably our entire way of using subtests is wrong, since 'go test' would probably like to run them all in parallel if you called t.Parallel(), but it definitely can't because the're all manipulating the shared state created by the parent test. They should probably all be separate toplevel tests instead, with common setup/teardown logic. But that's a job for another time. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-04-29backoff: add a LogLongerThan configuration.Avery Pennarun1-4/+11
Some programs use frequent short-duration backoffs even under non-error conditions. They can set this to avoid logging short backoffs when things are operating normally, but still get messages when longer backoffs kick in. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-04-29logtail/backoff: only log backoffs > 2secDavid Crawshaw1-1/+3
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2020-04-27logtail: add PrivateID.IsZero methodBrad Fitzpatrick1-0/+3
2020-04-26logtail: add const DefaultHost with default server nameBrad Fitzpatrick1-1/+5
2020-04-13logtail: add ParsePublicID that doesn't allocateBrad Fitzpatrick2-0/+22
2020-04-05logtail: don't send a User-AgentBrad Fitzpatrick1-0/+1
Just useless bytes on the wire. Especially with HTTP/1. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-04-05logtail: add ParsePrivateIDBrad Fitzpatrick2-0/+40
2020-04-04logtail: read to EOF on chunked responseBrad Fitzpatrick1-1/+11
We'll be fixing the server so this won't trigger in practice, but it demos the connection reuse problem. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-04-04logtail: reduce allocations encoding textBrad Fitzpatrick2-1/+32
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-03-20logtail: rename the unused CheckLogs to DrainLogsDavid Crawshaw2-15/+41
Its semantics has changed slightly, this will let us use it to drive batched logging in special circumstances. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2020-03-20filch: a few minor commentsDavid Crawshaw1-0/+5
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2020-03-15logtail: minor style/simplification changesBrad Fitzpatrick1-6/+5
2020-02-13logtail/filch: use x/sys/unix instead of syscall.David Anderson1-3/+4
In particular, the Dup2 syscall is not defined in the syscall package on arm64, but is defined in x/sys/unix. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-11logtail: remove unused code from old sentinel logic.David Anderson1-44/+0
Signed-off-by: David Anderson <dave@natulte.net>
2020-02-10logtail: don't pass in nil contexts.David Anderson1-4/+1
Signed-off-by: David Anderson <dave@natulte.net>
2020-02-10logtail: remove unused struct fields.David Anderson1-4/+0
Signed-off-by: David Anderson <dave@natulte.net>
2020-02-10logtail/filch: use io's seek constants.David Anderson1-5/+5
Signed-off-by: David Anderson <dave@natulte.net>
2020-02-09Move Linux client & common packages into a public repo.Earl Lee17-0/+1773