mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: avoid connection logging crashes in agent (#20307)
- Ignore errors when reporting a connection from the server, just log them instead - Translate connection log IP `localhost` to `127.0.0.1` on both the server and the agent Note that the temporary fix for converting invalid IPs to localhost is not required in main since the database no longer forbids NULL for the IP column since https://github.com/coder/coder/pull/19788 Relates to #20194
This commit is contained in:
@@ -62,10 +62,6 @@ func (m *FakeConnectionLogger) Contains(t testing.TB, expected database.UpsertCo
|
||||
t.Logf("connection log %d: expected ID %s, got %s", idx+1, expected.ID, cl.ID)
|
||||
continue
|
||||
}
|
||||
if !expected.Time.IsZero() && expected.Time != cl.Time {
|
||||
t.Logf("connection log %d: expected Time %s, got %s", idx+1, expected.Time, cl.Time)
|
||||
continue
|
||||
}
|
||||
if expected.OrganizationID != uuid.Nil && cl.OrganizationID != expected.OrganizationID {
|
||||
t.Logf("connection log %d: expected OrganizationID %s, got %s", idx+1, expected.OrganizationID, cl.OrganizationID)
|
||||
continue
|
||||
@@ -114,6 +110,18 @@ func (m *FakeConnectionLogger) Contains(t testing.TB, expected database.UpsertCo
|
||||
t.Logf("connection log %d: expected ConnectionID %s, got %s", idx+1, expected.ConnectionID.UUID, cl.ConnectionID.UUID)
|
||||
continue
|
||||
}
|
||||
if expected.DisconnectReason.Valid && cl.DisconnectReason.String != expected.DisconnectReason.String {
|
||||
t.Logf("connection log %d: expected DisconnectReason %s, got %s", idx+1, expected.DisconnectReason.String, cl.DisconnectReason.String)
|
||||
continue
|
||||
}
|
||||
if !expected.Time.IsZero() && expected.Time != cl.Time {
|
||||
t.Logf("connection log %d: expected Time %s, got %s", idx+1, expected.Time, cl.Time)
|
||||
continue
|
||||
}
|
||||
if expected.ConnectionStatus != "" && expected.ConnectionStatus != cl.ConnectionStatus {
|
||||
t.Logf("connection log %d: expected ConnectionStatus %s, got %s", idx+1, expected.ConnectionStatus, cl.ConnectionStatus)
|
||||
continue
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user