Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
1.) initial implementation of vmware/CC pairing algo in the cc
Browse files Browse the repository at this point in the history
2.) disable fault DB storage, temporarily
3.) initial bfebs implementation on Xen
  • Loading branch information
Daniel Nurmi committed Dec 5, 2011
2 parents 10f855c + 441884f commit 88d1662
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ public static Collection<CheckException> lookup( final ServiceConfiguration conf
}
return Lists.newArrayList( );
}

public static void persist( final CheckException errors ) {
}
/*
public static void persist( final CheckException errors ) {
if ( errors != null && Hosts.isCoordinator( ) ) {
try {
Expand All @@ -521,4 +523,5 @@ public static void persist( final CheckException errors ) {
}
}
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}
}
Expand All @@ -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 ) );
}
}
Expand Down
72 changes: 46 additions & 26 deletions cluster/handlers-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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;
Expand All @@ -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);
}
}
}

Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions cluster/handlers-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 31 additions & 7 deletions cluster/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions cluster/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion node/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
31 changes: 28 additions & 3 deletions storage/vbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]);
Expand All @@ -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
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit 88d1662

Please sign in to comment.