Fail a device whose clock has drifted out of TLS validity - #6
Open
KalebKE wants to merge 1 commit into
Open
Conversation
A pooled emulator is resumed, not recreated, so it can come back with its clock months behind. Nothing about it looks broken: adb answers "device", the screen is idle, `list` reports it healthy, and the pool keeps handing it out. Every TLS chain on that device then fails notBefore validation. The net stack reports ERR_CERT_DATE_INVALID, Conscrypt raises "Chain validation failed", and Firebase wraps it as "An internal error has occurred" — so the failure surfaces as an auth bug in whatever signs in first, on branches that touch no auth code. Observed on ci-pool-4 sitting four months behind the host: every E2E sign-in across the fleet failed at once, on three unrelated PRs including a docs-only change, and the retry logic in the consumer masked it further by treating "an internal error has occurred" as transient and retrying four times before giving up. Adds clockSkew alongside wedged, which exists for the same class of problem — reachable but unusable — and composes it into androidBackend health the same way. Sixty seconds is far wider than NTP drift and far narrower than anything that breaks certificate validation. Best-effort, like wedged: a device that will not answer `date` is not condemned on that basis. Reachability is already covered by healthy, and failing closed would empty the pool the first time an image drops the binary. Reporting these unhealthy is what makes the rest work: repair restarts unhealthy virtual devices, and consumers that check for a healthy device before trusting the pool now route around a skewed one instead of leasing it and failing somewhere unrelated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pooled emulator is resumed, not recreated, so it can come back with its clock months behind. Nothing about it looks broken — adb answers
device, the screen is idle,listreports it healthy — and the pool keeps handing it out.Every TLS chain on that device then fails
notBeforevalidation:So the failure surfaces as an auth bug in whatever signs in first, on branches that touch no auth code.
How it presented
ci-pool-4was sitting four months behind the host — its logcat timestamps read04-19while the job ran on08-31. Every E2E sign-in in the fleet failed at once, across three unrelated PRs including a docs-only change. Two things made it hard to see:"an internal error has occurred"as transient, so it retried four times with backoff before giving up — the log looks like a flaky network, not a broken device.The change
clockSkewsits alongsidewedged, which exists for exactly the same class of problem — reachable but unusable — and composes intoandroidBackend.healththe same way. 60s is far wider than NTP drift and far narrower than anything that breaks certificate validation.Best-effort, like
wedged: a device that will not answerdateis not condemned on that basis. Reachability is already covered byhealthy, and failing closed would empty the pool the first time an image drops the binary.Reporting these unhealthy is what makes the rest work —
repairrestarts unhealthy virtual devices, and consumers that require a healthy device before trusting the pool now route around a skewed one instead of leasing it and failing somewhere unrelated.Tests
Four cases: in step, 20s adrift (healthy), four hours behind, four hours ahead (both unhealthy, reason names the clock), plus a device whose
dateerrors staying healthy.go vet ./...and the full suite pass. The cross-compiled binary was also run against the live pool — it reports all six devices healthy, which is correct right now.I did not force a live skew to demonstrate detection: those devices were mid-CI-run at the time.