Skip to content

Commit

Permalink
Merge pull request #282 from lmiccini/kdump-emtpy-computes
Browse files Browse the repository at this point in the history
Enable toggling tagged flavors/images and small fixes
  • Loading branch information
openshift-merge-bot[bot] authored Oct 8, 2024
2 parents 3a3a6ce + ae42ac0 commit d1d7314
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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

0 comments on commit d1d7314

Please sign in to comment.