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

Add integrity checks before uploading snapshots #402

Merged
merged 4 commits into from
Mar 29, 2023

Conversation

msakrejda
Copy link
Contributor

The snapshot format makes some structural assumptions that cannot be
enforced by protobuf. If these are violated, processing the snapshot
may fail, or snapshot data may be misinterpreted and can cause bogus
statistics to be recorded.

Validate these assumptions before sending a snapshot.

See discussion in #399 (review)

@msakrejda msakrejda requested a review from a team March 24, 2023 17:31
@msakrejda
Copy link
Contributor Author

Are there any other full snapshot checks we should make? I didn't see any similar checks to make for compact snapshots, but maybe I missed something.

output/full.go Outdated Show resolved Hide resolved
The snapshot format makes some structural assumptions that cannot be
enforced by protobuf. If these are violated, processing the snapshot
may fail, or snapshot data may be misinterpreted and can cause bogus
statistics to be recorded.

Validate these assumptions before sending a snapshot.
@msakrejda msakrejda force-pushed the add-snapshot-integrity-checks branch from 77a7709 to d851aa6 Compare March 28, 2023 17:59
This could cause problems for subsequent snapshot computations.

Instead, just log an error and send a failed snapshot.
}

func SendFailedFull(ctx context.Context, server *state.Server, collectionOpts state.CollectionOpts, logger *util.Logger) error {
s := snapshot.FullSnapshot{FailedRun: true, CollectorErrors: logger.ErrorMessages}
s := snapshot.FullSnapshot{FailedRun: true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up moving this into submitFull because both callers were setting collector errors independently before invoking that helper--we might as well do it in the shared code path.

Copy link
Contributor

@keiko713 keiko713 left a comment

Choose a reason for hiding this comment

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

nice! 👍

@msakrejda msakrejda merged commit 672ea56 into main Mar 29, 2023
@seanlinsley seanlinsley deleted the add-snapshot-integrity-checks branch July 25, 2023 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants