Do not delete schedule if nova returns 404

Currently, if nova returns 404 qonos worker assumes the instance
does not exist. However, this inference might not be appropriate
in case of intermittent issues leading to potential customer data
loss.

Hence, the schedule will only be deleted through the nova extension.

Also, adds some logging.
Merge pull request #298 from komawar/dont-delete-schedules-on-404

Do not delete schedule if nova returns 404
fix nova_client creation logic to use right tenant

Co-authored-by: Amala Basha <amala.alungal@rackspace.com>
fix sqlalchemy's job.update() call to handle race condition

- the current query(job).update() method of sqlalchemy doesn't consider
  the version_id column introduced to handle race condition (Optimistic
Offline Lock).
- modified the update call to use session.add(job) & session.flush(job)
  so that sqlalchemy can use the optimistic offline lock feature using
job table's version id column.
- added test to ensure the version_id column is used as expected.
- fixed a minor pep8 issue on test_jobs
Merge pull request #300 from venkateshsampath/fix_nova_client_factory

fix nova_client creation logic to use right tenant
Merge pull request #296 from venkateshsampath/rm1348_sqlalchemy_fix

fix sqlalchemy's job.update() call to handle race condition
functional tests for Snapshot Job Processor

grouped tests under following classes,
- TestSnapshotProcessorJobProcessing
- TestSnapshotProcessorPolling
- TestSnapshotProcessorRetentionProcessing
- TestSnapshotProcessorNotifications
- TestSnapshotProcessorImageName

Co-authored-by: Sridevi Koushik <sridevi.koushik@rackspace.com>
Merge pull request #297 from venkateshsampath/test_job_processor

Functional Tests for Snapshot Job Processor
fix snapshot.get_image_status logic

- the snapshot.get_image_status method is used for two purposes.
1. to determine if a new image for the job needs to be created.
2. poll to check if the snapshot image is successfully created and
uploaded.
- extracted the logic that determine if new image needs to be created
  (_get_image_id).
- extracted the logic that polls for the image status.
- on exception, in both cases, update the job status to ERROR with next timeout
- wrap and re-raise the original exception as PollingException
- removed the assumption of image may be KILLED on exception.
- this fix also addresses one of the bug related to creation of
  duplicate scheduled images.
Merge pull request #301 from venkateshsampath/fix_get_image_status_logic

fix snapshot.get_image_status logic
Workers should cleanly shutdown quickly

The worker handles SIGHUP and SIGTERM, but it only affects the
job polling loop and not the processor. This patch passes the
stop notification to the processor so it can set the job to
TIMED_OUT and quickly and cleanly shut down rather than waiting
for the current job to finish processing.
Merge pull request #303 from rackerlabs/rm5870-graceful-shutdown-rebase

Workers should cleanly shutdown quickly
Update default backoff value to 1
Merge pull request #309 from rackerlabs/change-default-backoff

Update default backoff value to 1
Add missing foreign keys

Add missing foreign keys to job_metadata and schedule_metadata. Check
whether the foreign keys are existing. If not, then add.