Skip to content

Commit ec47089

Browse files
committed
fence_compute: Fix disabling force_down on node when action is on
When the action is on, the goal is to disable force_down for the nova-compute service on the node. However, we were only doing that if the nova-compute service was up; which is impossible if it's forced to be down... So just always disable force_down, and then, if it's up, do more things.
1 parent e67fcd4 commit ec47089

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

fence/agents/compute/fence_compute.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,23 @@ def set_power_status(_, options):
160160
return
161161

162162
if options["--action"] == "on":
163-
if get_power_status(_, options) != "on":
163+
try:
164+
# Forcing the host back up
165+
nova.services.force_down(
166+
options["--plug"], "nova-compute", force_down=False)
167+
except Exception as e:
168+
# In theory, if force_down=False fails, that's for the exact
169+
# same possible reasons that below with force_down=True
170+
# eg. either an incompatible version or an old client.
171+
# Since it's about forcing back to a default value, there is
172+
# no real worries to just consider it's still okay even if the
173+
# command failed
174+
logging.info("Exception from attempt to force "
175+
"host back up via nova API: "
176+
"%s: %s" % (e.__class__.__name__, e))
177+
if get_power_status(_, options) == "on":
164178
# Forcing the service back up in case it was disabled
165179
nova.services.enable(options["--plug"], 'nova-compute')
166-
try:
167-
# Forcing the host back up
168-
nova.services.force_down(
169-
options["--plug"], "nova-compute", force_down=False)
170-
except Exception as e:
171-
# In theory, if force_down=False fails, that's for the exact
172-
# same possible reasons that below with force_down=True
173-
# eg. either an incompatible version or an old client.
174-
# Since it's about forcing back to a default value, there is
175-
# no real worries to just consider it's still okay even if the
176-
# command failed
177-
logging.info("Exception from attempt to force "
178-
"host back up via nova API: "
179-
"%s: %s" % (e.__class__.__name__, e))
180180
else:
181181
# Pretend we're 'on' so that the fencing library doesn't loop forever waiting for the node to boot
182182
override_status = "on"

0 commit comments

Comments
 (0)