Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete empty uploads #10608

Merged
merged 3 commits into from
Mar 3, 2022
Merged

Complete empty uploads #10608

merged 3 commits into from
Mar 3, 2022

Conversation

zmb3
Copy link
Collaborator

@zmb3 zmb3 commented Feb 25, 2022

The upload completer scans for uploads that need to be completed,
likely due to an error or process restart. Prior to this change,
it only completed uploads that had 1 or more parts. Since completing
an upload is what cleans up the directory on disk, it was possible
for us to leave behind empty directories for uploads with no parts.

This change makes it valid to complete uploads with no parts, which
ensures that these directories get cleaned up.

In addition, the upload completer checks the upload for a session.end
event, and emits one if there is not already an end event present.
This logic only handled session.end, and not
windows.desktop.session.end, so that has been updated as well.

Updates #9646

@zmb3 zmb3 added audit-log Issues related to Teleports Audit Log backport-required desktop-access labels Feb 25, 2022
Copy link
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

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

Code looks good, but I'm fairly certain that a multipart upload with zero parts is rejected by the s3 API. Please verify against s3 before merging.

@zmb3 zmb3 force-pushed the zmb3/complete-empty-uploads branch 6 times, most recently from fa920dd to f3742bd Compare March 3, 2022 00:41
@zmb3 zmb3 force-pushed the zmb3/complete-empty-uploads branch from f3742bd to 0019ff5 Compare March 3, 2022 01:20
@zmb3
Copy link
Collaborator Author

zmb3 commented Mar 3, 2022

Note to myself and others, please do not squash these commits - they were intentionally rebased and separated this way because some of them need to be backported further than others.

@zmb3 zmb3 force-pushed the zmb3/complete-empty-uploads branch from 0019ff5 to 7667328 Compare March 3, 2022 01:42
@russjones
Copy link
Contributor

@zmb3 Looks like this was approved, can you merge?

@zmb3
Copy link
Collaborator Author

zmb3 commented Mar 3, 2022

@zmb3 Looks like this was approved, can you merge?

Just waiting on tests to pass. Rotate trusted clusters is still a bit flaky.

zmb3 added 3 commits March 3, 2022 07:39
The upload completer scans for uploads that need to be completed,
likely due to an error or process restart. Prior to this change,
it only completed uploads that had 1 or more parts. Since completing
an upload is what cleans up the directory on disk (or in the case of
cloud storage, finishes the multipart upload), it was possible
for us to leave behind empty directories (or multipart uploads)
for uploads with no parts.

This change makes it valid to complete uploads with no parts, which
ensures that these directories get cleaned up.

Also fix an issue with the GCS uploader, which failed to properly calculate
the upload ID from the path. This is because strings.Split(s, "/") returns an empty
string as the last element when s ends with a /.

Updates #9646
Ensure that the logic which checks for (and emits) a session.end
event also applies for windows.desktop.session.end events.

For this to work, we use the StreamSessionEvents API instead of
GetEvents. This is because the streaming API works for any stream
of audit events, and GetSessionEvents is specific to SSH and the
chunks index format used by SSH sessions.

Lastly, ensure that desktop related events are also captured in the
session recording stream (but omitted when streaming the events to
the browser during session playback). This allows us to use the
start event in order to reconstruct a missing end event.
When completing a file-based upload, open the parts files one at a time
and write them to the upload, closing each file before opening the next
one.

This is preferrable to opening them all at once and closing all files at
the end, because it consumes less file descriptors.

Updates #10660
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 backport-required desktop-access
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants