MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / get_failcount

Function get_failcount

lib/pengine/utils.c:1332–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1330}
1331
1332int
1333get_failcount(node_t * node, resource_t * rsc, int *last_failure, pe_working_set_t * data_set)
1334{
1335 char *key = NULL;
1336 const char *value = NULL;
1337 struct fail_search search = { rsc, 0, 0, NULL };
1338
1339 /* Optimize the "normal" case */
1340 key = crm_concat("fail-count", rsc->clone_name?rsc->clone_name:rsc->id, '-');
1341 value = g_hash_table_lookup(node->details->attrs, key);
1342 search.count = char2score(value);
1343 crm_trace("%s = %s", key, value);
1344 free(key);
1345
1346 if(value) {
1347 key = crm_concat("last-failure", rsc->clone_name?rsc->clone_name:rsc->id, '-');
1348 value = g_hash_table_lookup(node->details->attrs, key);
1349 search.last = crm_int_helper(value, NULL);
1350 free(key);
1351
1352 /* This block is still relevant once we omit anonymous instance numbers
1353 * because stopped clones wont have clone_name set
1354 */
1355 } else if (is_not_set(rsc->flags, pe_rsc_unique)) {
1356 search.rsc = uber_parent(rsc);
1357 search.key = clone_strip(rsc->id);
1358
1359 g_hash_table_foreach(node->details->attrs, get_failcount_by_prefix, &search);
1360 free(search.key);
1361 }
1362
1363 if (search.count != 0 && search.last != 0 && last_failure) {
1364 *last_failure = search.last;
1365 }
1366
1367 if (search.count != 0 && search.last != 0 && rsc->failure_timeout) {
1368 if (search.last > 0) {
1369 time_t now = get_timet_now(data_set);
1370
1371 if (now > (search.last + rsc->failure_timeout)) {
1372 crm_debug("Failcount for %s on %s has expired (limit was %ds)",
1373 search.rsc->id, node->details->uname, rsc->failure_timeout);
1374 search.count = 0;
1375 }
1376 }
1377 }
1378
1379 if (search.count != 0) {
1380 char *score = score2char(search.count);
1381
1382 crm_info("%s has failed %s times on %s", search.rsc->id, score, node->details->uname);
1383 free(score);
1384 }
1385
1386 return search.count;
1387}
1388
1389gboolean

Callers 5

print_rsc_summaryFunction · 0.85
process_orphan_resourceFunction · 0.85
unpack_rsc_opFunction · 0.85
check_actions_forFunction · 0.85
common_apply_stickinessFunction · 0.85

Calls 8

crm_concatFunction · 0.85
char2scoreFunction · 0.85
crm_int_helperFunction · 0.85
is_not_setFunction · 0.85
uber_parentFunction · 0.85
clone_stripFunction · 0.85
get_timet_nowFunction · 0.85
score2charFunction · 0.85

Tested by

no test coverage detected