Permalink
Browse files

1.) initial implementation of vmware/CC pairing algo in the cc

2.) disable fault DB storage, temporarily
3.) initial bfebs implementation on Xen
  • Loading branch information...
Daniel Nurmi
Daniel Nurmi committed Dec 5, 2011
2 parents 10f855c + 441884f commit 88d1662c70f68a336967cb7f5ea53694f5f50bcc
@@ -501,7 +501,9 @@ public CheckException apply( final ServiceStatusType input ) {
}
return Lists.newArrayList( );
}
-
+ public static void persist( final CheckException errors ) {
+ }
+/*
public static void persist( final CheckException errors ) {
if ( errors != null && Hosts.isCoordinator( ) ) {
try {
@@ -521,4 +523,5 @@ public static void persist( final CheckException errors ) {
}
}
}
+*/
}
@@ -228,7 +228,7 @@ public static void populateServices( ServiceConfiguration config, BaseMessage ms
for ( ServiceConfiguration s : c.services( ) ) {
if ( !serviceList.contains( s ) && State.DISABLED.apply( s ) ) {
msg.get_disabledServices( ).add( typeMapper.apply( s ) );
- } else if ( !serviceList.contains( s ) && State.DISABLED.apply( s ) ) {
+ } else if ( !serviceList.contains( s ) && State.NOTREADY.apply( s ) ) {
msg.get_notreadyServices( ).add( typeMapper.apply( s ) );
}
}
@@ -245,7 +245,7 @@ public static void populateServices( ServiceConfiguration config, BaseMessage ms
} else {
if ( !serviceList.contains( s ) && State.DISABLED.apply( s ) ) {
msg.get_disabledServices( ).add( typeMapper.apply( s ) );
- } else if ( !serviceList.contains( s ) && State.DISABLED.apply( s ) ) {
+ } else if ( !serviceList.contains( s ) && State.NOTREADY.apply( s ) ) {
msg.get_notreadyServices( ).add( typeMapper.apply( s ) );
}
}
View
@@ -115,7 +115,6 @@ int doDescribeServices(ncMetadata *ccMeta, serviceInfoType *serviceIds, int serv
}
*/
sem_mywait(CONFIG);
- logprintfl(EUCADEBUG, "MEH: %s\n", config->ccStatus.serviceId.name);
if (!strcmp(config->ccStatus.serviceId.name, "self")) {
for (i=0; i<serviceIdsLen; i++) {
logprintfl(EUCADEBUG, "DescribeServices(): received input serviceId[%d]\n", i);
@@ -203,11 +202,16 @@ int doStartService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "StartService(): attempt to start a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "StartService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "StartService(): starting service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(DISABLED);
}
- config->kick_enabled = 0;
- ccChangeState(DISABLED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "StartService(): done\n");
@@ -229,11 +233,16 @@ int doStopService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "StopService(): attempt to stop a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "StopService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "StopService(): stopping service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(STOPPED);
}
- config->kick_enabled = 0;
- ccChangeState(STOPPED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "StopService(): done\n");
@@ -255,9 +264,13 @@ int doEnableService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "EnableService(): attempt to enable a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "EnableService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
} else if (config->ccState != ENABLED) {
+ logprintfl(EUCADEBUG, "EnableService(): enabling service\n");
+ ret=0;
// tell monitor thread to (re)enable
config->kick_monitor_running = 0;
config->kick_network = 1;
@@ -267,17 +280,19 @@ int doEnableService(ncMetadata *ccMeta) {
}
sem_mypost(CONFIG);
- // wait for a minute to make sure CC is running again
- done=0;
- for (i=0; i<60 && !done; i++) {
- sem_mywait(CONFIG);
- if (config->kick_monitor_running) {
- done++;
- }
- sem_mypost(CONFIG);
- if (!done) {
- logprintfl(EUCADEBUG, "EnableService(): waiting for monitor to re-initialize (%d/60)\n", i);
- sleep(1);
+ if (config->ccState == ENABLED) {
+ // wait for a minute to make sure CC is running again
+ done=0;
+ for (i=0; i<60 && !done; i++) {
+ sem_mywait(CONFIG);
+ if (config->kick_monitor_running) {
+ done++;
+ }
+ sem_mypost(CONFIG);
+ if (!done) {
+ logprintfl(EUCADEBUG, "EnableService(): waiting for monitor to re-initialize (%d/60)\n", i);
+ sleep(1);
+ }
}
}
@@ -300,11 +315,16 @@ int doDisableService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "DisableService(): attempt to disable a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "DisableService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "DisableService(): disabling service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(DISABLED);
}
- config->kick_enabled = 0;
- ccChangeState(DISABLED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "DisableService(): done\n");
View
@@ -72,6 +72,7 @@ int doStartService(ncMetadata *ccMeta);
int doStopService(ncMetadata *ccMeta);
int doEnableService(ncMetadata *ccMeta);
int doDisableService(ncMetadata *ccMeta);
+int doShutdownService(ncMetadata *ccMeta);
int validCmp(ccInstance *inst, void *in);
int instNetParamsSet(ccInstance *inst, void *in);
View
@@ -2812,6 +2812,8 @@ int ccCheckState() {
char localDetails[1024];
int ret=0;
char cmd[MAX_PATH];
+ char buri[MAX_PATH], uriType[32], bhost[MAX_PATH], path[MAX_PATH], curi[MAX_PATH], chost[MAX_PATH];
+ int port, done=0, i, j, rc;
if (!config) {
return(1);
@@ -2856,10 +2858,34 @@ int ccCheckState() {
// network
+ // broker pairing algo
+ for (i=0; i<16; i++) {
+ int j;
+ if (strlen(config->notreadyServices[i].type)) {
+ if (!strcmp(config->notreadyServices[i].type, "vmwarebroker")) {
+ for (j=0; j<8; j++) {
+ if (strlen(config->notreadyServices[i].uris[j])) {
+ logprintfl(EUCADEBUG, "ccCheckState(): found broker - %s\n", config->notreadyServices[i].uris[j]);
+
+ snprintf(buri, MAX_PATH, "%s", config->notreadyServices[i].uris[j]);
+ bzero(bhost, sizeof(char) * MAX_PATH);
+ rc = tokenize_uri(buri, uriType, bhost, &port, path);
+
+ snprintf(curi, MAX_PATH, "%s", config->ccStatus.serviceId.uris[0]);
+ bzero(chost, sizeof(char) * MAX_PATH);
+ rc = tokenize_uri(curi, uriType, chost, &port, path);
+ if (!strcmp(curi, buri)) {
+ logprintfl(EUCAWARN, "ccCheckState(): detected local broker (%s) matching local CC (%s) in NOTREADY state\n", config->notreadyServices[i].uris[j], config->ccStatus.serviceId.uris[0]);
+ }
+ }
+ }
+ }
+ }
+ }
+
snprintf(localDetails, 1023, "ERRORS=%d", ret);
- sem_mywait(CONFIG);
snprintf(config->ccStatus.details, 1023, "%s", localDetails);
- sem_mypost(CONFIG);
+
return(ret);
}
@@ -3008,18 +3034,16 @@ void *monitor_thread(void *in) {
}
}
+ // do state checks under CONFIG lock
+ sem_mywait(CONFIG);
if (ccCheckState()) {
logprintfl(EUCAERROR, "monitor_thread(): ccCheckState() returned failures\n");
- sem_mywait(CONFIG);
config->kick_enabled = 0;
ccChangeState(NOTREADY);
- sem_mypost(CONFIG);
} else if (config->ccState == NOTREADY) {
- sem_mywait(CONFIG);
ccChangeState(DISABLED);
- sem_mypost(CONFIG);
}
-
+ sem_mypost(CONFIG);
shawn();
logprintfl(EUCADEBUG, "monitor_thread(localState=%s): done\n", config->ccStatus.localState);
View
@@ -323,6 +323,7 @@ int changeState(ccResource *in, int newstate);
int ccIsEnabled(void);
int ccIsDisabled(void);
int ccChangeState(int newstate);
+int ccCheckState();
int ccGetStateString(char *outstr, int n);
int readConfigFile(char configFiles[][MAX_PATH], int numFiles);
View
@@ -182,6 +182,13 @@ int gen_instance_xml (const ncInstance * instance)
_ATTRIBUTE(hypervisor, "bitness", bitness);
}
+ { // backing specification (TODO: maybe expand this with device maps or whatnot?)
+ xmlNodePtr backing = xmlNewChild (instanceNode, NULL, BAD_CAST "backing", NULL);
+ xmlNodePtr root = xmlNewChild (backing, NULL, BAD_CAST "root", NULL);
+ assert (instance->params.root);
+ _ATTRIBUTE(root, "type", ncResourceTypeName[instance->params.root->type]);
+ }
+
_ELEMENT(instanceNode, "name", instance->instanceId);
_ELEMENT(instanceNode, "uuid", instance->uuid);
_ELEMENT(instanceNode, "reservation", instance->reservationId);
@@ -240,7 +247,7 @@ int gen_instance_xml (const ncInstance * instance)
if (!strcmp ("none", vbr->guestDeviceName))
continue;
// for Linux instances on Xen, partitions can be used directly, so disks can be skipped
- if (strstr (instance->platform, "linux") && strstr (instance->hypervisorType, "xen")) {
+ if (strstr (instance->platform, "linux") && strstr (instance->hypervisorType, "xen") && (vbr->type == NC_RESOURCE_IMAGE)) {
if (vbr->partitionNumber == 0) {
continue;
}
View
@@ -163,7 +163,7 @@ parse_rec ( // parses the VBR as supplied by a client or user, checks values, an
if (strstr (vbr->typeName, "machine") == vbr->typeName) {
vbr->type = NC_RESOURCE_IMAGE;
if (vm)
- vm->image = vbr;
+ vm->root = vbr;
} else if (strstr (vbr->typeName, "kernel") == vbr->typeName) {
vbr->type = NC_RESOURCE_KERNEL;
if (vm)
@@ -353,7 +353,7 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
virtualMachine * vm, // vm definition containing VBR records
ncMetadata * meta) // OPTIONAL parameter for translating, e.g., walrus:// URI into http:// URI
{
- unsigned char partitions [BUS_TYPES_TOTAL][EUCA_MAX_DISKS][EUCA_MAX_PARTITIONS]; // for validating partitions
+ virtualBootRecord * partitions [BUS_TYPES_TOTAL][EUCA_MAX_DISKS][EUCA_MAX_PARTITIONS]; // for validating partitions
bzero (partitions, sizeof (partitions));
for (int i=0, j=0; i<EUCA_MAX_VBRS && i<vm->virtualBootRecordLen; i++) {
virtualBootRecord * vbr = &(vm->virtualBootRecord[i]);
@@ -362,7 +362,18 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
return ERROR;
if (vbr->type!=NC_RESOURCE_KERNEL && vbr->type!=NC_RESOURCE_RAMDISK)
- partitions [vbr->guestDeviceBus][vbr->diskNumber][vbr->partitionNumber] = 1;
+ partitions [vbr->guestDeviceBus][vbr->diskNumber][vbr->partitionNumber] = vbr;
+
+ if (vm->root==NULL) { // we have not identified the EMI yet
+ if (vbr->type==NC_RESOURCE_IMAGE) {
+ vm->root=vbr;
+ }
+ } else {
+ if (vm->root!=vbr && vbr->type==NC_RESOURCE_IMAGE) {
+ logprintfl (EUCAERROR, "Error: more than one EMI specified in the boot record\n");
+ return ERROR;
+ }
+ }
}
// ensure that partitions are contiguous and that partitions and disks are not mixed
@@ -382,10 +393,24 @@ vbr_parse ( // parses and verifies all VBR entries in the virtual machine defini
return ERROR;
}
}
+ if (vm->root==NULL) { // root partition or disk have not been found yet (no NC_RESOURCE_IMAGE)
+ virtualBootRecord * vbr;
+ if (has_partitions)
+ vbr = partitions [i][j][1];
+ else
+ vbr = partitions [i][j][0];
+ if (vbr && (vbr->type == NC_RESOURCE_EBS))
+ vm->root = vbr;
+ }
}
}
}
+ if (vm->root==NULL) {
+ logprintfl (EUCAERROR, "Error: no root partition or disk have been found\n");
+ return ERROR;
+ }
+
return OK;
}
Oops, something went wrong.

0 comments on commit 88d1662

Please sign in to comment.