-
Notifications
You must be signed in to change notification settings - Fork 23
Custom retention policy #2285
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
JeffreyDevloo
wants to merge
20
commits into
2.9.x
Choose a base branch
from
custom_retention_policy_jef
base: 2.9.x
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.
Open
Custom retention policy #2285
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3661db0
Objectify snapshots and buckets for better readable code
eafb8ea
Working custom retention policy.
70f9ca8
Refactor the configurable delete_snapshot
JeffreyDevloo 9e13c5c
Rebase on the latest 2.9.x
JeffreyDevloo bf2bcae
Fully convert a snapshot dict to an object
JeffreyDevloo 38e940f
Make consistency configurable
JeffreyDevloo e83b128
Add documentation
JeffreyDevloo 6301d18
Default policy did not skip the first 24 hours
JeffreyDevloo 6bcaa2c
Snapshots with a clone won't be deleted anymore
JeffreyDevloo ef50791
Add retention policy configurability
JeffreyDevloo cb89e5d
Think about more test scenarios
JeffreyDevloo a6e1d17
Test overlapping
JeffreyDevloo abb23be
Add more examples
JeffreyDevloo 9a73aaa
Add rtype for unittesting
JeffreyDevloo b36c6c2
Setup validation
JeffreyDevloo 33c01b5
Merge branch '2.9.x' into custom_retention_policy_jef
JeffreyDevloo 82f5c3f
Merge to latest 2.9 with snapshot delete exception handling
JeffreyDevloo 65c4c9b
Correct small format issue
JeffreyDevloo e73e151
Merge branch '2.9.x' into custom_retention_policy_jef
JeffreyDevloo 6624925
Merge 2.9 and add the concurrency change back into the refactored sna…
JeffreyDevloo 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
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,91 @@ | ||
### Snapshot management | ||
The Framework will, by default, create snapshots of every vDisk every hour | ||
(can be adjusted. See docs/scheduledtasks.md). | ||
|
||
To keep the snapshots manageable overtime, the Framework schedules a clean-up every day to enforce a retention policy. | ||
This automatic task will: | ||
- Create an overview of the all the snapshots for every volume | ||
- Skip the first 24 hours (allows the user to create as many snaphots as he wants daily) | ||
- Enforce the retention policy | ||
|
||
The default retention policy is: | ||
- a single snapshot is kept for the first 7 days after that | ||
- Prioritizes consistent snapshots over older ones for the first day in the policy | ||
(which is 2 days back, starting from now) | ||
- A single snapshot is kept for the 2nd, 3rd and 4th week to have a single snapshot of the week for the first month | ||
- All older snapshots are discarded | ||
|
||
#### Configuring the retention policy | ||
A retention policy can be configured so the scheduled task will enforce a different one from the default. | ||
|
||
It can be customized on: | ||
- Global level, enforces the policy to all vDisks within the cluster | ||
- VPool level, overrides the global level, enforce to all vDisks within the vPool | ||
- VDisk level, overrides the global and vPool level, enforce to this vDisk only | ||
|
||
The notation of the policy is a list containing policies. A policies consists minimally of `nr_of_snapshots`, which | ||
is the the number of snapshots to have over the given `nr_of_days`, and `nr_of_days` which is the number of days to span | ||
the `nr_of_snapshots` over. This notation allows for some fine grained control while also being easy to configure. | ||
Since we are working with days, *monthly and weekly policies will not follow the calendar days!* | ||
|
||
There are two additional options available: `consistency_first` | ||
which indicates that: | ||
- this policy has to search for the oldest consistent snapshot instead of oldest one | ||
- When no consistent snapshot was found, find the oldest snapshot | ||
|
||
If a policy interval spans multiple days, the `consistency_first_on` can be configured to narrow the days down | ||
to apply the `consistency_first` rules | ||
This options takes in a list of day numbers. | ||
|
||
|
||
If we were to write out the default retention policy, it would look like: | ||
``` | ||
[# one per day for the week and opt for a consistent snapshot for the first day | ||
{'nr_of_snapshots': 7, 'nr_of_days': 7, 'consistency_first': True, 'consistency_first_on': [1]}, | ||
# One per week for the rest of the month | ||
{'nr_of_snapshots': 3, 'nr_of_days': 21}] | ||
``` | ||
|
||
Configuring it on different levels can be done using the API: | ||
- Global level: POST to: `'/storagerouters/<storagerouter_guid>/global_snapshot_retention_policy'` | ||
- vPool level: POST to: `/vpools/<vpool_guid>/snapshot_retention_policy` | ||
- vDisk level: POST to: `/vdisks/<vdisk_guid>/snapshot_retention_policy` | ||
|
||
##### Examples: | ||
The examples simplify a week as 7 days and months as 4 * 7 days. | ||
|
||
I wish to keep hourly snapshots from the first week | ||
``` | ||
[{'nr_of_days': 7, # A week spans 7 days | ||
'nr_of_snapshots': 168}] # Keep 24 snapshot for every day for 7 days: 7 * 24 | ||
``` | ||
I wish to keep hourly snapshots from the first week and one for every week for the whole year | ||
``` | ||
[ # First policy | ||
{'nr_of_days': 7, # A week spans 7 days | ||
'nr_of_snapshots': 7 * 24}, # Keep 24 snapshot for every day for 7 days: 7 * 24 | ||
# Second policy | ||
{'nr_of_days': 7 * (52 - 1), # The first week is already covered by the previous policy, so 52 - 1 weeks remaining | ||
'nr_of_snapshots': 1 * (52 - 1)} | ||
] | ||
``` | ||
|
||
A production use case could be: | ||
``` | ||
[ # First policy - keep the first 24 snapshots | ||
{'nr_of_days': 1, | ||
'nr_of_snapshots': 24 }, | ||
# Second policy - Keep 4 snapshots a day for the remaining week (6 leftover days) | ||
{'nr_of_days': 6, | ||
'nr_of_snapshots': 4 * 6}, | ||
# Third policy - keep 1 snapshot per day for the 3 weeks to come | ||
{'nr_of_days': 3 * 7, | ||
'nr_of_snapshots': 3 * 7] | ||
# Fourth policy - keep 1 snapshot per week for the next 5 months | ||
{'nr_of_days': 4 * 7 * 5, # Use the week notation to avoid issues (4 * 7 days = month) | ||
'nr_of_snapshots': 5 * 7 | ||
# Fift policy - first 6 months are configured by now - Keep a snapshot every 6 month until 2 years have passed | ||
{'nr_of_days': (4 * 7) * (6 * 3), | ||
'nr_of_snapshots': 3} | ||
] | ||
``` |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.