Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes instance migration with ebs-volumes attached. Fixes EUCA-5839 a…

…nd EUCA-6083.

Changes to convert_dev_names and added service info metadata passed to the NC from
the CC on MigrateInstance requests.

Service metadata is needed for ebs-instance migration to connect the root volume.
  • Loading branch information...
commit 78b16161efd8d55e923449add8751187447afbe2 1 parent aebdb7f
@zhill zhill authored
View
7 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/VolumeManager.java
@@ -131,8 +131,6 @@
import edu.ucsb.eucalyptus.msgs.DetachStorageVolumeType;
import edu.ucsb.eucalyptus.msgs.DetachVolumeResponseType;
import edu.ucsb.eucalyptus.msgs.DetachVolumeType;
-import edu.ucsb.eucalyptus.msgs.ExportVolumeResponseType;
-import edu.ucsb.eucalyptus.msgs.ExportVolumeType;
import edu.ucsb.eucalyptus.msgs.GetVolumeTokenResponseType;
import edu.ucsb.eucalyptus.msgs.GetVolumeTokenType;
import edu.ucsb.eucalyptus.msgs.ResourceTag;
@@ -419,9 +417,8 @@ public AttachVolumeResponseType AttachVolume( AttachVolumeType request ) throws
throw new EucalyptusCloudException( e.getMessage( ), e );
}
- //TODO: zhill, this is a messaging change. The SC should not know the format, so the CLC must construct the special format
- String token = StorageProperties.TOKEN_PREFIX + scGetTokenResponse.getVolumeId() + "," + scGetTokenResponse.getToken();
-
+ //The SC should not know the format, so the CLC must construct the special format
+ String token = StorageProperties.formatVolumeAttachmentTokenForTransfer(scGetTokenResponse.getToken(), volume.getDisplayName());
request.setRemoteDevice(token);
AttachedVolume attachVol = new AttachedVolume( volume.getDisplayName( ), vm.getInstanceId( ), request.getDevice( ), request.getRemoteDevice( ) );
View
14 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cloud/run/ClusterAllocator.java
@@ -104,6 +104,7 @@
import com.eucalyptus.util.EucalyptusCloudException;
import com.eucalyptus.util.Exceptions;
import com.eucalyptus.util.LogUtil;
+import com.eucalyptus.util.StorageProperties;
import com.eucalyptus.util.async.AsyncRequests;
import com.eucalyptus.util.async.Request;
import com.eucalyptus.util.async.StatefulMessageSet;
@@ -129,7 +130,6 @@
public class ClusterAllocator implements Runnable {
private static final long BYTES_PER_GB = ( 1024L * 1024L * 1024L );
- private static final String VOLUME_TOKEN_PREFIX = "sc://"; //Used for designating EBS volumes in the VBR
private static Logger LOG = Logger.getLogger( ClusterAllocator.class );
@@ -388,12 +388,11 @@ private VmTypeInfo makeVmTypeInfo( final VmTypeInfo vmInfo, final ResourceToken
throw new EucalyptusCloudException( "Failed to get remote device string for " + volumeId + " while running instance " + token.getInstanceId( ) );
} else {
//Do formatting here since formatting is for messaging only.
- //sc://vol-X,<token>
- volumeToken = VOLUME_TOKEN_PREFIX + volumeId + "," + volumeToken;
- rootVbr.setResourceLocation(volumeToken);
- rootVbr.setSize(rootVolume.getSize() * BYTES_PER_GB);
- //vm.updatePersistantVolume(remoteDeviceString, rootVolume); Skipping this step for now as no one seems to be using it
+ volumeToken = StorageProperties.formatVolumeAttachmentTokenForTransfer(volumeToken, volumeId);
}
+ rootVbr.setResourceLocation(volumeToken);
+ rootVbr.setSize(rootVolume.getSize() * BYTES_PER_GB);
+ //vm.updatePersistantVolume(remoteDeviceString, rootVolume); Skipping this step for now as no one seems to be using it
} catch (final Exception ex) {
LOG.error(ex);
Logs.extreme().error(ex, ex);
@@ -428,8 +427,7 @@ private VmTypeInfo makeVmTypeInfo( final VmTypeInfo vmInfo, final ResourceToken
throw new EucalyptusCloudException( "Failed to get remote device string for " + volumeId + " while running instance " + token.getInstanceId( ) );
} else {
//Do formatting here since formatting is for messaging only.
- //sc://vol-X,<token>
- volumeToken = VOLUME_TOKEN_PREFIX + volumeId + "," + volumeToken;
+ volumeToken = StorageProperties.formatVolumeAttachmentTokenForTransfer(volumeToken, volumeId);
VirtualBootRecord vbr = new VirtualBootRecord(volumeId, volumeToken, "ebs", mapping.getKey(), (volume.getSize() * BYTES_PER_GB), "none");
childVmInfo.getVirtualBootRecord().add(vbr);
//vm.updatePersistantVolume(remoteDeviceString, volume); Skipping this step for now as no one seems to be using it
View
7 clc/modules/core/src/main/java/com/eucalyptus/util/StorageProperties.java
@@ -113,12 +113,15 @@
public static final String DEFAULT_EBS_MANAGER = "OverlayManager";
public static String DAS_DEVICE = "/dev/blockdev";
public static final String STORAGE_CLASS_PREFIX = "com.eucalyptus.storage.";
- public static final long SNAP_POINT_MAX_TIME_MS = 15000; //15 sec turnaround
- public static final String TOKEN_PREFIX = "sc://"; //Used to indicate a token should be resolved to an SC. The holder shoul replace 'sc://' with the service url for the enabled SC
+ public static final long SNAP_POINT_MAX_TIME_MS = 15000; //15 sec turnaround
+ public static final String TOKEN_PREFIX = "sc://"; //Used to indicate a token should be resolved to an SC
public static final String COMMON_IQN = "ALL";
static { Groovyness.loadConfig("storageprops.groovy"); }
+ public static String formatVolumeAttachmentTokenForTransfer(String token, String volumeId) {
+ return TOKEN_PREFIX + volumeId + "," + token;
+ }
private static String getSCIqn() {
try {
View
18 cluster/handlers.c
@@ -4550,6 +4550,10 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
timeout = ncGetTimeout(time(NULL), OP_TIMEOUT, 1, 0);
LOGDEBUG("about to ncClientCall source node '%s' with nc_instances (%s %d) [creds='%s'] %s\n",
SP(resourceCacheLocal.resources[src_index].hostname), nodeAction, found_instances, credentials, SP(found_instances == 1 ? nc_instances[0]->instanceId : ""));
+
+ //Populate service metadata in request. Needed for ebs-volume attachment
+ populateOutboundMeta(pMeta);
+
rc = ncClientCall(pMeta, timeout, resourceCacheLocal.resources[src_index].lockidx, resourceCacheLocal.resources[src_index].ncURL, "ncMigrateInstances",
nc_instances, found_instances, nodeAction, credentials);
if (rc) {
@@ -4601,6 +4605,9 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
exit(1);
}
+ //Populate service metadata in request. Needed for ebs-volume attachment
+ populateOutboundMeta(pMeta);
+
rc = ncClientCall(pMeta, timeout, resourceCacheLocal.resources[dst_index].lockidx, resourceCacheLocal.resources[dst_index].ncURL, "ncMigrateInstances",
&(nc_instances[idx]), 1, nodeAction, credentials);
if (rc) {
@@ -4622,6 +4629,10 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
timeout = ncGetTimeout(time(NULL), OP_TIMEOUT, 1, 0);
LOGDEBUG("about to ncClientCall source node '%s' with nc_instances (%s %d) %s\n",
SP(resourceCacheLocal.resources[src_index].hostname), nodeAction, found_instances, SP(found_instances == 1 ? nc_instances[0]->instanceId : ""));
+
+ //Populate service metadata in request. Needed for ebs-volume attachment
+ populateOutboundMeta(pMeta);
+
// No need to send credentials with commit call: they were already passed to source and destination during prepare call.
rc = ncClientCall(pMeta, timeout, resourceCacheLocal.resources[src_index].lockidx, resourceCacheLocal.resources[src_index].ncURL, "ncMigrateInstances",
nc_instances, found_instances, nodeAction, NULL);
@@ -4656,6 +4667,9 @@ int doMigrateInstances(ncMetadata * pMeta, char *actionNode, char *instanceId, c
SP(resourceCacheLocal.resources[dst_index].hostname), SP(found_instances == 1 ? nc_instances[0]->migration_dst : ""), nodeAction, found_instances,
SP(found_instances == 1 ? nc_instances[0]->instanceId : ""), resourceCacheLocal.resources[dst_index].ncURL);
+ //Populate service metadata in request. Needed for ebs-volume attachment
+ populateOutboundMeta(pMeta);
+
rc = ncClientCall(pMeta, timeout, resourceCacheLocal.resources[dst_index].lockidx, resourceCacheLocal.resources[dst_index].ncURL, "ncMigrateInstances",
nc_instances, found_instances, nodeAction, NULL);
if (rc) {
@@ -4793,10 +4807,10 @@ static int populateOutboundMeta(ncMetadata * pMeta)
}
} else {
- return 1;
+ return EUCA_ERROR;
}
- return 0;
+ return EUCA_OK;
}
//!
View
17 node/handlers.c
@@ -504,7 +504,12 @@ int convert_dev_names(const char *localDev, char *localDevReal, char *localDevTa
{
bzero(localDevReal, 32);
if (strchr(localDev, '/') != NULL) {
- sscanf(localDev, "/dev/%s", localDevReal);
+ if(strncmp(localDev, "unknown,requested:", sizeof("unknown,requested:") - 1) == 0) {
+ //localDev starts with 'unknown,requested:', this occurs in migration cases. Extract the actual /dev/* value.
+ sscanf(localDev, "unknown,requested:/dev/%s", localDevReal);
+ } else {
+ sscanf(localDev, "/dev/%s", localDevReal);
+ }
} else {
snprintf(localDevReal, 32, "%s", localDev);
}
@@ -515,8 +520,14 @@ int convert_dev_names(const char *localDev, char *localDevReal, char *localDevTa
}
if (localDevTag) {
- bzero(localDevTag, 256);
- snprintf(localDevTag, 256, "unknown,requested:%s", localDev);
+ //If localDev already has the unknown,requested...just copy it
+ if(strncmp(localDev, "unknown,requested:", sizeof("unknown,requested:") - 1) == 0) {
+ bzero(localDevTag, 256);
+ snprintf(localDevTag, 256, "%s", localDev);
+ } else {
+ bzero(localDevTag, 256);
+ snprintf(localDevTag, 256, "unknown,requested:%s", localDev);
+ }
}
return EUCA_OK;
View
25 node/server-marshal.c
@@ -1371,9 +1371,6 @@ adb_ncMigrateInstancesResponse_t *ncMigrateInstancesMarshal(adb_ncMigrateInstanc
{
int error = EUCA_OK;
ncMetadata meta = { 0 };
- axis2_char_t *correlationId = NULL;
- axis2_char_t *userId = NULL;
- axis2_char_t *nodeName = NULL;
ncInstance **instances = NULL;
int instancesLen = 0;
axis2_char_t *action = NULL;
@@ -1388,11 +1385,6 @@ adb_ncMigrateInstancesResponse_t *ncMigrateInstancesMarshal(adb_ncMigrateInstanc
response = adb_ncMigrateInstancesResponse_create(env);
output = adb_ncMigrateInstancesResponseType_create(env);
- // get standard fields from input
- correlationId = adb_ncMigrateInstancesType_get_correlationId(input, env);
- userId = adb_ncMigrateInstancesType_get_userId(input, env);
- nodeName = adb_ncMigrateInstancesType_get_nodeName(input, env);
-
// get operation-specific fields from input
instancesLen = adb_ncMigrateInstancesType_sizeof_instances(input, env);
if ((instances = EUCA_ZALLOC(instancesLen, sizeof(ncInstance *))) == NULL) {
@@ -1411,14 +1403,13 @@ adb_ncMigrateInstancesResponse_t *ncMigrateInstancesMarshal(adb_ncMigrateInstanc
action = adb_ncMigrateInstancesType_get_action(input, env);
credentials = adb_ncMigrateInstancesType_get_credentials(input, env);
- eventlog("NC", userId, correlationId, "MigrateInstances", "begin");
+ // get standard fields from input
+ EUCA_MESSAGE_UNMARSHAL(ncMigrateInstancesType, input, (&meta));
+ meta.nodeName = adb_ncMigrateInstancesType_get_nodeName(input, env);
- // do it
- bzero((void *)&meta, sizeof(meta));
- meta.correlationId = correlationId;
- meta.userId = userId;
- meta.nodeName = nodeName;
+ eventlog("NC", meta.userId, meta.correlationId, "MigrateInstances", "begin");
+ // do it
error = doMigrateInstances(&meta, instances, instancesLen, action, credentials);
if (error != EUCA_OK) {
LOGERROR("failed error=%d\n", error);
@@ -1431,8 +1422,8 @@ adb_ncMigrateInstancesResponse_t *ncMigrateInstancesMarshal(adb_ncMigrateInstanc
} else {
// set standard fields in output
adb_ncMigrateInstancesResponseType_set_return(output, env, AXIS2_TRUE);
- adb_ncMigrateInstancesResponseType_set_correlationId(output, env, correlationId);
- adb_ncMigrateInstancesResponseType_set_userId(output, env, userId);
+ adb_ncMigrateInstancesResponseType_set_correlationId(output, env, meta.correlationId);
+ adb_ncMigrateInstancesResponseType_set_userId(output, env, meta.userId);
// no operation-specific fields in output
}
@@ -1447,7 +1438,7 @@ adb_ncMigrateInstancesResponse_t *ncMigrateInstancesMarshal(adb_ncMigrateInstanc
}
pthread_mutex_unlock(&ncHandlerLock);
- eventlog("NC", userId, correlationId, "MigrateInstances", "end");
+ eventlog("NC", meta.userId, meta.correlationId, "MigrateInstances", "end");
return (response);
}
View
1  project/cluster
View
1  project/cluster
@@ -1 +0,0 @@
-../cluster
View
1  project/devel
@@ -1 +0,0 @@
-../devel
View
1  project/devel
View
1  project/gatherlog
View
1  project/gatherlog
@@ -1 +0,0 @@
-../gatherlog
View
1  project/net
View
1  project/net
@@ -1 +0,0 @@
-../net
View
1  project/node
@@ -1 +0,0 @@
-../node
View
1  project/node
View
1  project/storage
View
1  project/storage
@@ -1 +0,0 @@
-../storage
View
1  project/tools
@@ -1 +0,0 @@
-../tools
View
1  project/tools
View
1  project/util
@@ -1 +0,0 @@
-../util
View
1  project/util
View
1  project/wsdl
@@ -1 +0,0 @@
-../wsdl
View
1  project/wsdl
Please sign in to comment.
Something went wrong with that request. Please try again.