Skip to content

Commit

Permalink
Added pre-transfer check for OSP volume, waiting for 'available'
Browse files Browse the repository at this point in the history
Added a check before the OSP volume transfer begins, so that
we do not attempt to move the volume before it it is possible.
OSP volume has to be in the 'available' state before the transfer
begins. We are looping through TIMEOUT seconds (currently 300)
before giving up and erroring out.
  • Loading branch information
pericnenad committed Oct 14, 2019
1 parent f55344d commit 1d06725
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions wrapper/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,34 @@ def handle_finish(self, data, state):
state['internal']['disk_ids'])
logging.debug('Assumed volume list: %r', volumes)
return False
# Move volumes to destination project
for vol in volumes:
logging.info('Transfering volume: %s', vol)
logging.info('Transferring volume: %s', vol)
# Checking if volume is in available state
is_available = False
start_at = time.time()
while start_at + TIMEOUT > time.time():
volume_state = self._run_openstack([
'volume', 'show', '-f', 'value', '-c', 'status', vol,
], data)
if volume_state is None:
error('Unable to get volume state, quitting.')
return False
volume_state = volume_state.rstrip()
logging.info('Current volume state: %s.', volume_state)
if volume_state == 'available':
logging.info(
'Volume detached n first %s second(s), trasferring.',
time.time() - start_at)
is_available = True
break;
time.sleep(20)
if not is_available:
error(
'Volume did not get ready (available) '
'for transfer within %s seconds.',
TIMEOUT)
return False
# Move volumes to the destination project
transfer = self._run_openstack([
'volume', 'transfer', 'request', 'create',
'--format', 'json',
Expand Down

0 comments on commit 1d06725

Please sign in to comment.