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

Allow sparse option for Kopia & Restic restore #7141

Merged
merged 3 commits into from
Dec 6, 2023

Conversation

qiuming-best
Copy link
Contributor

@qiuming-best qiuming-best commented Nov 23, 2023

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #(issue)
#6664

  • Modify the uploader API
  • Modify DataMoverConfig field type in DataDownload into map[string]string
  • Modify the ParallelFilesUpload API for Kopia & Restic backup
  • Add sparse option for Kopia & Restic restore

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

@github-actions github-actions bot requested a review from sseago November 23, 2023 08:04
@qiuming-best qiuming-best marked this pull request as draft November 23, 2023 08:04
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from af6adc7 to b2f8bbe Compare November 24, 2023 02:16
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch 8 times, most recently from fe45ccd to 076c9a3 Compare November 24, 2023 09:31
Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Attention: 47 lines in your changes are missing coverage. Please review.

Comparison is base (85482ae) 61.77% compared to head (1a237d3) 61.78%.
Report is 34 commits behind head on main.

Files Patch % Lines
pkg/uploader/provider/restic.go 42.85% 12 Missing and 4 partials ⚠️
pkg/uploader/kopia/snapshot.go 47.61% 9 Missing and 2 partials ⚠️
pkg/cmd/util/output/restore_describer.go 0.00% 7 Missing ⚠️
pkg/podvolume/restorer.go 0.00% 3 Missing and 1 partial ⚠️
pkg/uploader/util/uploader_config.go 90.00% 2 Missing and 1 partial ⚠️
pkg/cmd/util/output/backup_describer.go 33.33% 2 Missing ⚠️
pkg/controller/data_download_controller.go 0.00% 1 Missing ⚠️
pkg/controller/data_upload_controller.go 50.00% 0 Missing and 1 partial ⚠️
pkg/controller/pod_volume_backup_controller.go 0.00% 0 Missing and 1 partial ⚠️
pkg/controller/pod_volume_restore_controller.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7141    +/-   ##
========================================
  Coverage   61.77%   61.78%            
========================================
  Files         259      262     +3     
  Lines       27859    28167   +308     
========================================
+ Hits        17210    17403   +193     
- Misses       9445     9534    +89     
- Partials     1204     1230    +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from 076c9a3 to 7cff2f1 Compare November 24, 2023 10:33
@github-actions github-actions bot added the Area/Design Design Documents label Nov 24, 2023
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch 2 times, most recently from a34a85f to dfb8935 Compare November 24, 2023 10:37
@qiuming-best qiuming-best marked this pull request as ready for review November 27, 2023 02:00
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from dfb8935 to fd77ba8 Compare November 27, 2023 02:10
Copy link
Contributor

@draghuram draghuram left a comment

Choose a reason for hiding this comment

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

Also note that the new uploaded config needs to be added at https://velero.io/docs/v1.12/api-types/restore/.

@@ -122,5 +122,44 @@ Roughly, the process is as follows:
3. Each respective controller within the CRs calls the uploader, and the ParallelFilesUpload from UploaderConfig in CRs is passed to the uploader.
4. When the uploader subsequently calls the Kopia API, it can use the ParallelFilesUpload to set the MaxParallelFileReads parameter, and if the uploader calls the Restic command it would output one warning log for Restic does not support this feature.

### Sparse Option For Kopia & Restic Restore
In many system files, there are numerous zero bytes or empty blocks that still occupy physical storage space. Sparse backup employs a more intelligent approach by only backing up the actual data-containing portions. For those empty blocks or zero bytes, it merely records their presence without actually storing them. This can significantly reduce the storage space required for backups, especially in situations where there is a substantial amount of empty data in large file systems.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is describing the backup but this section is about sparse restore?

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've removed the design, and I'll add the design later

design/velero-uploader-configuration.md Outdated Show resolved Hide resolved
config/crd/v1/bases/velero.io_backups.yaml Outdated Show resolved Hide resolved
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from fd77ba8 to 0571fd2 Compare November 28, 2023 06:38
@qiuming-best qiuming-best changed the title Allow sparse option for Kopia & Restic restore [WIP] Allow sparse option for Kopia & Restic restore Nov 28, 2023
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch 5 times, most recently from ae3461c to bfc6b68 Compare November 30, 2023 05:37
@github-actions github-actions bot removed the Area/Design Design Documents label Nov 30, 2023
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from bfc6b68 to 0fc7e5f Compare November 30, 2023 05:42
@qiuming-best qiuming-best changed the title [WIP] Allow sparse option for Kopia & Restic restore Allow sparse option for Kopia & Restic restore Nov 30, 2023
pkg/cmd/cli/restore/create.go Outdated Show resolved Hide resolved
pkg/controller/data_upload_controller.go Outdated Show resolved Hide resolved
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from 0fc7e5f to 7b95b3c Compare November 30, 2023 10:49
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from 7b95b3c to 0afaa70 Compare November 30, 2023 10:56
@reasonerjt reasonerjt added this to the v1.13 milestone Dec 4, 2023
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch 4 times, most recently from 939def8 to ded375c Compare December 5, 2023 08:15
UploaderConfigForBackup *UploaderConfigForBackup `json:"uploaderConfig,omitempty"`
}

// UploaderConfigForBackup defines the configuration for the backup.
Copy link
Contributor

Choose a reason for hiding this comment

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

inaccurate comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -177,6 +177,11 @@ func DescribeRestore(ctx context.Context, kbClient kbclient.Client, restore *vel
d.Println()
d.Printf("Preserve Service NodePorts:\t%s\n", BoolPointerString(restore.Spec.PreserveNodePorts, "false", "true", "auto"))

if restore.Spec.UploaderConfigForRestore != nil && *restore.Spec.UploaderConfigForRestore.WriteSparseFiles {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a risk of nil pointer b/c restore.Spec.UploaderConfigForRestore.WriteSparseFiles may also be nil, you should use boolptr.IsSetToTrue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

// UploaderConfig specifies the configuration for the restore.
// +optional
// +nullable
UploaderConfigForRestore *UploaderConfigForRestore `json:"uploaderConfig,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Trivial: for simplicity and consistency with json key and comment, the name of the Field in the struct should better be UploaderConfig, there won't be confusion, b/c normally the code would look like

restore.Spec.UploaderConfig .....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

}

func StoreRestoreConfig(config *velerov1api.UploaderConfigForRestore) map[string]string {
data := make(map[string]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this cause inconsistency for different uploaders?
Can we be sure that the default value is always false for different uploaders?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

return data
}

func GetBackupConfig(data map[string]string) (velerov1api.UploaderConfigForBackup, error) {
Copy link
Contributor

@reasonerjt reasonerjt Dec 6, 2023

Choose a reason for hiding this comment

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

I'm not sure if reusing velerov1api.UploaderConfigForBackup is a good approach, there may be settings in PVB that is meaningful to the uploader but is not exposed in backup CR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from ded375c to 2f00ea9 Compare December 6, 2023 08:37
Signed-off-by: Ming Qiu <mqiu@vmware.com>
@qiuming-best qiuming-best force-pushed the support-restore-sparse branch from 2f00ea9 to 1a237d3 Compare December 6, 2023 08:59
Copy link
Contributor

@reasonerjt reasonerjt left a comment

Choose a reason for hiding this comment

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

lgtm

@Lyndon-Li Lyndon-Li merged commit 099acd2 into vmware-tanzu:main Dec 6, 2023
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants