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

Enable toggling tagged flavors/images and small fixes #282

Merged
Show file tree
Hide file tree
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
20 changes: 17 additions & 3 deletions templates/instanceha/bin/instanceha.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
logging.debug(exc)

EVACUABLE_TAG = config["EVACUABLE_TAG"] if 'EVACUABLE_TAG' in config else "evacuable"
TAGGED_IMAGES = config["TAGGED_IMAGES"] if 'TAGGED_IMAGES' in config else "true"
TAGGED_FLAVORS = config["TAGGED_FLAVORS"] if 'TAGGED_FLAVORS' in config else "true"
DELTA = int(config["DELTA"]) if 'DELTA' in config else 30
POLL = int(config["POLL"]) if 'POLL' in config else 30
THRESHOLD = int(config["THRESHOLD"]) if 'THRESHOLD' in config else 50
Expand Down Expand Up @@ -126,8 +128,14 @@ def _custom_check():

def _host_evacuate(connection, host):
result = True
images = _get_evacuable_images(connection)
flavors = _get_evacuable_flavors(connection)
if 'true' in TAGGED_IMAGES:
images = _get_evacuable_images(connection)
else:
images = []
if 'true' in TAGGED_FLAVORS:
flavors = _get_evacuable_flavors(connection)
else:
flavors = []
servers = connection.servers.list(search_opts={'host': host, 'all_tenants': 1 })
servers = [server for server in servers if server.status in {'ACTIVE', 'ERROR', 'STOPPED'}]

Expand Down Expand Up @@ -419,7 +427,11 @@ def _check_kdump(stale_services):
#logging.debug("address is %s" % address[0])

# short hostname
name = socket.gethostbyaddr(address[0])[0].split('.', 1)[0]
try:
name = socket.gethostbyaddr(address[0])[0].split('.', 1)[0]
except Exception as msg:
logging.error('Failed reverse dns lookup for: %s - %s' % (address[0], msg))
continue

# fence_kdump checks if the magic number matches, so let's do it here too
if hex(struct.unpack('ii',data)[0]).upper() != FENCE_KDUMP_MAGIC.upper() :
Expand All @@ -443,6 +455,8 @@ def _check_kdump(stale_services):

if broken_computes:
stale_services = [service for service in stale_services if service.host in broken_computes]
else:
stale_services = []

return stale_services

Expand Down
2 changes: 2 additions & 0 deletions templates/instanceha/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
config:
EVACUABLE_TAG: "evacuable"
TAGGED_IMAGES: "true"
TAGGED_FLAVORS: "true"
SMART_EVACUATION: "false"
DELTA: "30"
POLL: "30"
Expand Down
Loading