Skip to content

Commit

Permalink
latest merge from eee
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nurmi committed Dec 4, 2011
2 parents 2a83891 + 710e137 commit 6ce47ac
Show file tree
Hide file tree
Showing 19 changed files with 449 additions and 1,537 deletions.
Expand Up @@ -195,7 +195,7 @@ public SetResponse findRecords( Name name, int type ) {
try {
InetAddress cloudIp = Topology.lookup( Eucalyptus.class ).getInetAddress( );
if (cloudIp != null) {
resp.addRRset( new RRset( new ARecord( name, 1, ttl, cloudIp ) ) );
resp.addRRset( new RRset( new ARecord( name, 1, 20/*ttl*/, cloudIp ) ) );
}
return resp;
} catch (Exception e) {
Expand Down Expand Up @@ -256,7 +256,7 @@ public SetResponse findRecords( Name name, int type ) {
LOG.error(e);
return super.findRecords( name, type );
}
resp.addRRset( new RRset( new ARecord( name, 1, ttl, walrusIp ) ) );
resp.addRRset( new RRset( new ARecord( name, 1, 20/*ttl*/, walrusIp ) ) );
return resp;
} else {
return super.findRecords( name, type );
Expand Down
4 changes: 2 additions & 2 deletions cluster/Makefile
Expand Up @@ -18,7 +18,7 @@ SHUTDOWNCC=shutdownCC
#WSDL2C=${AXIS2C_HOME}/bin/tools/wsdl2c/WSDL2C.sh
NCLIBS=../util/data.o ../node/client-marshal-adb.o ../util/ipc.o
NC_FAKE_LIBS=../util/data.o ../node/client-marshal-fake.o ../util/ipc.o
SCLIBS=../storage/storage.o ../storage/storage-windows.o ../storage/walrus.o ../storage/http.o
SCLIBS=../storage/storage-windows.o ../storage/walrus.o ../storage/http.o
VNLIBS=../net/vnetwork.o ../util/misc.o ../storage/diskutil.o
WSSECLIBS=../util/euca_axis.o ../util/euca_auth.o
CC_LIBS = ${LIBS} ${LDFLAGS} -lcurl -lssl -lcrypto -lrampart
Expand Down Expand Up @@ -69,7 +69,7 @@ server: $(NCLIBS) $(VNLIBS) $(SERVICE_SO)

fake: all $(NC_FAKE_LIBS) $(SERVICE_SO_FAKE)

$(SERVICE_SO): generated/stubs ../storage/storage.o server-marshal.o handlers.o handlers-state.o server-marshal-state.o ../util/windows-bundle.o
$(SERVICE_SO): generated/stubs server-marshal.o handlers.o handlers-state.o server-marshal-state.o ../util/windows-bundle.o
$(CC) -shared generated/*.o server-marshal.o handlers.o handlers-state.o server-marshal-state.o ../util/windows-bundle.o $(SCLIBS) $(NCLIBS) $(VNLIBS) $(WSSECLIBS) $(CC_LIBS) -o $(SERVICE_SO)

$(SERVICE_SO_FAKE):
Expand Down
1 change: 0 additions & 1 deletion cluster/handlers-state.c
Expand Up @@ -74,7 +74,6 @@ permission notice:

#include <server-marshal.h>
#include <handlers.h>
#include <storage.h>
#include <vnetwork.h>
#include <misc.h>
#include <ipc.h>
Expand Down
1 change: 0 additions & 1 deletion cluster/handlers.c
Expand Up @@ -75,7 +75,6 @@ permission notice:

#include <server-marshal.h>
#include <handlers.h>
#include <storage.h>
#include <vnetwork.h>
#include <misc.h>
#include <ipc.h>
Expand Down
3 changes: 0 additions & 3 deletions node/Makefile
Expand Up @@ -59,9 +59,6 @@ server: $(SERVICE_SO)
../storage/blobstore.o: ../storage/blobstore.c ../util/misc.o ../util/data.o
make -C ../storage

../storage/storage.o: ../storage/storage.c ../util/misc.o ../util/data.o
make -C ../storage

../storage/walrus.o: ../storage/walrus.c ../util/misc.o ../util/data.o
make -C ../storage

Expand Down
273 changes: 206 additions & 67 deletions node/handlers.c

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions node/handlers.h
Expand Up @@ -70,7 +70,8 @@ permission notice:

#define LIBVIRT_QUERY_RETRIES 5
#define MAXDOMS 1024
#define BYTES_PER_DISK_UNIT 1073741824 /* disk stats are in Gigs */
#define BYTES_PER_DISK_UNIT 1073741824 // describeResource disk units are GBs
#define MB_PER_DISK_UNIT 1024 // describeResource disk units are GBs

/* NC state */
struct nc_state_t {
Expand All @@ -79,16 +80,15 @@ struct nc_state_t {
hypervisorCapabilityType capability;
vnetConfig *vnetconfig; // network config
// globals
int config_network_port;
char admin_user_id[CHAR_BUFFER_SIZE];
int save_instance_files;
char uri[CHAR_BUFFER_SIZE];
char iqn[CHAR_BUFFER_SIZE];
virConnectPtr conn;
boolean convert_to_disk;
boolean do_inject_key;
int concurrent_disk_ops;
// defined max
long long config_max_disk;
long long config_max_mem;
long long config_max_cores;
// current max
Expand All @@ -98,7 +98,6 @@ struct nc_state_t {
// paths
char home[MAX_PATH];
char config_network_path [MAX_PATH];
char gen_libvirt_cmd_path[MAX_PATH];
char libvirt_xslt_path[MAX_PATH];
char get_info_cmd_path[MAX_PATH];
char rootwrap_cmd_path[MAX_PATH];
Expand Down
16 changes: 2 additions & 14 deletions node/handlers_kvm.c
Expand Up @@ -97,10 +97,7 @@ static int doInitialize (struct nc_state_t *nc)
{
char *s = NULL;

logprintfl(EUCADEBUG, "doInitialized() invoked\n");

/* set up paths of Eucalyptus commands NC relies on */
snprintf (nc->gen_libvirt_cmd_path, MAX_PATH, EUCALYPTUS_GEN_KVM_LIBVIRT_XML, nc->home, nc->home);
// set up paths of Eucalyptus commands NC relies on
snprintf (nc->get_info_cmd_path, MAX_PATH, EUCALYPTUS_GET_KVM_INFO, nc->home, nc->home);
strcpy(nc->uri, HYPERVISOR_URI);
nc->convert_to_disk = 1;
Expand All @@ -118,18 +115,9 @@ static int doInitialize (struct nc_state_t *nc)
GET_VALUE("total_memory", nc->mem_max);
if (s) free(s);

/* we leave 256M to the host */
// we leave 256M to the host
nc->mem_max -= 256;

/* let's adjust the values based on the config values */
if (nc->config_max_mem && nc->config_max_mem < nc->mem_max)
nc->mem_max = nc->config_max_mem;
if (nc->config_max_cores)
nc->cores_max = nc->config_max_cores;

logprintfl(EUCAINFO, "Using %lld cores\n", nc->cores_max);
logprintfl(EUCAINFO, "Using %lld memory\n", nc->mem_max);

return OK;
}

Expand Down
20 changes: 7 additions & 13 deletions node/handlers_xen.c
Expand Up @@ -95,10 +95,7 @@ static int doInitialize (struct nc_state_t *nc)
virNodeInfo ni;
long long dom0_min_mem;

logprintfl(EUCADEBUG, "doInitialized() invoked\n");

/* set up paths of Eucalyptus commands NC relies on */
snprintf (nc->gen_libvirt_cmd_path, MAX_PATH, EUCALYPTUS_GEN_LIBVIRT_XML, nc->home, nc->home);
// set up paths of Eucalyptus commands NC relies on
snprintf (nc->get_info_cmd_path, MAX_PATH, EUCALYPTUS_GET_XEN_INFO, nc->home, nc->home);
snprintf (nc->virsh_cmd_path, MAX_PATH, EUCALYPTUS_VIRSH, nc->home);
snprintf (nc->xm_cmd_path, MAX_PATH, EUCALYPTUS_XM);
Expand All @@ -107,18 +104,18 @@ static int doInitialize (struct nc_state_t *nc)
nc->convert_to_disk = 0;
nc->capability = HYPERVISOR_XEN_AND_HARDWARE; // TODO: set to XEN_PARAVIRTUALIZED if on older Xen kernel

/* check connection is fresh */
// check connection is fresh
if (!check_hypervisor_conn()) {
return ERROR_FATAL;
}

/* get resources */
// get resources
if (virNodeGetInfo(nc->conn, &ni)) {
logprintfl (EUCAFATAL, "error: failed to discover resources\n");
return ERROR_FATAL;
}

/* dom0-min-mem has to come from xend config file */
// dom0-min-mem has to come from xend config file
s = system_output (nc->get_info_cmd_path);
if (get_value (s, "dom0-min-mem", &dom0_min_mem)) {
logprintfl (EUCAFATAL, "error: did not find dom0-min-mem in output from %s\n", nc->get_info_cmd_path);
Expand All @@ -127,21 +124,18 @@ static int doInitialize (struct nc_state_t *nc)
}
free (s);

/* calculate the available memory */
// calculate the available memory
nc->mem_max = ni.memory/1024 - 32 - dom0_min_mem;

/* calculate the available cores */
// calculate the available cores
nc->cores_max = ni.cpus;

/* let's adjust the values based on the config values */
// let's adjust the values based on the config values
if (nc->config_max_mem && nc->config_max_mem < nc->mem_max)
nc->mem_max = nc->config_max_mem;
if (nc->config_max_cores)
nc->cores_max = nc->config_max_cores;

logprintfl(EUCAINFO, "Using %lld cores\n", nc->cores_max);
logprintfl(EUCAINFO, "Using %lld memory\n", nc->mem_max);

return OK;
}

Expand Down
8 changes: 4 additions & 4 deletions storage/Makefile
Expand Up @@ -14,8 +14,8 @@ TESTS=test_vbr test_blobstore test
IMAGER=_euca_imager
#EFENCE=-lefence

all: vbr.o backing.o storage.o storage-windows.o walrus.o diskutil.o Wclient $(IMAGER) test_blobstore test_vbr
#all: storage.o storage-windows.o walrus.o test_blobstore
all: vbr.o backing.o storage-windows.o walrus.o diskutil.o Wclient $(IMAGER) test_blobstore test_vbr
#all: storage-windows.o walrus.o test_blobstore

build: all

Expand All @@ -28,8 +28,8 @@ Wclient: Makefile Wclient.c ../util/euca_auth.o ../util/misc.o walrus.o http.o
walrus.o: walrus.c walrus.h
$(CC) $(CFLAGS) $(INCLUDES) -c walrus.c

test: test.c storage.h storage.o storage-windows.o ../util/misc.o ../util/data.o ../util/ipc.o ../util/euca_auth.o walrus.o
$(CC) $(CFLAGS) $(INCLUDES) test.c storage.o storage-windows.o ../util/misc.o diskutil.o ../util/data.o ../util/ipc.o ../util/euca_auth.o walrus.o $(STORAGE_LIBS) -o test
test: test.c blobstore.o storage-windows.o ../util/misc.o ../util/data.o ../util/ipc.o ../util/euca_auth.o walrus.o
$(CC) $(CFLAGS) $(INCLUDES) test.c blobstore.o storage-windows.o ../util/misc.o diskutil.o ../util/data.o ../util/ipc.o ../util/euca_auth.o walrus.o $(STORAGE_LIBS) -o test

test_blobstore: blobstore.o blobstore.c blobstore.h map.o diskutil.o ../util/misc.o
$(CC) -g -rdynamic $(CFLAGS) $(INCLUDES) -D_UNIT_TEST blobstore.c -o test_blobstore map.o diskutil.o ../util/misc.o ../util/ipc.o $(STORAGE_LIBS) $(EFENCE) ../util/euca_auth.o
Expand Down
58 changes: 51 additions & 7 deletions storage/backing.c
Expand Up @@ -84,6 +84,7 @@
#include "backing.h"
#include "iscsi.h"
#include "vbr.h"
#include "ipc.h" // sem

#define CACHE_TIMEOUT_USEC 1000000LL*60*60*2
#define STORE_TIMEOUT_USEC 1000000LL*60*2
Expand All @@ -93,13 +94,39 @@
static char instances_path [MAX_PATH];
static blobstore * cache_bs = NULL;
static blobstore * work_bs;
static sem * disk_sem = NULL;

extern struct nc_state_t nc_state;

static void bs_errors (const char * msg) {
// we normally do not care to print all messages from blobstore as many are errors that we can handle
logprintfl (EUCADEBUG2, "{%u} blobstore: %s", (unsigned int)pthread_self(), msg);
}

static void stat_blobstore (const char * conf_instances_path, const char * name, blobstore_meta * meta)
{
bzero (meta, sizeof (blobstore_meta));
char path [MAX_PATH];
snprintf (path, sizeof (path), "%s/%s", conf_instances_path, name);
blobstore * bs = blobstore_open (path,
0, // any size
0, // no flags = do not create it
BLOBSTORE_FORMAT_ANY,
BLOBSTORE_REVOCATION_ANY,
BLOBSTORE_SNAPSHOT_ANY);
if (bs == NULL)
return;
blobstore_stat (bs, meta);
blobstore_close (bs);
}

void stat_backing_store (const char * conf_instances_path, blobstore_meta * work_meta, blobstore_meta * cache_meta)
{
assert (conf_instances_path);
stat_blobstore (conf_instances_path, "work", work_meta);
stat_blobstore (conf_instances_path, "cache", cache_meta);
}

int init_backing_store (const char * conf_instances_path, unsigned int conf_work_size_mb, unsigned int conf_cache_size_mb)
{
logprintfl (EUCAINFO, "initializing backing store...\n");
Expand All @@ -125,19 +152,20 @@ int init_backing_store (const char * conf_instances_path, unsigned int conf_work

blobstore_set_error_function ( &bs_errors );
if (cache_limit_blocks) {
cache_bs = blobstore_open (cache_path, cache_limit_blocks, BLOBSTORE_FORMAT_DIRECTORY, BLOBSTORE_REVOCATION_LRU, BLOBSTORE_SNAPSHOT_ANY);
cache_bs = blobstore_open (cache_path, cache_limit_blocks, BLOBSTORE_FLAG_CREAT, BLOBSTORE_FORMAT_DIRECTORY, BLOBSTORE_REVOCATION_LRU, BLOBSTORE_SNAPSHOT_ANY);
if (cache_bs==NULL) {
logprintfl (EUCAERROR, "ERROR: %s\n", blobstore_get_error_str(blobstore_get_error()));
logprintfl (EUCAERROR, "ERROR: failed to open/create cache blobstore: %s\n", blobstore_get_error_str(blobstore_get_error()));
return ERROR;
}
if (blobstore_fsck (cache_bs, NULL)) { // TODO: verify checksums?
logprintfl (EUCAERROR, "ERROR: cache failed integrity check: %s\n", blobstore_get_error_str(blobstore_get_error()));
return ERROR;
}
}
work_bs = blobstore_open (work_path, work_limit_blocks, BLOBSTORE_FORMAT_FILES, BLOBSTORE_REVOCATION_NONE, BLOBSTORE_SNAPSHOT_ANY);
work_bs = blobstore_open (work_path, work_limit_blocks, BLOBSTORE_FLAG_CREAT, BLOBSTORE_FORMAT_FILES, BLOBSTORE_REVOCATION_NONE, BLOBSTORE_SNAPSHOT_ANY);
if (work_bs==NULL) {
logprintfl (EUCAERROR, "ERROR: %s\n", blobstore_get_error_str(blobstore_get_error()));
logprintfl (EUCAERROR, "ERROR: failed to open/create work blobstore: %s\n", blobstore_get_error_str(blobstore_get_error()));
logprintfl (EUCAERROR, "ERROR: %s\n", blobstore_get_last_trace());
blobstore_close (cache_bs);
return ERROR;
}
Expand All @@ -147,6 +175,13 @@ int init_backing_store (const char * conf_instances_path, unsigned int conf_work
return ERROR;
}

// set the initial value of the semaphore to the number of
// disk-intensive operations that can run in parallel on this node
if (nc_state.concurrent_disk_ops && (disk_sem = sem_alloc (nc_state.concurrent_disk_ops, "mutex")) == NULL) {
logprintfl (EUCAERROR, "failed to create and initialize disk semaphore\n");
return ERROR;
}

return OK;
}

Expand Down Expand Up @@ -322,12 +357,21 @@ int create_instance_backing (ncInstance * instance)
TRUE, // make working copy of runtime-modifiable files
(instance->do_inject_key)?(instance->keyName):(NULL), // the SSH key
instance->instanceId); // ID is for logging
if (sentinel == NULL ||
art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC) != OK) { // download/create/combine the dependencies
if (sentinel == NULL) {
logprintfl (EUCAERROR, "[%s] error: failed to prepare backing for instance\n", instance->instanceId);
goto out;
}


sem_p (disk_sem);
// download/create/combine the dependencies
int rc = art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC);
sem_v (disk_sem);

if (rc != OK) {
logprintfl (EUCAERROR, "[%s] error: failed to implement backing for instance\n", instance->instanceId);
goto out;
}

if (save_instance_struct (instance)) // update instance checkpoint now that the struct got updated
goto out;

Expand Down
2 changes: 2 additions & 0 deletions storage/backing.h
Expand Up @@ -62,10 +62,12 @@
*/

#include "data.h" // ncInstance
#include "blobstore.h" // blobstore_meta

#define BACKING_FILE_PERM 0660
#define BACKING_DIRECTORY_PERM 0771

void stat_backing_store (const char * conf_instances_path, blobstore_meta * work_meta, blobstore_meta * cache_meta);
int init_backing_store (const char * conf_instances_path, unsigned int conf_work_size_mb, unsigned int conf_cache_size_mb);
int create_instance_backing (ncInstance * instance);
int clone_bundling_backing (ncInstance * instance, const char * filePrefix, char * blockPath);
Expand Down

0 comments on commit 6ce47ac

Please sign in to comment.