[
https://issues.apache.org/jira/browse/CLOUDSTACK-6274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13943835#comment-13943835
]
Mike Tutkowski commented on CLOUDSTACK-6274:
--------------------------------------------
>From an e-mail I sent to dev@ on March 10, 2014 (I slightly modified the
>content of the e-mail below to correct a minor error):
Hi,
I noticed a minor problem trying to attach a volume that is at the cluster
scope to a VM whose root disk is at the zone scope IF the VM is in the stopped
state (this works fine when the VM is in the running state).
The problem is in the needMoveVolume method in the VolumeApiServiceImpl class.
When the VM is in the Stopped state, if you try to get the host ID of the VM,
it will come back as null. (code below)
if (storeForRootStoreScope.getScopeType() !=
storeForDataStoreScope.getScopeType()) {
if (storeForDataStoreScope.getScopeType() == ScopeType.CLUSTER) {
Long vmClusterId = null;
if (storeForRootStoreScope.getScopeType() == ScopeType.HOST) {
HostScope hs = (HostScope)storeForRootStoreScope;
vmClusterId = hs.getClusterId();
} else if (storeForRootStoreScope.getScopeType() ==
ScopeType.ZONE) {
Long hostId =
_vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId();
if (hostId != null) {
HostVO host = _hostDao.findById(hostId);
vmClusterId = host.getClusterId();
}
}
if (storeForDataStoreScope.getScopeId().equals(vmClusterId)) {
return false;
}
} else if (storeForDataStoreScope.getScopeType() == ScopeType.HOST
&& (storeForRootStoreScope.getScopeType() ==
ScopeType.CLUSTER || storeForRootStoreScope.getScopeType() == ScopeType.ZONE)) {
Long hostId =
_vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId();
if (storeForDataStoreScope.getScopeId().equals(hostId)) {
return false;
}
}
throw new CloudRuntimeException("Can't move volume between scope: "
+ storeForDataStoreScope.getScopeType() + " and " +
storeForRootStoreScope.getScopeType());
}
My question is the following: Do you think it's acceptable to query for the
last host ID if the host ID is null in this situation? (code below)
if (storeForRootStoreScope.getScopeType() !=
storeForDataStoreScope.getScopeType()) {
if (storeForDataStoreScope.getScopeType() == ScopeType.CLUSTER) {
Long vmClusterId = null;
if (storeForRootStoreScope.getScopeType() == ScopeType.HOST) {
HostScope hs = (HostScope)storeForRootStoreScope;
vmClusterId = hs.getClusterId();
} else if (storeForRootStoreScope.getScopeType() ==
ScopeType.ZONE) {
Long hostId =
_vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId();
if (hostId == null) {
hostId =
_vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getLastHostId();
}
if (hostId != null) {
HostVO host = _hostDao.findById(hostId);
vmClusterId = host.getClusterId();
}
}
if (storeForDataStoreScope.getScopeId().equals(vmClusterId)) {
return false;
}
} else if (storeForDataStoreScope.getScopeType() == ScopeType.HOST
&& (storeForRootStoreScope.getScopeType() ==
ScopeType.CLUSTER || storeForRootStoreScope.getScopeType() == ScopeType.ZONE)) {
Long hostId =
_vmInstanceDao.findById(rootVolumeOfVm.getInstanceId()).getHostId();
if (storeForDataStoreScope.getScopeId().equals(hostId)) {
return false;
}
}
throw new CloudRuntimeException("Can't move volume between scope: "
+ storeForDataStoreScope.getScopeType() + " and " +
storeForRootStoreScope.getScopeType());
}
I believe this solves the problem for this one case, but it wouldn't solve the
case where the VM was created in the Stopped state, it's root disk is at the
zone scope, and we want to attach a data disk that is at the cluster scope to
the VM.
In this situation, there will not be a last host ID.
Thoughts?
Thanks!
> Scope issue attaching a disk to a VM
> ------------------------------------
>
> Key: CLOUDSTACK-6274
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-6274
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Components: Management Server
> Affects Versions: 4.4.0
> Environment: Ubuntu 12.04
> Reporter: Mike Tutkowski
> Fix For: 4.4.0
>
>
--
This message was sent by Atlassian JIRA
(v6.2#6252)