Uh oh!
There was an error while loading. Please reload this page.
CID-1338387: remove logicless execution cycles - #1056
Conversation
miguelaferreira
commented
Nov 10, 2015
Wouldn't it be better to make sure |
DaanHoogland
commented
Nov 10, 2015
It was put in there explicitely (return null;) so i trusted the intention. a review of the architecture could be justified. |
miguelaferreira
commented
Nov 10, 2015
That intention opens up an entire category of errors, null dereferencing. In addition forces defensive coding, just like what you introduce in this PR. |
asfbot
commented
Nov 10, 2015
Daan Hoogland on dev@cloudstack.apache.org replies: |
rafaelweingartner
commented
Nov 10, 2015
@DaanHoogland I agree with @miguelaferreira. That makes me wondering, why ordering by random the projection?! That can make problems harder to debug. Whatever, that is not the focus here. |
DaanHoogland
commented
Nov 10, 2015
@miguelaferreira@rafaelweingartner I totally agree with you that this can be dealt with better. I didn't want to give it a second thought as my intention is to get more coverity issues fixed then newly reported on every itteration. I am fine with not committing this as I first approached so will look into a better solution. please see #1057 and comment on that as well. |
DaanHoogland
commented
Nov 10, 2015
@rafaelweingartner after randomly oredering and limiting output to 1 the next step is looping over all (1) results and retrieving all hosts one by one ignoring previous results in the set. @miguelaferreira growing this out my idea is to start by having selectHypervisorHost throw an exception on host == null and catch it one level up to just ignore the finding it again part. I'll implement it for arguments sake and force push |
DaanHoogland
commented
Nov 10, 2015
@miguelaferreira@rafaelweingartner you guys care to discuss this further? (this as in this case but also this as in this pattern) |
throw on host is null no iteration for retrieving only one element
rafaelweingartner
commented
Nov 10, 2015
@ DaanHoogland, I noticed that the select is limiting the RS in one element. That is actually my point, if the register does not matter, I would rather order by id DESC or ASC and not at random (of course, I would maintain the limit 1 clause); because that way if something happens I think it would be easier to track the problem. Additionally, as you pointed that out, I think if the host == null, throwing an exception is a better way to go. BTW: I was staring at that code now, and something hit me. I also noticed that you created two new exceptions, would not it be better for us to use the already known “CloudRuntimeException”? Instead of creating other exception types. |
miguelaferreira
commented
Nov 10, 2015
If there will be no error recovery for the exception thrown on host == null, then you will probably be better off with using Optional. It's in Java8, but also in Guava, I think. |
rafaelweingartner
commented
Nov 10, 2015
Are we already migrating to Java 8? |
DaanHoogland
commented
Nov 10, 2015
Optionals are great whether we need to handle or not, right? Especially in this one level case. I was thinking it would get more complicated in some cases. Even in this case if we realy think it through. If we go and think of a good pattern to handle nulls with optionals we better make it very tempting to use all over the cloud. a bigger problem then a less then perfect solution is more then one solution to a problem. it will lead to confusion. @rafaelweingartner yes we are going to 1.8. I think we can run on 1.8 now. |
rafaelweingartner
commented
Nov 10, 2015
That is great if we can use Java 8. However, I checked the maven compiler configuration, and it is using Java 1.7. Will that be changed in current master? |
DaanHoogland
commented
Nov 10, 2015
yeah, you had me at 'Are we'. I am now building with 1.8. change in the pom and et the java_home should be all |
rafaelweingartner
commented
Nov 10, 2015
Got it. Shouldn’t we create a PR changing the Java compilation level to 1.8? @DaanHoogland, I still have a doubt about the need of that “selectHypervisorHost” method call. If you take a look at the stack of calls, the method that starts the process is “com.cloud.hypervisor.HypervisorGuruManagerImpl.getGuruProcessedCommandTargetHost(long, Command)” that method makes me think that we could just use the host that it receives as a parameter instead of looking for another one. What is the point on getting a host at random? There was not even a check if the hypervisor type of the host that was selected is the same as the host that initiated the whole process. Moreover, line 79 of “getGuruProcessedCommandTargetHost”, already uses the hypervisor type of the host that is being sent as a parameter; I am not seeing why that call “endPointSelector.selectHypervisorHost” is needed. It seems that we could just remove lines 114 and 115 in Ovm3HypervisorGuru.java (prior to the modifications that @DaanHoogland did) and we would be good to go, without much complications. The same happens for XenServerGuru.java, lines 193 and 194. |
DaanHoogland
commented
Nov 10, 2015
@rafaelweingartner I think the method configures the host to have the right storage endpoint. It is kind of an obfuscated side effect but I think the call to |
DaanHoogland
commented
Nov 10, 2015
@rafaelweingartner the compile of cloudstack with 1.8 completes but not with unit tests. I think we need to work hard for this. |
rafaelweingartner
commented
Nov 10, 2015
@DaanHoogland, sorry if I am being stubborn, but I really do not see what the method “endPointSelector.selectHypervisorHost” is used for; at the end we get the “EndPoint” and use just the host_id of that object, then we load the host using that id and the details of that host. My point is that, if the host does not matter, why not use the host we have already loaded in line 113, and then load the details of that host. If we do that, we can remove the “endPointSelector.selectHypervisorHost” method. The configure method you talked about (org.apache.cloudstack.storage.RemoteHostEndPoint.configure(Host)) will load the “publicAddress”,if the host it receives as a parameter is a SSVM. However, the select “select h.id from host h where h.status = 'Up' and h.hypervisor_type is not null” that is executed in (endPointSelector.selectHypervisorHost) will not return any of the system VMs, because they have “hypervisor_type” value as null. Therefore, we are using that method without needing it; that method will just return a random host of the environment. |
miguelaferreira
commented
Nov 11, 2015
We don't need Java 8 to use optional. And yes, optional is meant for expressing that a value may be present or not. The API is quite clear, I don't see the confusion. https://github.com/google/guava/wiki/UsingAndAvoidingNullExplained |
DaanHoogland
commented
Nov 11, 2015
@miguelaferreira Optional is very clear indeed. So is exception handling. When you need to handle a possible null return one level deep optional is fine. Newbees look at the code of one hypervisor guru as example of the code for an other hypervisor guru. Let's not implement a different solution strategy in each but find a solution that works in a generic way, avoiding confusion on the part of the spectator. @rafaelweingartner your stubbornness is much appreciated. I want to understand exactly what happens as well. You have not convinced me that the call is without side effects yet. At the very least an EndPoint object is created by the spring framework. I don't say that this side effect is desired but I want to be sure before just cutting the code away. The endpoint in a storage subsystem is not intended to be the same as a hypervisor and maybe I let let myself be misled by that. |
miguelaferreira
commented
Nov 11, 2015
@DaanHoogland both Optional and Exception will give the opportunity to handle the "null case", the difference is in the semantics. Optional means that you expect to either have or not have a value. Exception means that no value is an error state/case. So you should use one or the other depending on what does it mean semantically to not have a value. Newbies or otherwise will understand this. Regarding your point about different solutions in different places, I would say that it argues for stagnation. You present two options: either apply a better solution to all places, or keep replicating the current solution. I propose a different approach. An approach that will introduce a better solution incrementally, one (or a few) places at a time. I don't see any problem with this, since we actually keep history everyone can see that one change happened in 2010 and the other in 2015. Then people can ask about it, or better yet we can tell them upfront. We just have to be willing to do the best we can at all times. |
DaanHoogland
commented
Nov 11, 2015
@miguelaferreira you are assigning claims to me that I did not make: "You present two options: " |
miguelaferreira
commented
Nov 11, 2015
I don't think so @DaanHoogland. But if I've misinterpreted what you said, I'll be happy to have you explain to me what that is. |
rafaelweingartner
commented
Nov 11, 2015
Hi @DaanHoogland, I debugged the use of that method in my environment. I am using Xen; and that method is used when creating a template from a snapshot; the CS will execute the code: “com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command)” Look at what happened in my test, the hostHd received in the “XenServerGuru.getCommandHostDelegation” method was (100). “XenServerGuru.getCommandHostDelegation” loaded the host data from host table to retrieve the dataCenterID, and then executed “endPointSelector.selectHypervisorHost”, that ended up selecting a host that has the id (87) which is in a different cluster. Then it created the “EndPoint” object that does not do much; there is a configure method “org.apache.cloudstack.storage.RemoteHostEndPoint.configure(Host)” that is called, but it merely retrieves some data from the host object that was sent as a parameter. After that in line 161 of “XenServerGuru.getCommandHostDelegation” it is loaded the host data using the host id of the “EndPoint” object; then we check if the host (87) has a fix “snapshotHotFix”; in my case, the host did not have, so it ended up returning the original host id (100) at line 170. The name of the method “org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector.selectHypervisorHost” does not say much, and its execution does not make much sense to me. I believe it can be removed without any harm. |
DaanHoogland
commented
Nov 11, 2015
@rafaelweingartner nice analysis. meaning, all of my change is senseless. I think the conclusion of your research is that the side effects for CopyCommand are none and we can actually remove this bit of the code. @snuf can you concur? |
DaanHoogland
commented
Nov 11, 2015
running the regression tests on this but these are not in ovm(yet) will look into that. |
rafaelweingartner
commented
Nov 11, 2015
Cool, |
DaanHoogland
commented
Nov 11, 2015
see INFRA-10703 at the apache jira :) and cast your vote for it |
DaanHoogland
commented
Nov 13, 2015
did the sbp regression tests on this: and these do not include ovm tests however and were only run with a 2 kvm host config. will run with a 2 xen host config, now |
rafaelweingartner
commented
Nov 13, 2015
Before you run the Xen tests, I think you should apply the changes we talked about in "XenServerGuru.java" and remove the method "EndPoint selectHypervisorHost(Scope scope);" from "EndPointSelector.java" |
DaanHoogland
commented
Nov 13, 2015
@rafaelweingartner too late 😢 is running, next spin. |
rafaelweingartner
commented
Nov 24, 2015
@DaanHoogland, would you like me to finish the changes that we need, so we can proceed with this PR? |
DaanHoogland
commented
Nov 24, 2015
@rafaelweingartner please go ahead |
DaanHoogland
commented
Dec 6, 2015
#1177 obsoleted this |
rafaelweingartner
commented
Dec 6, 2015
Actually, the one that obsoleted this is #1124 |
DaanHoogland
commented
Dec 6, 2015
@rafaelweingartner you better read #1177, part of #1124 will no longer merge cleanly because of the ovm3 changes. |
rafaelweingartner
commented
Dec 6, 2015
@DaanHoogland PR #1124 rebased on top of master. |
CID-1338387: Deletion of method endPointSelector.selectHypervisorHostFollowing the discussions and analysis presented on PR #1056 create by @DaanHoogland This PR is intended to push those changes that were discussed there regarding the of endPointSelector.selectHypervisorHost method. * pr/1124: Deletion of method endPointSelector.selectHypervisorHost Signed-off-by: Will Stevens <williamstevens@gmail.com>
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template. adjust Java doc at HypervisorGuru.getCommandHostDelegation(long, Command) change method findHostToOperateOnSnapshot change method findHostToOperateOnSnapshot to find any host of the same zone and hypervisor type Changes to take into consideration managed storage
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template.
…ed based on snapshots The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template. Consider using Disabled hosts when no Enabled hosts are found This also closesapache#2317
…ed based on snapshots The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template. Consider using Disabled hosts when no Enabled hosts are found This also closesapache#2317
…ed based on snapshots The first PR(apache#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in apache#1124 after a long discussion and analysis in apache#1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in apache#1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template. Consider using Disabled hosts when no Enabled hosts are found This also closesapache#2317
…ed based on snapshots (#2315) The first PR(#1176) intended to solve #CLOUDSTACK-9025 was only tackling the problem for CloudStack deployments that use single hypervisor types (restricted to XenServer). Additionally, the lack of information regarding that solution (poor documentation, test cases and description in PRs and Jira ticket) led the code to be removed in #1124 after a long discussion and analysis in #1056. That piece of code seemed logicless (and it was!). It would receive a hostId and then change that hostId for other hostId of the zone without doing any check; it was not even checking the hypervisor and storage in which the host was plugged into. The problem reported in #CLOUDSTACK-9025 is caused by partial snapshots that are taken in XenServer. This means, we do not take a complete snapshot, but a partial one that contains only the modified data. This requires rebuilding the VHD hierarchy when creating a template out of the snapshot. The point is that the first hostId received is not a hostId, but a system VM ID(SSVM). That is why the code in #1176 fixed the problem for some deployment scenarios, but would cause problems for scenarios where we have multiple hypervisors in the same zone. We need to execute the creation of the VHD that represents the template in the hypervisor, so the VHD chain can be built using the parent links. This commit changes the method com.cloud.hypervisor.XenServerGuru.getCommandHostDelegation(long, Command). From now on we replace the hostId that is intended to execute the “copy command” that will create the VHD of the template according to some conditions that were already in place. The idea is that starting with XenServer 6.2.0 hotFix ESP1004 we need to execute the command in the hypervisor host and not from the SSVM. Moreover, the method was improved making it readable and understandable; it was also created test cases assuring that from XenServer 6.2.0 hotFix ESP1004 and upward versions we change the hostId that will be used to execute the “copy command”. Furthermore, we are not selecting a random host from a zone anymore. A new method was introduced in the HostDao called “findHostConnectedToSnapshotStoragePoolToExecuteCommand”, using this method we look for a host that is in the cluster that is using the storage pool where the volume from which the Snaphost is taken of. By doing this, we guarantee that the host that is connected to the primary storage where all of the snapshots parent VHDs are stored is used to create the template. Consider using Disabled hosts when no Enabled hosts are found This also closes#2317
Refatoração nos _parsers_ do Usage Closesapache#1056, apache#2373, and apache#2387 See merge request scclouds/scclouds!966
I have removed the paramoia null check and created a specific exception as i think we always should for any specific condition. This would require careful consideration each time on whether and how specific the condition is of course ;)