fix(ci-visibility): harden review edge cases#4735
fix(ci-visibility): harden review edge cases#4735gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
9a3ddc0 to
a3a2821
Compare
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: d92e058 | Docs | Datadog PR Page | Give us feedback! |
2450bfb to
0054f0b
Compare
0054f0b to
1645ac3
Compare
BenchmarksBenchmark execution time: 2026-05-06 22:15:11 Comparing candidate commit d92e058 in PR branch Found 0 performance improvements and 4 performance regressions! Performance is the same for 238 metrics, 9 unstable metrics.
|
42d74ee
into
main
What does this PR do?
Fixes three CI Visibility review findings around logs, settings bootstrap, and shallow Git recovery.
This PR makes the CI Visibility logs writer safe when log writes, flushes, payload rotation, and shutdown overlap. The package-level logs state is now synchronized, writer payload rotation is guarded by a writer mutex, uploads are reserved before goroutines start, and log writes accepted before shutdown are flushed exactly once. It also updates the stale msgpack comments for the JSON logs payload path.
It also hardens settings initialization so a nil settings response no longer panics. The bootstrap now logs nil settings responses separately from request errors, leaves settings at their zero value, and preserves the existing upload wait behavior. A test seam for client creation lets the nil-response paths be covered directly.
Finally,
UnshallowGitRepositorynow treats a successful but quietgit fetchas success. The HEAD and upstream fetch fallbacks now run only after real command errors, avoiding the previous nil-error panic and unnecessary fallback behavior.Motivation
Follow-up review found concurrency and nil-handling gaps that could make CI Visibility unstable under parallel log writes, unusual client responses, or quiet Git commands.
The highest-risk issue was in logs: the payload object had its own locking, but the writer swapped the payload pointer without a writer-level lock. Concurrent writes, flushes, and stop could race with rotation and lose accepted log entries.
The settings and Git fixes address defensive edge cases: nil settings responses should disable features safely, and Git commands that exit successfully do not need stdout to be considered successful.
Testing
go test ./internal/civisibility/integrations/logsgo test -race ./internal/civisibility/integrations/logsgo test ./internal/civisibility/integrations -run 'TestEnsureSettingsInitialization|TestUploadRepositoryChanges|TestSearchCommitsResponse'go test ./internal/civisibility/utils -run 'TestUnshallowGitRepository'go test ./internal/civisibility/...go test -race ./internal/civisibility/...go vet ./internal/civisibility/...