Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pre-transfer check for OSP volume, waiting for 'available' #59

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 in %s second(s), trasferring.',
int(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