Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ability to specify timeout to http_get (connection and overall), …

…fix null check bug when CLC does not set userId in eucalyptusMessage
  • Loading branch information...
commit 8a6938c94b1a2682a7013451e8d230ac2969919e 1 parent 49b5d31
root authored
View
54 cluster/handlers.c
@@ -269,7 +269,25 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
pid = fork();
if (!pid) {
ncStub *ncs;
-
+ ncMetadata *localmeta=NULL;
+
+ localmeta = malloc(sizeof(ncMetadata));
+ if (!localmeta) {
+ logprintfl(EUCAFATAL, "ncClientCall(%s): out of memory!\n", ncOp);
+ unlock_exit(1);
+ }
+ memcpy(localmeta, meta, sizeof(ncMetadata));
+ if (meta->correlationId) {
+ localmeta->correlationId = strdup(meta->correlationId);
+ } else {
+ localmeta->correlationId = strdup("unset");
+ }
+ if (meta->userId) {
+ localmeta->userId = strdup(meta->userId);
+ } else {
+ localmeta->userId = strdup("eucalyptus");
+ }
+
close(filedes[0]);
ncs = ncStubCreate(ncURL, NULL, NULL);
if (config->use_wssec) {
@@ -282,7 +300,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
char *instId = va_arg(al, char *);
char **consoleOutput=va_arg(al, char **);
- rc = ncGetConsoleOutputStub(ncs, meta, instId, consoleOutput);
+ rc = ncGetConsoleOutputStub(ncs, localmeta, instId, consoleOutput);
if (timeout && consoleOutput) {
if (!rc && *consoleOutput) {
len = strlen(*consoleOutput) + 1;
@@ -301,7 +319,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
char *remoteDev = va_arg(al, char *);
char *localDev = va_arg(al, char *);
- rc = ncAttachVolumeStub(ncs, meta, instanceId, volumeId, remoteDev, localDev);
+ rc = ncAttachVolumeStub(ncs, localmeta, instanceId, volumeId, remoteDev, localDev);
} else if (!strcmp(ncOp, "ncDetachVolume")) {
char *instanceId = va_arg(al, char *);
char *volumeId = va_arg(al, char *);
@@ -309,32 +327,33 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
char *localDev = va_arg(al, char *);
int force = va_arg(al, int);
- rc = ncDetachVolumeStub(ncs, meta, instanceId, volumeId, remoteDev, localDev, force);
+ rc = ncDetachVolumeStub(ncs, localmeta, instanceId, volumeId, remoteDev, localDev, force);
} else if (!strcmp(ncOp, "ncCreateImage")) {
char *instanceId = va_arg(al, char *);
char *volumeId = va_arg(al, char *);
char *remoteDev = va_arg(al, char *);
- rc = ncCreateImageStub(ncs, meta, instanceId, volumeId, remoteDev);
+ rc = ncCreateImageStub(ncs, localmeta, instanceId, volumeId, remoteDev);
} else if (!strcmp(ncOp, "ncPowerDown")) {
- rc = ncPowerDownStub(ncs, meta);
+ rc = ncPowerDownStub(ncs, localmeta);
} else if (!strcmp(ncOp, "ncAssignAddress")) {
char *instanceId = va_arg(al, char *);
char *publicIp = va_arg(al, char *);
- rc = ncAssignAddressStub(ncs, meta, instanceId, publicIp);
+ rc = ncAssignAddressStub(ncs, localmeta, instanceId, publicIp);
//rc = 0;
} else if (!strcmp(ncOp, "ncRebootInstance")) {
char *instId = va_arg(al, char *);
- rc = ncRebootInstanceStub(ncs, meta, instId);
+ rc = ncRebootInstanceStub(ncs, localmeta, instId);
} else if (!strcmp(ncOp, "ncTerminateInstance")) {
char *instId = va_arg(al, char *);
int force = va_arg(al, int);
int *shutdownState = va_arg(al, int *);
int *previousState = va_arg(al, int *);
-
- rc = ncTerminateInstanceStub(ncs, meta, instId, force, shutdownState, previousState);
+
+ rc = ncTerminateInstanceStub(ncs, localmeta, instId, force, shutdownState, previousState);
+
if (timeout) {
if (!rc) {
len = 2;
@@ -356,7 +375,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
int vlan = va_arg(al, int);
char **outStatus = va_arg(al, char **);
- rc = ncStartNetworkStub(ncs, meta, uuid, peers, peersLen, port, vlan, outStatus);
+ rc = ncStartNetworkStub(ncs, localmeta, uuid, peers, peersLen, port, vlan, outStatus);
if (timeout && outStatus) {
if (!rc && *outStatus) {
len = strlen(*outStatus) + 1;
@@ -390,7 +409,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
int netNamesLen = va_arg(al, int);
ncInstance **outInst = va_arg(al, ncInstance **);
- rc = ncRunInstanceStub(ncs, meta, uuid, instId, reservationId, ncvm, imageId, imageURL, kernelId, kernelURL, ramdiskId, ramdiskURL, keyName, ncnet, userData, launchIndex, platform, expiryTime, netNames, netNamesLen, outInst);
+ rc = ncRunInstanceStub(ncs, localmeta, uuid, instId, reservationId, ncvm, imageId, imageURL, kernelId, kernelURL, ramdiskId, ramdiskURL, keyName, ncnet, userData, launchIndex, platform, expiryTime, netNames, netNamesLen, outInst);
if (timeout && outInst) {
if (!rc && *outInst) {
len = sizeof(ncInstance);
@@ -409,7 +428,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
ncInstance ***ncOutInsts=va_arg(al, ncInstance ***);
int *ncOutInstsLen= va_arg(al, int *);
- rc = ncDescribeInstancesStub(ncs, meta, instIds, instIdsLen, ncOutInsts, ncOutInstsLen);
+ rc = ncDescribeInstancesStub(ncs, localmeta, instIds, instIdsLen, ncOutInsts, ncOutInstsLen);
if (timeout && ncOutInsts && ncOutInstsLen) {
if (!rc) {
len = *ncOutInstsLen;
@@ -430,7 +449,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
char *resourceType = va_arg(al, char *);
ncResource **outRes=va_arg(al, ncResource **);
- rc = ncDescribeResourceStub(ncs, meta, resourceType, outRes);
+ rc = ncDescribeResourceStub(ncs, localmeta, resourceType, outRes);
if (timeout && outRes) {
if (!rc && *outRes) {
len = sizeof(ncResource);
@@ -452,11 +471,11 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
char *S3Policy = va_arg(al, char *);
char *S3PolicySig = va_arg(al, char *);
- rc = ncBundleInstanceStub(ncs, meta, instanceId, bucketName, filePrefix, walrusURL, userPublicKey, S3Policy, S3PolicySig);
+ rc = ncBundleInstanceStub(ncs, localmeta, instanceId, bucketName, filePrefix, walrusURL, userPublicKey, S3Policy, S3PolicySig);
} else if (!strcmp(ncOp, "ncCancelBundleTask")) {
char *instanceId = va_arg(al, char *);
- rc = ncCancelBundleTaskStub(ncs, meta, instanceId);
+ rc = ncCancelBundleTaskStub(ncs, localmeta, instanceId);
} else {
logprintfl(EUCAWARN, "\tncClientCall(%s): ppid=%d operation '%s' not found\n", ncOp, getppid(), ncOp);
rc = 1;
@@ -468,6 +487,7 @@ int ncClientCall(ncMetadata *meta, int timeout, int ncLock, char *ncURL, char *n
ret = 0;
}
close(filedes[1]);
+ if (localmeta) free(localmeta);
exit(ret);
} else {
// returns for each client call
@@ -3920,7 +3940,7 @@ int reconfigureNetworkFromCLC() {
// clcnet populate
snprintf(url, MAX_PATH, "http://%s:8773/latest/network-topology", cloudIp);
- rc = http_get_timeout(url, clcnetfile, 0, 0);
+ rc = http_get_timeout(url, clcnetfile, 0, 0, 10, 15);
if (cloudIp) free(cloudIp);
if (rc) {
logprintfl(EUCAWARN, "reconfigureNetworkFromCLC(): cannot get latest network topology from cloud controller\n");
View
6 cluster/server-marshal.c
@@ -191,9 +191,6 @@ adb_BundleInstanceResponse_t *BundleInstanceMarshal(adb_BundleInstance_t *bundle
EUCA_MESSAGE_UNMARSHAL(bundleInstanceType, bit, (&ccMeta));
- ccMeta.correlationId = adb_bundleInstanceType_get_correlationId(bit, env);
- ccMeta.userId = adb_bundleInstanceType_get_userId(bit, env);
-
instanceId = adb_bundleInstanceType_get_instanceId(bit, env);
bucketName = adb_bundleInstanceType_get_bucketName(bit, env);
filePrefix = adb_bundleInstanceType_get_filePrefix(bit, env);
@@ -243,9 +240,6 @@ adb_CancelBundleTaskResponse_t *CancelBundleTaskMarshal(adb_CancelBundleTask_t *
EUCA_MESSAGE_UNMARSHAL(cancelBundleTaskType, bit, (&ccMeta));
- ccMeta.correlationId = adb_cancelBundleTaskType_get_correlationId(bit, env);
- ccMeta.userId = adb_cancelBundleTaskType_get_userId(bit, env);
-
instanceId = adb_cancelBundleTaskType_get_instanceId(bit, env);
status = AXIS2_TRUE;
View
10 storage/http.c
@@ -324,10 +324,10 @@ char * url_decode (const char * encoded) {
int http_get (const char * url, const char * outfile)
{
- return(http_get_timeout(url, outfile, TOTAL_RETRIES, FIRST_TIMEOUT));
+ return(http_get_timeout(url, outfile, TOTAL_RETRIES, FIRST_TIMEOUT, 0, 0));
}
-int http_get_timeout (const char * url, const char * outfile, int total_retries, int first_timeout)
+int http_get_timeout (const char * url, const char * outfile, int total_retries, int first_timeout, int connect_timeout, int total_timeout)
{
int code = ERROR;
@@ -368,6 +368,12 @@ int http_get_timeout (const char * url, const char * outfile, int total_retries,
curl_easy_setopt (curl, CURLOPT_WRITEDATA, &params);
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data);
+ if (connect_timeout > 0) {
+ curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, connect_timeout);
+ }
+ if (total_timeout > 0) {
+ curl_easy_setopt (curl, CURLOPT_TIMEOUT, total_timeout);
+ }
// curl_easy_setopt (curl, CURLOPT_HTTPHEADER, headers); /* register headers */
logprintfl (EUCADEBUG, "http_get(): writing %s output to %s\n", "GET", outfile);
View
2  storage/http.h
@@ -61,7 +61,7 @@ permission notice:
#define HTTP_H
int http_put (const char * file_name, const char * url, const char * login, const char * password);
int http_get (const char * url, const char * outfile);
-int http_get_timeout (const char * url, const char * outfile, int total_retries, int first_timeout);
+int http_get_timeout (const char * url, const char * outfile, int total_retries, int first_timeout, int connect_timeout, int total_timeout);
char * url_encode (const char * unencoded);
char * url_decode (const char * encoded);
#endif /* HTTP_H */
View
4 storage/storage.c
@@ -831,7 +831,7 @@ static long long get_cached_file (const char * user_id, const char * url, const
} else {
char manifestURL[1024];
snprintf(manifestURL, 1024, "%s.manifest.xml", url);
- e = http_get_timeout(manifestURL, tmp_digest_path, 10, 4);
+ e = http_get_timeout(manifestURL, tmp_digest_path, 10, 4, 0, 0);
}
if (e==OK && stat (tmp_digest_path, &mystat)) {
digest_size_b = (long long)mystat.st_size;
@@ -877,7 +877,7 @@ static long long get_cached_file (const char * user_id, const char * url, const
if (strstr(url, "services/Walrus")) {
e = walrus_image_by_manifest_url (url, file_path, 1);
} else {
- e = http_get_timeout(url, file_path, 10, 4);
+ e = http_get_timeout(url, file_path, 10, 4, 0, 0);
}
/* for KVM, convert partition into disk */
Please sign in to comment.
Something went wrong with that request. Please try again.