-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(backup): incremental NAS backup support for KVM #13074
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
Open
jmsperu
wants to merge
21
commits into
apache:main
Choose a base branch
from
jmsperu:feature/nas-backup-incremental
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,687
−26
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f2a9202
docs: add RFC for incremental NAS backup support (KVM)
jmsperu 1981469
feat(backup): add chain-metadata keys + nas.backup.full.every config
jmsperu fbb916b
feat(backup): nasbackup.sh full+incremental modes via backup-begin
jmsperu 1f2aebc
feat(backup): orchestrate full vs incremental in NAS provider
jmsperu 43e2f75
feat(backup): on-demand bitmap recreation for incremental NAS backup
jmsperu 39303fb
feat(backup): restore path follows incremental backing-chain
jmsperu b8d069e
feat(backup): cascade-delete + chain repair for NAS incrementals
jmsperu 49edc7f
test(backup): smoke tests for incremental NAS backup chain
jmsperu d80ed16
test(backup): mock returns no-backing-chain for rsync-failure test
jmsperu 9764025
docs: move RFC out of repo per reviewer feedback
jmsperu 72f967a
test(backup): mock BackupDetailsDao to fix NPE in NASBackupProviderTest
jmsperu 7e1691b
feat(backup): anchor incremental chain on VM active_checkpoint_id
jmsperu b7b74c4
refactor(backup): mirror snapshot-style delete chain for NAS incremen…
jmsperu 9f4d61f
test(backup): drop unnecessary host.getId() stub in live-child delete…
jmsperu 691931d
feat(backup): add nas.backup.incremental.enabled master switch
jmsperu 0bdcdb1
feat(backup): pre-seed bitmap on stopped-VM backup for next incremental
jmsperu 5be1910
refactor(backup): per-volume parent paths for incremental NAS backup
jmsperu 3e2e144
fix(nas-backup): address Copilot review on PR #13074
jmsperu 4f3375a
fix(nas-backup): don't persist unconfirmed bitmap; gate sanity_checks
jmsperu bedcc2a
test(nas-backup): enable incremental in active-checkpoint test
jmsperu f2210f4
refactor(nas-backup): address abh1sar review on PR #13074
jmsperu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
core/src/main/java/org/apache/cloudstack/backup/RebaseBackupCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // | ||
|
|
||
| package org.apache.cloudstack.backup; | ||
|
|
||
| import com.cloud.agent.api.Command; | ||
| import com.cloud.agent.api.LogLevel; | ||
|
|
||
| /** | ||
| * Tells the KVM agent to rebase a NAS backup qcow2 onto a new backing parent. Used by the | ||
| * NAS backup provider during chain repair when a middle incremental is being deleted: the | ||
| * immediate child must absorb the soon-to-be-deleted parent's blocks and then re-link to | ||
| * the grandparent. Both target and new-backing paths are NAS-mount-relative. | ||
| */ | ||
| public class RebaseBackupCommand extends Command { | ||
| private String targetPath; // mount-relative path of the qcow2 to repoint | ||
| private String newBackingPath; // mount-relative path of the new backing parent | ||
| private String backupRepoType; | ||
| private String backupRepoAddress; | ||
| @LogLevel(LogLevel.Log4jLevel.Off) | ||
| private String mountOptions; | ||
|
|
||
| public RebaseBackupCommand(String targetPath, String newBackingPath, | ||
| String backupRepoType, String backupRepoAddress, String mountOptions) { | ||
| super(); | ||
| this.targetPath = targetPath; | ||
| this.newBackingPath = newBackingPath; | ||
| this.backupRepoType = backupRepoType; | ||
| this.backupRepoAddress = backupRepoAddress; | ||
| this.mountOptions = mountOptions; | ||
| } | ||
|
|
||
| public String getTargetPath() { | ||
| return targetPath; | ||
| } | ||
|
|
||
| public String getNewBackingPath() { | ||
| return newBackingPath; | ||
| } | ||
|
|
||
| public String getBackupRepoType() { | ||
| return backupRepoType; | ||
| } | ||
|
|
||
| public String getBackupRepoAddress() { | ||
| return backupRepoAddress; | ||
| } | ||
|
|
||
| public String getMountOptions() { | ||
| return mountOptions == null ? "" : mountOptions; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean executeInSequence() { | ||
| return true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupChainKeys.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.backup; | ||
|
|
||
| /** | ||
| * Keys used by the NAS backup provider when storing incremental-chain metadata | ||
| * in the existing {@code backup_details} key/value table. Stored here (not on | ||
| * the {@code backups} table) so other providers do not need a schema change to | ||
| * support their own incremental implementations. | ||
| */ | ||
| public final class NASBackupChainKeys { | ||
|
|
||
| /** UUID of the parent backup (full or previous incremental). Empty for full backups. */ | ||
| public static final String PARENT_BACKUP_ID = "nas.parent_backup_id"; | ||
|
|
||
| /** QEMU dirty-bitmap name created by this backup, used as the {@code <incremental>} reference for the next one. */ | ||
| public static final String BITMAP_NAME = "nas.bitmap_name"; | ||
|
|
||
| /** Identifier shared by every backup in the same chain (the full anchors a chain; its incrementals inherit the id). */ | ||
| public static final String CHAIN_ID = "nas.chain_id"; | ||
|
|
||
| /** Position within the chain: 0 for the full, 1 for the first incremental, and so on. */ | ||
| public static final String CHAIN_POSITION = "nas.chain_position"; | ||
|
|
||
| /** | ||
| * In-memory chain-mode sentinels used by {@code ChainDecision.mode}. The persisted | ||
| * full-vs-incremental backup type lives on the {@code backup.type} column (set in | ||
| * {@code takeBackup}) — single source of truth. Not duplicated into backup_details. | ||
| */ | ||
| public static final String TYPE_FULL = "full"; | ||
| public static final String TYPE_INCREMENTAL = "incremental"; | ||
|
Comment on lines
+44
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two strings are not being used anywhere in the code. Can be removed |
||
|
|
||
| /** | ||
| * Tombstone key stored in {@code backup_details} when a backup is requested for deletion | ||
| * but still has live children. The on-NAS file is preserved until the last child is gone, | ||
| * at which point cascade deletion collects every tombstoned ancestor. Mirrors the snapshot | ||
| * subsystem's {@code Hidden} state semantics (see {@code DefaultSnapshotStrategy}). | ||
| */ | ||
| public static final String DELETE_PENDING = "nas.delete_pending"; | ||
|
|
||
| /** | ||
| * VM-scoped detail (stored in {@code vm_instance_details}) holding the QEMU dirty-bitmap | ||
| * name that currently exists on the running VM and is therefore the only valid parent | ||
| * for the next incremental backup. Written by {@link #BITMAP_NAME} on each successful | ||
| * backup; cleared on restore (the restored disk image has no bitmap, so the next backup | ||
| * must be a fresh full). When the VM has no detail, {@code decideChain} forces full. | ||
| */ | ||
| public static final String VM_ACTIVE_CHECKPOINT_ID = "nas.active_checkpoint_id"; | ||
|
|
||
| private NASBackupChainKeys() { | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mentioned this in a previous comment also. Can you please remove theRebaseBackupCommand and its wrapper as it is not being used now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also remove any occurrence of it in nasbackup.sh