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

Function find_anonymous_clone

lib/pengine/unpack.c:1037–1118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1035extern resource_t *create_child_clone(resource_t * rsc, int sub_id, pe_working_set_t * data_set);
1036
1037static resource_t *
1038find_anonymous_clone(pe_working_set_t * data_set, node_t * node, resource_t * parent, const char *rsc_id)
1039{
1040 GListPtr rIter = NULL;
1041 resource_t *rsc = NULL;
1042 gboolean skip_inactive = FALSE;
1043
1044 CRM_ASSERT(parent != NULL);
1045 CRM_ASSERT(parent->variant == pe_clone || parent->variant == pe_master);
1046 CRM_ASSERT(is_not_set(parent->flags, pe_rsc_unique));
1047
1048 /* Find an instance active (or partially active for grouped clones) on the specified node */
1049 pe_rsc_trace(parent, "Looking for %s on %s in %s", rsc_id, node->details->uname, parent->id);
1050 for(rIter = parent->children; rsc == NULL && rIter; rIter = rIter->next) {
1051 GListPtr nIter = NULL;
1052 GListPtr locations = NULL;
1053 resource_t *child = rIter->data;
1054
1055 child->fns->location(child, &locations, TRUE);
1056 if (locations == NULL) {
1057 pe_rsc_trace(child, "Resource %s, skip inactive", child->id);
1058 continue;
1059 }
1060
1061 for(nIter = locations; nIter && rsc == NULL; nIter = nIter->next) {
1062 node_t *childnode = nIter->data;
1063 if(childnode->details == node->details) {
1064 /* ->find_rsc() because we might be a cloned group */
1065 rsc = parent->fns->find_rsc(child, rsc_id, NULL, pe_find_clone);
1066 pe_rsc_trace(rsc, "Resource %s, active", rsc->id);
1067 }
1068
1069 /* Keep this block, it means we'll do the right thing if
1070 * anyone toggles the unique flag to 'off'
1071 */
1072 if(rsc && rsc->running_on) {
1073 crm_notice("/Anonymous/ clone %s is already running on %s",
1074 parent->id, node->details->uname);
1075 skip_inactive = TRUE;
1076 rsc = NULL;
1077 }
1078 }
1079
1080 g_list_free(locations);
1081 }
1082
1083 /* Find an inactive instance */
1084 if(skip_inactive == FALSE) {
1085 pe_rsc_trace(parent, "Looking for %s anywhere", rsc_id);
1086 for(rIter = parent->children; rsc == NULL && rIter; rIter = rIter->next) {
1087 GListPtr locations = NULL;
1088 resource_t *child = rIter->data;
1089
1090 child->fns->location(child, &locations, TRUE);
1091 if (locations == NULL) {
1092 /* ->find_rsc() because we might be a cloned group */
1093 rsc = parent->fns->find_rsc(child, rsc_id, NULL, pe_find_clone);
1094 pe_rsc_trace(parent, "Resource %s, empty slot", rsc->id);

Callers 1

unpack_find_resourceFunction · 0.85

Calls 4

is_not_setFunction · 0.85
create_child_cloneFunction · 0.85
safe_str_neqFunction · 0.85
is_setFunction · 0.85

Tested by

no test coverage detected