mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Fix race condifiton where multiple hosts can try and create or delete (#39698)
the same volume, snapshot or hostgroup,
This commit is contained in:
parent
3832d04611
commit
8df02ac37e
3 changed files with 52 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Simon Dodsley (simon@purestorage.com)
|
||||
# (c) 2018, Simon Dodsley (simon@purestorage.com)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
@ -149,10 +149,13 @@ def get_target(module, array):
|
|||
def create_volume(module, array):
|
||||
"""Create Volume"""
|
||||
size = module.params['size']
|
||||
|
||||
changed = True
|
||||
if not module.check_mode:
|
||||
array.create_volume(module.params['name'], size)
|
||||
module.exit_json(changed=True)
|
||||
try:
|
||||
array.create_volume(module.params['name'], size)
|
||||
except:
|
||||
changed = False
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
|
||||
def copy_from_volume(module, array):
|
||||
|
@ -190,10 +193,17 @@ def update_volume(module, array):
|
|||
|
||||
def delete_volume(module, array):
|
||||
""" Delete Volume"""
|
||||
changed = True
|
||||
if not module.check_mode:
|
||||
array.destroy_volume(module.params['name'])
|
||||
if module.params['eradicate']:
|
||||
array.eradicate_volume(module.params['name'])
|
||||
try:
|
||||
array.destroy_volume(module.params['name'])
|
||||
if module.params['eradicate']:
|
||||
try:
|
||||
array.eradicate_volume(module.params['name'])
|
||||
except:
|
||||
changed = False
|
||||
except:
|
||||
changed = False
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue