rackops/rackspace-cloud-backup — pull request #7 by RSTJNII (2014-01-10 01:05:46+00:00)
Title: Locking refactor

Only two changes here:
* I refactored how we handle client registration
* I refactored and overhauled how jobs are handled

The client registration refactor introduces a Python wrapper script that reads bootstrap.json for the IsRegistered key. If IsRegistered == True, it exits succesfully. If IsRegistered == False it registers DriveClient and bounces the daemon. This could probably be "chefified" better by pulling the read into Chef and calling the appropriate LWRPs if IsRegistered if False, but I'm going to leave that for another refactor. (Why yes, I did think of that right after writing and testing the wrapper, how could you tell?) This change eliminates the lock file, and will allow clients with a lock file and a broken registration to fix themselves.

The job overhaul is more in-depth. Instead of having create_backup.py write out a bash script with curls, I made it write out a JSON config file with all the details needed to start a job. This script is idempotent and will not recreate existing jobs or rewrite the file if it is unchanged. One key point, though, is that the idempotence comes from it reading the existing config in and comparing it, it does not check existing datasets against the API and as such will create duplicate jobs if the config is blown away. Again, I leave that to another refactor. This change allows Chef to update the backup sets as the role attributes change, the previous version was a one-shot-lock with no future changes.

run_backup is now a python script that reads in the JSON config file and minizes API calls. It only makes one auth request and makes the wakeup request to resolve issue #4. As it is intended to be a cron job it only writes to stdout with debug on, normal status messages go to syslog.

Please wait to merge until tomorrow morning, I want to verify the new run_backups script runs from cron. I'm submitting tonight so code review can get a head start.