Skip to content
Browse files

Merge branch 'dev/juphoff/evac' into dev/juphoff/evac-test

Conflicts:
	cluster/handlers.c
	util/misc.c
	util/misc.h
  • Loading branch information...
2 parents 8b5f55d + a5903ac commit eec6bcdb62e7a9e63d3954682301b100f18d7c68 @juphoff juphoff committed Apr 9, 2013
Showing with 89 additions and 26 deletions.
  1. +57 −22 cluster/handlers.c
  2. +1 −1 cluster/handlers.h
  3. +29 −2 util/misc.c
  4. +2 −1 util/misc.h
View
79 cluster/handlers.c
@@ -2375,7 +2375,6 @@ int refresh_instances(ncMetadata * pMeta, int timeout, int dolock)
EUCA_FREE(ip);
}
- //#if 0
if ((myInstance->ccnet.publicIp[0] != '\0' && strcmp(myInstance->ccnet.publicIp, "0.0.0.0"))
&& (myInstance->ncnet.publicIp[0] == '\0' || !strcmp(myInstance->ncnet.publicIp, "0.0.0.0"))) {
// CC has network info, NC does not
@@ -2387,7 +2386,6 @@ int refresh_instances(ncMetadata * pMeta, int timeout, int dolock)
LOGWARN("could not send AssignAddress to NC\n");
}
}
- //#endif
refresh_instanceCache(myInstance->instanceId, myInstance);
if (!strcmp(myInstance->state, "Extant")) {
@@ -2985,6 +2983,7 @@ int schedule_instance_roundrobin(virtualMachine * vm, int *outresid)
return (0);
}
+
//!
//! @param[in] instance
//! @param[in] includeNodes
@@ -3000,48 +2999,82 @@ int schedule_instance_roundrobin(virtualMachine * vm, int *outresid)
//!
//! @note
//!
-int schedule_instance_migration(ncInstance *instance, char **includeNodes, char **excludeNodes, int includeNodeCount, int excludeNodeCount, int inresid, int *outresid)
+int schedule_instance_migration(ncInstance *instance, char **includeNodes, char **excludeNodes, int includeNodeCount, int excludeNodeCount, int inresid, int *outresid, ccResourceCache *resourceCacheLocal)
{
int ret = 0;
- LOGDEBUG("invoked\n");
+ LOGDEBUG("invoked: include=%d, exclude=%d\n", includeNodeCount, excludeNodeCount);
if (includeNodes && excludeNodes) {
LOGERROR("[%s] migration scheduler cannot be called with both nodes to include and nodes to exclude; the options are mutually exclusive.\n", instance->instanceId);
ret = 1;
goto out;
}
-
- // This is easy: we can keep calling the round-robin scheduler until we get a node we like.
- if (config->schedPolicy == SCHEDROUNDROBIN) {
+ // Trivial case: migration to a specific node:
+ if (includeNodeCount == 1) {
+ LOGINFO("[%s] attempting to schedule migration to specific node: %s\n", instance->instanceId,
+ includeNodes[0]);
+ if (!strcmp(instance->migration_src, includeNodes[0])) {
+ LOGERROR("[%s] can't schedule SAME-NODE migration from %s to %s\n", instance->instanceId,
+ instance->migration_src, includeNodes[0]);
+ ret = 1;
+ goto out;
+ }
+ ret = schedule_instance(&(instance->params), includeNodes[0], outresid);
+ } else if (config->schedPolicy == SCHEDROUNDROBIN) {
+ // This is relatively easy: we can keep calling the round-robin scheduler until we get a node we like.
int first_try = -1; // To break loops.
int done = 0;
int found = 0;
while (!done) {
ret = schedule_instance_roundrobin(&(instance->params), outresid);
- if (*outresid != inresid) {
- // Found a destination node that's not the source node.
- LOGDEBUG("[%s] scheduled: src_index=%d, dst_index=%d\n", instance->instanceId, inresid, *outresid);
- done++;
- found++;
- } else {
+
+ if (first_try == -1) {
+ first_try = *outresid;
+ } else if (*outresid == first_try) {
+ LOGERROR("[%s] has looped around without scheduling a destination, breaking loop\n", instance->instanceId);
+ // We've already been here. We know this one won't work.
+ //done++;
+ break;
+ }
+
+ if (*outresid == inresid) {
// Tried to schduled to the source node, so retry.
- LOGDEBUG("[%s] can't schedule src_index=%d == dst_index=%d, trying again...\n",
- instance->instanceId, inresid, *outresid);
- if (first_try == -1) {
- first_try = *outresid;
- } else if (*outresid == first_try) {
- LOGERROR("[%s] has looped around without scheduling a destination, breaking loop\n", instance->instanceId);
+ LOGDEBUG("[%s] can't schedule src_index=%d == dst_index=%d (%s > %s), trying again...\n",
+ instance->instanceId, inresid, *outresid, instance->migration_src,
+ resourceCacheLocal->resources[*outresid].hostname);
+ } else if (check_for_string_in_list(resourceCacheLocal->resources[*outresid].hostname,
+ excludeNodes, excludeNodeCount)) {
+ // Exclusion list takes priority over inclusion list.
+ LOGDEBUG("[%s] can't schedule src_index=%d, dst_index=%d because node %s is in destination-exclusion list\n",
+ instance->instanceId, inresid, *outresid, resourceCacheLocal->resources[*outresid].hostname);
+ } else if (includeNodeCount) {
+ if (!check_for_string_in_list(resourceCacheLocal->resources[*outresid].hostname,
+ includeNodes, includeNodeCount)) {
+ LOGDEBUG("[%s] can't schedule src_index=%d, dst_index=%d because node %s is not in destination-inclusion list\n",
+ instance->instanceId, inresid, *outresid, resourceCacheLocal->resources[*outresid].hostname);
+ } else {
+ LOGDEBUG("[%s] scheduled: src_index=%d, dst_index=%d (%s > %s) -- destination node is in inclusion list\n",
+ instance->instanceId, inresid, *outresid, resourceCacheLocal->resources[*outresid].hostname, instance->migration_src);
done++;
+ found++;
}
+ } else if (*outresid != inresid) {
+ // Found a destination node that's not the source node.
+ LOGDEBUG("[%s] scheduled: src_index=%d, dst_index=%d (%s > %s)\n", instance->instanceId, inresid, *outresid, instance->migration_src, resourceCacheLocal->resources[*outresid].hostname);
+ done++;
+ found++;
}
}
if (!found) {
ret = 1;
}
+ } else if ((config->schedPolicy == SCHEDGREEDY) || (config->schedPolicy == SCHEDPOWERSAVE)) {
+ //
+ ret = schedule_instance_greedy(&(instance->params), outresid);
} else {
// If not ROUNDROBIN, fall back to configured scheduling policy and hope (for now).
- // FIXME: (Why should be obvious.)
+ // FIXME: This doesn't avoid scheduling source nodes or handle includeNodes/excludeNodes.
ret = schedule_instance(&(instance->params), NULL, outresid);
}
@@ -4265,10 +4298,12 @@ int doMigrateInstances(ncMetadata * pMeta, char *sourceNode, char *instanceId, c
for (int idx = 0; idx < found_instances; idx++) {
if (allowHosts) {
// destinationHosts is whitelist, pass as includeNodes.
- rc = schedule_instance_migration(nc_instances[idx], destinationNodes, NULL, destinationNodeCount, 0, src_index, &dst_index);
+ LOGDEBUG("[%s] scheduling instance with a destination-inclusion list\n", nc_instances[idx]->instanceId);
+ rc = schedule_instance_migration(nc_instances[idx], destinationNodes, NULL, destinationNodeCount, 0, src_index, &dst_index, &resourceCacheLocal);
} else {
+ LOGDEBUG("[%s] scheduling instance with a destination-exclusion list\n", nc_instances[idx]->instanceId);
// destinationHosts is blacklist, pass as excludeNodes.
- rc = schedule_instance_migration(nc_instances[idx], NULL, destinationNodes, 0, destinationNodeCount, src_index, &dst_index);
+ rc = schedule_instance_migration(nc_instances[idx], NULL, destinationNodes, 0, destinationNodeCount, src_index, &dst_index, &resourceCacheLocal);
}
if (rc || (dst_index == -1)) {
View
2 cluster/handlers.h
@@ -397,7 +397,7 @@ int schedule_instance(virtualMachine * vm, char *targetNode, int *outresid);
int schedule_instance_roundrobin(virtualMachine * vm, int *outresid);
int schedule_instance_explicit(virtualMachine * vm, char *targetNode, int *outresid);
int schedule_instance_greedy(virtualMachine * vm, int *outresid);
-int schedule_instance_migration(ncInstance *instance, char **includeNodes, char **excludeNodes, int includeNodeCount, int excludeNodeCount, int inresid, int *outresid);
+int schedule_instance_migration(ncInstance *instance, char **includeNodes, char **excludeNodes, int includeNodeCount, int excludeNodeCount, int inresid, int *outresid, ccResourceCache *resourceCacheLocal);
int doRunInstances(ncMetadata * pMeta, char *amiId, char *kernelId, char *ramdiskId, char *amiURL, char *kernelURL, char *ramdiskURL, char **instIds,
int instIdsLen, char **netNames, int netNamesLen, char **macAddrs, int macAddrsLen, int *networkIndexList, int networkIndexListLen,
char **uuids, int uuidsLen, int minCount, int maxCount, char *accountId, char *ownerId, char *reservationId, virtualMachine * ccvm,
View
31 util/misc.c
@@ -407,14 +407,14 @@ pid_t timewait(pid_t pid, int *status, int timeout_sec)
return (rc);
}
-//!
+//!
//! Attempt to kill a process. This could wait up to 3 seconds to confirm/infirm the
//! success of the kill operations.
//!
//! @param pid the process identifier for the process we're terminating
//!
//! @return EUCA_OK on success or EUCA_ERROR on failure
-//!
+//!
int killwait(pid_t pid)
{
int status = 0;
@@ -2667,6 +2667,33 @@ int get_remoteDevForNC(const char *the_iqn, const char *remoteDev, char *remoteD
return ret;
}
+//!
+//! @param[in] string string
+//! @param[in] list list of strings
+//! @param[in] count number of entries in list
+//!
+//!
+//! @return FALSE if string not in list of strings, TRUE if string is in list.
+//!
+
+int check_for_string_in_list (char *string, char **list, int count)
+{
+ if (!string || !count || !list || !(*list)) {
+ return FALSE;
+ }
+
+ for (int i = 0; i < count; i++) {
+ if (!list[i]) {
+ return FALSE;
+ }
+ if (!strcmp(string, list[i])) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
#ifdef _UNIT_TEST
//!
//! Main entry point of the application
View
3 util/misc.h
@@ -196,7 +196,8 @@ int get_blkid(const char *dev_path, char *uuid, unsigned int uuid_size);
char parse_boolean(const char *s);
int drop_privs(void);
int timeshell(char *command, char *stdout_str, char *stderr_str, int max_size, int timeout);
-int get_remoteDevForNC(const char *the_iqn, const char *remoteDev, char *remoteDevForNC, int remoteDevForNCLen);
+int get_remoteDevForNC(const char * the_iqn, const char * remoteDev, char * remoteDevForNC, int remoteDevForNCLen);
+int check_for_string_in_list (char *string, char **list, int count);
/*----------------------------------------------------------------------------*\
| |

0 comments on commit eec6bcd

Please sign in to comment.
Something went wrong with that request. Please try again.