vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.52k stars 1.38k forks source link

execution order of hooks #3978

Open ThomasSteinbach opened 3 years ago

ThomasSteinbach commented 3 years ago

Describe the problem/challenge you have

A backup could require a lifecycle of actions to be done. For instance backing up Nextcloud would require following actions in order:

  1. in the app container set Nextclouds maintainance mode to 'on' (pre-backup hook no. 1)
  2. in the database container do a database backup with pg_dump or mysqldump (pre-backup hook no 2)
  3. doing the velero backup of k8s objects and volumes
  4. in the database container remove the database backup file (post-backup hook no 1)
  5. in the app container set Nextclouds maintainance mode to 'off' (post-backup hook 1 - could run in parallel with step 4)

However currently Velero hooks run rather random. Every pod backup has its own pre-/post- hook but because the pod backups run in parallel you cannot ensure that - regarding the example above - the database dump is synchronized with the maintainance mode-

Describe the solution you'd like

It would be nice (and required) for hooks having a global sort order in which they were executed. Hooks should be executed in order and only after a previous hook finishes.

Environment:

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

reasonerjt commented 3 years ago

@ThomasSteinbach

So 4 and 5 can be solved by the "post-backup hook"

As for 1 and 2, based on my understanding, you may handle that via adding a Backup Item Action plugin?
https://velero.io/docs/v1.6/custom-plugins/

ThomasSteinbach commented 2 years ago

@reasonerjt I think you misunderstood my requirement. Of course, step 4 and 5 can be solved by post-backup hooks and step 1 and 2 by pre-backup hooks. I already wrote that in braces behind the steps objectives.

What my requirement is about, is to run those steps in order. That is currently not possible, because hooks for different resources are running asychronous.

Or in other words: It would be nice having global dependency definitions for hooks. Such that you can say define hook X just after hooks with labels d, e and f have finished.