Skip to content

Commit

Permalink
Deprecate pod annotation system
Browse files Browse the repository at this point in the history
Deprecating the annotation on the pod within the backup tarball since we
are going to stop using this annotation to identify which volumes are
restic backups.

Signed-off-by: Carlisia <carlisiac@vmware.com>
  • Loading branch information
Carlisia committed Jun 12, 2019
1 parent 74b5752 commit 0a1feaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 9 additions & 1 deletion pkg/restic/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ const (
InitContainer = "restic-wait"
DefaultMaintenanceFrequency = 24 * time.Hour

podAnnotationPrefix = "snapshot.velero.io/"
// Deprecated.
podAnnotationPrefix = "snapshot.velero.io/"

volumesToBackupAnnotation = "backup.velero.io/backup-volumes"
)

// PodHasSnapshotAnnotation returns true if the object has an annotation
// indicating that there is a restic snapshot for a volume in this pod,
// or false otherwise.
// Deprecated: we will stop using pod annotation to determine restic
// volumes to backup.
func PodHasSnapshotAnnotation(obj metav1.Object) bool {
for key := range obj.GetAnnotations() {
if strings.HasPrefix(key, podAnnotationPrefix) {
Expand All @@ -58,6 +62,8 @@ func PodHasSnapshotAnnotation(obj metav1.Object) bool {

// GetPodSnapshotAnnotations returns a map, of volume name -> snapshot id,
// of all restic snapshots for this pod.
// Deprecated: we will stop using pod annotation to determine restic
// volumes to backup.
func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string {
var res map[string]string

Expand All @@ -79,6 +85,8 @@ func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string {

// SetPodSnapshotAnnotation adds an annotation to a pod to indicate that
// the specified volume has a restic snapshot with the provided id.
// Deprecated: we will stop using pod annotation to determine restic
// volumes to backup.
func SetPodSnapshotAnnotation(obj metav1.Object, volumeName, snapshotID string) {
annotations := obj.GetAnnotations()

Expand Down
10 changes: 4 additions & 6 deletions site/docs/master/restic.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,12 @@ should be taken (`backup.velero.io/backup-volumes`)
- finds the pod volume's subdirectory within the above volume
- runs `restic backup`
- updates the status of the custom resource to `Completed` or `Failed`
1. As each `PodVolumeBackup` finishes, the main Velero process captures its restic snapshot ID and adds it as an annotation
to the copy of the pod JSON that's stored in the Velero backup. This will be used for restores, as seen in the next section.
1. As each `PodVolumeBackup` finishes, the main Velero process adds it to the Velero backup in a file named `<backup-name>-podvolumebackups.json.gz`. This file gets uploaded to object storage alongside the backup tarball. It will be used for restores, as seen in the next section.

### Restore

1. The main Velero restore process checks each pod that it's restoring for annotations specifying a restic backup
exists for a volume in the pod (`snapshot.velero.io/<volume-name>`)
1. When found, Velero first ensures a restic repository exists for the pod's namespace, by:
1. The main Velero restore process checks each pod that it's restoring from a previously created restic backup by iterating through the contents of the `<backup-name>-podvolumebackups.json.gz` file.
1. For each pod found, Velero first ensures a restic repository exists for the pod's namespace, by:
- checking if a `ResticRepository` custom resource already exists
- if not, creating a new one, and waiting for the `ResticRepository` controller to init/check it (note that
in this case, the actual repository should already exist in object storage, so the Velero controller will simply
Expand Down Expand Up @@ -319,4 +317,4 @@ on to running other init containers/the main containers.
[3]: https://github.com/heptio/velero/releases/
[4]: https://kubernetes.io/docs/concepts/storage/volumes/#local
[5]: http://restic.readthedocs.io/en/latest/100_references.html#terminology
[6]: https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
[6]: https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

0 comments on commit 0a1feaa

Please sign in to comment.