Skip to content

Commit

Permalink
Add exit-on-error feature to volume and peer sections
Browse files Browse the repository at this point in the history
User can exit gdeploy if volume creation fails by adding the flag
ignore_vg_errors=no in the [vg] section.

And exit gdeploy if peer probe failed by setting ignore_peer_errors=no
in the [peer] section.
  • Loading branch information
sac committed Aug 17, 2016
1 parent c1b2f59 commit b30228d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gdeployfeatures/peer/peer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"probe": {
"options": [
{
"required": "false",
"name": "ignore_peer_errors",
"default": "yes"
}
]
},
Expand All @@ -13,6 +16,11 @@
"name": "force",
"required": "false",
"default": "no"
},
{
"required": "false",
"name": "ignore_peer_errors",
"default": "yes"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions gdeployfeatures/peer/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
def peer_probe(section_dict):
if not check_for_host_names():
return False, False
Global.ignore_errors = section_dict.get('ignore_peer_errors')
to_be_probed = Global.hosts + Global.brick_hosts
to_be_probed = sorted(set(to_be_probed))
section_dict['to_be_probed'] = to_be_probed
return section_dict, defaults.PROBE_YML

def peer_detach(section_dict):
Global.ignore_errors = section_dict.get('ignore_peer_errors')
section_dict['hosts'] = Global.hosts
if not check_for_host_names():
return False, False
Expand Down
35 changes: 35 additions & 0 deletions gdeployfeatures/volume/volume.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
"required": "false",
"name": "glusterfs:volfile_server",
"default": "localhost"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand All @@ -97,6 +102,11 @@
{
"required": "true",
"name": "volname"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand All @@ -118,6 +128,11 @@
"required": "false",
"name": "force",
"default": "no"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand Down Expand Up @@ -156,6 +171,11 @@
"required": "false",
"name": "replica_count",
"default": "0"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand All @@ -178,6 +198,11 @@
"required": "false",
"name": "force",
"default": "no"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand Down Expand Up @@ -233,6 +258,11 @@
"required": "false",
"name": "glusterfs:volfile_server",
"default": "localhost"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
},
Expand All @@ -241,6 +271,11 @@
{
"required": "true",
"name": "volname"
},
{
"required": "false",
"name": "ignore_volume_errors",
"default": "yes"
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions gdeployfeatures/volume/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

def volume_create(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
if not section_dict.get('brick_dirs'):
Expand Down Expand Up @@ -156,24 +157,28 @@ def check_brick_name_format(brick_name):

def volume_delete(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
return section_dict, defaults.VOLDEL_YML

def volume_start(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
return section_dict, defaults.VOLUMESTART_YML

def volume_stop(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
return section_dict, defaults.VOLSTOP_YML

def volume_add_brick(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
yamls = []
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
Expand All @@ -187,13 +192,15 @@ def volume_add_brick(section_dict):

def volume_remove_brick(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
section_dict['old_bricks'] = section_dict.pop('bricks')
return section_dict, defaults.REMOVEBRK_YML

def volume_rebalance(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
return section_dict, [defaults.VOLUMESTART_YML,
Expand All @@ -202,6 +209,7 @@ def volume_rebalance(section_dict):

def volume_set(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
keys = section_dict.get('key')
Expand All @@ -221,6 +229,7 @@ def volume_set(section_dict):

def volume_smb_setup(section_dict):
global helpers
Global.ignore_errors = section_dict.get('ignore_volume_errors')
section_dict['volname'] = helpers.split_volume_and_hostname(
section_dict['volname'])
SMB_DEFAULTS = {
Expand Down

0 comments on commit b30228d

Please sign in to comment.