Yes, the main bug here is not updating the Total Capacity - this is avoiding the total getting updated on host reconnects.
Bug with the Used and Reserved Capacities gets masked since CapacityManager also listens to the VM state changes and updates these values. Prachi -----Original Message----- From: Darren Shepherd [mailto:darren.s.sheph...@gmail.com] Sent: Wednesday, September 25, 2013 1:45 PM To: dev@cloudstack.apache.org Subject: Re: bug? capacity not updated when adding memory to hypervisor The main bug being the lack of memCap.setTotalCapacity(host.getTotalMemory()); Darren On Wed, Sep 25, 2013 at 1:13 PM, Daan Hoogland <daan.hoogl...@gmail.com> wrote: > I agree Darren, > > if (cpuCap.getUsedCapacity() == usedCpu && > cpuCap.getReservedCapacity() == reservedCpu) { } else { > if (cpuCap.getReservedCapacity() != reservedCpu) { > cpuCap.setReservedCapacity(reservedCpu); > } > if (cpuCap.getUsedCapacity() != usedCpu) { > cpuCap.setUsedCapacity(usedCpu); > } > } > > makes more sense. (same for mem) > > > On Wed, Sep 25, 2013 at 9:59 PM, Darren Shepherd < > darren.s.sheph...@gmail.com> wrote: > >> I added more memory to a hypervisor, and the host tables was updated >> properly, but the op_host_capacity is not updated. I tracked down >> the code to CapacityManagerImpl.updateCapacityForHost. The below >> logic seems completely wrong. Unless I'm reading it wrong, it seems >> like it will only update EITHER used or reserved (not both) and never >> update total. I removed log statements to make it more readable. >> >> if (cpuCap.getUsedCapacity() == usedCpu && >> cpuCap.getReservedCapacity() == reservedCpu) { >> } else if (cpuCap.getReservedCapacity() != reservedCpu) { >> cpuCap.setReservedCapacity(reservedCpu); >> } else if (cpuCap.getUsedCapacity() != usedCpu) { >> cpuCap.setUsedCapacity(usedCpu); >> } >> >> if (memCap.getUsedCapacity() == usedMemory && >> memCap.getReservedCapacity() == reservedMemory) { >> } else if (memCap.getReservedCapacity() != reservedMemory) { >> memCap.setReservedCapacity(reservedMemory); >> } else if (memCap.getUsedCapacity() != usedMemory) { >> memCap.setUsedCapacity(usedMemory); >> } >>