Skip to content

Commit 80161d5

Browse files
committed
Low: fencer: Don't remove device if child is deleted
If the child of a primitive element representing a fencing device was deleted, and we didn't catch it earlier as instance_attributes or meta_attributes, then previously we would remove the fencing device. We should remove the device only if the primitive itself was deleted. By inspection, it looks like this would unregister a fencing device if one of its operations (op elements) were deleted. If we find that only a child of the primitive was deleted, fall through to the next if block -- that is, "continue" only if the primitive itself was deleted and we call stonith_device_remove(). Signed-off-by: Reid Wahl <[email protected]>
1 parent 0cf23c0 commit 80161d5

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

daemons/fenced/fenced_cib.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ update_cib_stonith_devices(const xmlNode *patchset)
258258

259259
const char *rsc_id = NULL;
260260
const char *end_quote = NULL;
261-
char *copy = NULL;
262261

263262
if ((strstr(primitive_xpath, PCMK_XE_INSTANCE_ATTRIBUTES) != NULL)
264263
|| (strstr(primitive_xpath, PCMK_XE_META_ATTRIBUTES) != NULL)) {
@@ -277,19 +276,22 @@ update_cib_stonith_devices(const xmlNode *patchset)
277276
continue;
278277
}
279278

280-
/* A primitive resource was removed. If it was a fencing resource,
281-
* it's faster to remove it directly than to run the scheduler and
282-
* update all device registrations.
283-
*/
284-
copy = strndup(rsc_id, end_quote - rsc_id);
285-
pcmk__assert(copy != NULL);
286-
stonith_device_remove(copy, true);
279+
if (strchr(end_quote, '/') == NULL) {
280+
/* The primitive element itself was deleted. If this was a
281+
* fencing resource, it's faster to remove it directly than to
282+
* run the scheduler and update all device registrations.
283+
*/
284+
char *copy = strndup(rsc_id, end_quote - rsc_id);
287285

288-
/* watchdog_device_update called afterwards
289-
to fall back to implicit definition if needed */
286+
pcmk__assert(copy != NULL);
287+
stonith_device_remove(copy, true);
290288

291-
free(copy);
292-
continue;
289+
/* watchdog_device_update called afterwards
290+
to fall back to implicit definition if needed */
291+
292+
free(copy);
293+
continue;
294+
}
293295
}
294296

295297
if (strstr(xpath, "/" PCMK_XE_RESOURCES)

0 commit comments

Comments
 (0)