xorpaul/g10k

add ZFS snapshot feature to minimze risks and downtime

maxadamo opened this issue · 3 comments

I have created this tool: https://github.com/maxadamo/g10k-zfs
The tool does the following:
- creates ZFS snapshots on an existing ZFS pool
- rotates in a loop two snapshots, called Even and Odd
- mounts either Even or Odd depending on the rotation position

  • creates a new ZFS r/o snapshot whose name contains a timestamp (i.e.: code/g10k@Date-06-Jan-2020_Time-16.28.42)
  • unmount the currently mounted snapshot
  • mount the new snapshot
  • deletes the old snapshot

This prevents leaving the code in a bad status and helps minimizing the downtime (replacing the snapshot takes few millisecond and happens only if the code was checked out successfully).

I am not sure about the question that I need to ask you, because there are actually few different options available:

  1. fully integrate g10k-zfs into g10k with PR (it is version 0.1... it needs a break-in period first). I can remove docopt (which you are not using) and try to harmonize my code with g10k code.
  2. we may think that the snapshot feature is not in scope with g10k. Thus, I saw initially in your code the following function: checkForAndExecutePostrunCommand(). Not clear how this works, and if it works, but g10k-zfs can be run indeed as Postrun command.
  3. of course, I can run g10k first, and if g10k is successful I run g10k-zfs which will replace the snapshot

Starting the New Year with guns blazing 😏

Cool idea, I'm also looking for a way to check the whole g10k run first before shipping or using the populated Puppet environment code elsewhere.

My approach would have been a staging directory somewhere else and the simply link or rsync it to the final destination.

I'll also have a look into integrating your ZFS code into g10k directly, but you're also welcome to provide a PR of course 😅

I think if I remove docopt the code left is tiny.... I should be able to provide a file zfs.go, which can be added to this package.
Then. it will be matter of adding few command switches for it.

I'll think about the symlink... it's easier for people who don't want to setup ZFS on their servers... and it would have been easier for me 😢

I had time to think a little bit. Symlink is also good, but you'll have one copy at time, and you need to clone again from scratch, because the other copy is in use already.
With ZFS you have a staging copy (read/write) which is never mounted and can be changed.
I'll try to work for the ZFS PR .... and anyway, it will be optional for the users.