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

Function can_be_master

pengine/master.c:163–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161 } while(0)
162
163static node_t *
164can_be_master(resource_t * rsc)
165{
166 node_t *node = NULL;
167 node_t *local_node = NULL;
168 resource_t *parent = uber_parent(rsc);
169 clone_variant_data_t *clone_data = NULL;
170
171#if 0
172 enum rsc_role_e role = RSC_ROLE_UNKNOWN;
173
174 role = rsc->fns->state(rsc, FALSE);
175 crm_info("%s role: %s", rsc->id, role2text(role));
176#endif
177
178 if (rsc->children) {
179 GListPtr gIter = rsc->children;
180
181 for (; gIter != NULL; gIter = gIter->next) {
182 resource_t *child = (resource_t *) gIter->data;
183
184 if (can_be_master(child) == NULL) {
185 pe_rsc_trace(rsc, "Child %s of %s can't be promoted", child->id, rsc->id);
186 return NULL;
187 }
188 }
189 }
190
191 node = rsc->fns->location(rsc, NULL, FALSE);
192 if (node == NULL) {
193 pe_rsc_trace(rsc, "%s cannot be master: not allocated", rsc->id);
194 return NULL;
195
196 } else if (is_not_set(rsc->flags, pe_rsc_managed)) {
197 if (rsc->fns->state(rsc, TRUE) == RSC_ROLE_MASTER) {
198 crm_notice("Forcing unmanaged master %s to remain promoted on %s",
199 rsc->id, node->details->uname);
200
201 } else {
202 return NULL;
203 }
204
205 } else if (rsc->priority < 0) {
206 pe_rsc_trace(rsc, "%s cannot be master: preference: %d", rsc->id, rsc->priority);
207 return NULL;
208
209 } else if (can_run_resources(node) == FALSE) {
210 crm_trace( "Node cant run any resources: %s", node->details->uname);
211 return NULL;
212 }
213
214 get_clone_variant_data(clone_data, parent);
215 local_node = pe_hash_table_lookup(parent->allowed_nodes, node->details->id);
216
217 if (local_node == NULL) {
218 crm_err("%s cannot run on %s: node not allowed", rsc->id, node->details->uname);
219 return NULL;
220

Callers 1

master_colorFunction · 0.85

Calls 5

uber_parentFunction · 0.85
role2textFunction · 0.85
is_not_setFunction · 0.85
can_run_resourcesFunction · 0.85
pe_hash_table_lookupFunction · 0.85

Tested by

no test coverage detected