Skip to content

Conversation

@eriktate
Copy link
Contributor

@eriktate eriktate commented Apr 3, 2025

This PR prepares session recording to use different file operations based on configuration (e.g. encrypted or not). There shouldn't be any functional changes to how recordings are saved included in this PR

@eriktate eriktate added the no-changelog Indicates that a PR does not require a changelog entry label Apr 3, 2025
@github-actions github-actions bot added audit-log Issues related to Teleports Audit Log size/md labels Apr 3, 2025
return trace.Wrap(err)
}

if err := f.Truncate(n); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if any of these operation fails, should we keep the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. The caller of WritePart() removes the file in case of a failure and there's no reason to hang onto the reserved file if we bail out because of a failed truncation.

The individual part files should probably be removed too, but we don't currently remove them on failure (at least not near the callsite) and I don't really want to change effective behavior with this PR


func loggingClose(ctx context.Context, closer io.Closer, log *slog.Logger, msg string, args ...any) {
if err := closer.Close(); err != nil {
log.ErrorContext(ctx, msg, append(args, "error", err)...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything that we can do to avoid the allocation here? Perhaps maybe the caller should annotate the logger with any desired args via log.With before calling this function? Alternatively if this is only used in a handful of places, perhaps we could get rid of this function and just call close in line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah handling the close inline isn't really annoying enough to warrant the helper. Even when the encrypted version is added, that's only like 3 more spots we'll have to do the check. I opted to remove it for now, but preloading the logger is probably the best way to do something like this going forward, so I'll try to keep that in mind for later 👍

@eriktate eriktate force-pushed the eriktate/split-modular-session-recording-writes branch 3 times, most recently from b23ae13 to 5c9233c Compare April 7, 2025 18:50
@eriktate eriktate requested review from rosstimothy and tigrato April 7, 2025 21:09
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from doggydogworld April 9, 2025 09:19
@eriktate eriktate force-pushed the eriktate/split-modular-session-recording-writes branch from 1a1949e to 476ebc1 Compare April 9, 2025 14:06
@eriktate eriktate enabled auto-merge April 9, 2025 14:23
@eriktate eriktate added this pull request to the merge queue Apr 9, 2025
Merged via the queue into master with commit 2afda8c Apr 9, 2025
40 checks passed
@eriktate eriktate deleted the eriktate/split-modular-session-recording-writes branch April 9, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit-log Issues related to Teleports Audit Log no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants