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

Compress the snapshots(full as well as Incremental) before uploading to object store and decompress the snapshot before restoration. #293

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

ishan16696
Copy link
Member

@ishan16696 ishan16696 commented Dec 7, 2020

What this PR does / why we need it:
This PR added the compression/decompression feature. So, it compress/decompress the snapshots(full as well as Incremental) before/after uploading/downloading to/from object store.
It also supports the backward compatibility for restoring from non-compressed snapshots as well as when different compressionPolicy were used to take the snapshot.

Which issue(s) this PR fixes:
Fixes #255

Special notes for your reviewer:

Release note:

Add support for snapshot compression/decompression. Compression and compression policy can be configured through flags:  `--compress-snapshots` and `--compression-policy` respectively. Supported compression policies currently are `gzip` (default), `lzw` and `zlib`. Snapshot compression is disabled by default.

@gardener-robot gardener-robot added needs/review Needs review size/l Size of pull request is large (see gardener-robot robot/bots/size.py) needs/second-opinion Needs second review by someone else labels Dec 7, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 7, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 7, 2020
Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @ishan16696! It is looking good. Some small suggestions.

Also, could you please add some tests to cover the compression cases. Especially, for restoration in the mixed case (mixing of uncompressed and compressed backups with different algo)?

cmd/options.go Outdated Show resolved Hide resolved
cmd/options.go Outdated Show resolved Hide resolved
cmd/options.go Outdated Show resolved Hide resolved
cmd/options.go Outdated Show resolved Hide resolved
pkg/compressor/compressor.go Outdated Show resolved Hide resolved
example/00-backup-restore-server-config.yaml Outdated Show resolved Hide resolved
pkg/compressor/types.go Outdated Show resolved Hide resolved
pkg/server/types.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/types.go Outdated Show resolved Hide resolved
@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Dec 7, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 8, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 8, 2020
Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

A small comment about the logging time. I think we can simply rely on existing time logging for download or upload which would be enough. No additional logging time for compression is required. We can still log that we are compressing/uncompressing.

pkg/compressor/compressor.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 8, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 8, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 10, 2020
Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Once you have added the tests for the mixed case for restoration, this PR is good to be merged.

example/00-backup-restore-server-config.yaml Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
@gardener-robot gardener-robot added size/xl Size of pull request is huge (see gardener-robot robot/bots/size.py) and removed size/l Size of pull request is large (see gardener-robot robot/bots/size.py) labels Dec 14, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 14, 2020
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao left a comment

Choose a reason for hiding this comment

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

@ishan16696 Thanks a lot for the well-written PR. Overall, code looks fine. I will test it out in the morning. Other than that, I have some minor code-related concerns/suggestions. Please address them. Thanks.
Also, please document your findings about compression and decompression (time taken, size reduction ratio, etc) for the different algorithms, so that it can serve as a reference point for someone new to compression and wanting to choose a suitable algorithm for running etcdbr.

pkg/compressor/init.go Outdated Show resolved Hide resolved
pkg/compressor/types.go Outdated Show resolved Hide resolved
pkg/compressor/types.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 15, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 15, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 20, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 20, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 23, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 23, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 24, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 24, 2020
Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

@ishan16696 Thanks a lot for the changes and also the tests. The PR is now looking good. Just some final comments below.

example/00-backup-restore-server-config.yaml Outdated Show resolved Hide resolved
pkg/compressor/compressor.go Show resolved Hide resolved
pkg/compressor/compressor.go Show resolved Hide resolved
pkg/compressor/compressor.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshotter/snapshotter.go Outdated Show resolved Hide resolved
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 7, 2021
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 7, 2021
@gardener-robot gardener-robot added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 12, 2021
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 12, 2021
@amshuman-kr
Copy link
Collaborator

Thanks @ishan16696 for the test case and the changes. I have only a few remaining questions.

  1. In the restoration tests, it is not clear to me how the first runSnapshotter call reliably takes a full snapshot and also how we can be sure that the snapshot are completed by the time the function call returns.
  2. The default vase for IsSnapshotCompressed for completeness.

@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 19, 2021
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jan 19, 2021
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jan 19, 2021
@ishan16696
Copy link
Member Author

ishan16696 commented Jan 20, 2021

  1. In the restoration tests, it is not clear to me how the first runSnapshotter call reliably takes a full snapshot

there is boolean variable here by which we can configure either to take fullSnapshot or deltaSnapshot.

how we can be sure that the snapshot are completed by the time the function call returns.

I am also not so sure .... but runSnapshotter is returning an error so by this error we can be sure that runSnapshotter is completed otherwise here test will get fail.

The default vase for IsSnapshotCompressed for completeness.

done

Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @ishan16696! LGTM

Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao left a comment

Choose a reason for hiding this comment

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

@ishan16696 Thanks for making all the changes. LGTM 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/changes Needs (more) changes needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/review Needs review needs/second-opinion Needs second review by someone else size/xl Size of pull request is huge (see gardener-robot robot/bots/size.py)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Compress/decompress snapshots before/after uploading/downloading to/from object store
7 participants