The way the deployVM command works is that it first runs the create() where it checks the requirements, returns the jobid and then the execute() where it starts the VM if specified. Perhaps the VM can be started in create() itself if startvm is true and return a future which is then checked in execute()
________________________________ From: Rakesh Venkatesh <www.rakeshv....@gmail.com> Sent: Thursday, July 29, 2021 12:47 PM To: dev <dev@cloudstack.apache.org> Subject: Re: Code executed twice while deploying VM Is there a way second computation can be avoided if "startvm" or some other flag to indicate starting the vm flag is passed? On Thu, Jul 29, 2021 at 8:15 AM David Jumani <david.jum...@shapeblue.com> wrote: > Hi Rakesh, > > If I'm right, that's because a VM can be deployed without starting it. It > initially checks whether the VM can be deployed, and once again before > starting as things might change (if started some time after deployment) > I'm all for optimizing the code but this is the reason I see the > duplication of code / computation > > ________________________________ > From: Rakesh Venkatesh > <www.rakeshv....@gmail.com<http://www.rakeshv....@gmail.com>> > Sent: Wednesday, July 28, 2021 2:34 PM > To: users <us...@cloudstack.apache.org>; dev <dev@cloudstack.apache.org> > Subject: Code executed twice while deploying VM > > Hello Users/Devs > > > Today I observed that while deploying a VM, the same code is executed > twice: the first time, while trying to find a suitable deployment > destination and the second time, while trying to start a VM. I think this > is a redundant process and also time-consuming since the same calculations > are done twice. These are the one of the duplicate logs > > Asyn job is created > 2021-07-28 09:01:27,964 (logid:10ac9f28) ZoneWideStoragePoolAllocator to > find storage pool > > Now it finds a suitable destination > Returning Deployment Destination: > > Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] > : Dest[Zone(1)-Pod(1)-Cluster(1)-Host(1)-Storage(Volume(23|ROOT-->Pool(3))] > > VM start attempt #1 > > 2021-07-28 09:01:36,039 job-174/job-175 ctx-b815930d) (logid:10ac9f28) > ZoneWideStoragePoolAllocator to find storage pool > > > From the above two logs, I can see that starting at 9:01:27 and 09:01:36, > its doing the same calculations. > if I see the logs before and after the above-mentioned logs, they are all > same. They try to find a suitable host, a suitable storage pool, and so on. > In the production platform, the calculation is done twice and this takes a > lot of time to deploy a VM. > > Do you guys also think this is an issue or redundant process and needs to > be improved? Or any other suggestions to avoid double calculation? > > -- > Thanks and regards > Rakesh > > > > -- Thanks and regards Rakesh venkatesh