fix(ssh): stop warning about sessions that were never going to be recorded - #6896
Merged
Conversation
…orded `Session.Recorded` returned a plain error both when recording was off for the namespace and when the seat had no pty, so the only call site — which logs every non-nil return at warning as "failed to set the session as recorded" — reported the expected cases as failures. On a fleet running non-interactive SSH that is every session: an operator reading the logs concludes a compliance feature is silently dropping recordings. Return `ErrRecordingDisabled` and `ErrRecordingNoPty`, both wrapping `ErrRecordingSkipped` so the caller needs a single comparison, and log them at debug. Warning is left for a genuine `UpdateSession` failure. The recorder is still dropped in all three cases, so behaviour is unchanged. Fixes: #6894
|
Claude finished @otavio's task in 3m 11s —— View job Code Review CompleteReviewed 4 files across code quality, security, testing, language patterns, and architecture — no new issues found. The code looks good as-is. A few things I specifically verified:
Clean, well-scoped fix with tests covering both the sentinel identities and the regression itself. To request another review round, comment |
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.
What
Session.Recordednow reports the two conditions under which a session was never going to berecorded as expected outcomes rather than failures, so
pipelogs them at debug instead ofwarning. Recording behaviour is unchanged.
Why
Recordedreturned an undifferentiatederrorfor three unrelated outcomes: recording disabledfor the namespace, a seat with no pty, and a genuine
UpdateSessionfailure. The only call sitelogged every non-nil return at warning as
failed to set the session as recorded, so bothexpected cases were reported as a compliance feature failing.
On a fleet whose sessions are almost entirely non-interactive automation (
ssh host <command>),that is every session — an observed deployment logged the warning for 66 of 66 sessions in a
99-minute window, which triggered an incident investigation before the error string was read
closely enough to show the condition was normal.
Closes #6894
Changes
session: addedErrRecordingDisabledandErrRecordingNoPty, both wrappingErrRecordingSkipped. Wrapping keeps the specific reason in the log'serrorfield whileletting a caller ask a single question — a third skip condition won't require touching any
caller. The sentinels live beside
Recordedrather than inerrors.go, whose contents arescoped to errors returned to the SSH client.
channels:pipebranches onerrors.Is(err, session.ErrRecordingSkipped), loggingsession recording skippedat debug and reserving the warning for a realUpdateSessionfailure.
recorder = nilstill runs for all three outcomes.TestRecordedcovers the four outcomes and asserts sentinel identity witherrors.Is, not message text, since identity is what the call site dispatches on.TestPipeReportsExpectedRecordingSkipscovers the defect itself — an enterprise-edition pipeplus a logrus hook, asserting nothing is emitted at warn level and the skip lands at debug.
The signature was kept, rather than moving to
(bool, error), because the reason for the skip iswhat makes the debug line worth reading.
Testing
The warning branch has no call-site test:
Session.serviceis unexported, so thechannelspackage cannot inject a failing service. Its error origin is covered by
TestRecorded's"marking the session as recorded fails" case in the
sessionpackage.