weizhouapache commented on PR #14623:
URL: https://github.com/apache/cloudstack/pull/14623#issuecomment-6764401395

   I ran this change on a KVM + Ceph RBD test environment (two KVM hosts, two 
RBD primary storage pools) to check whether the libvirt cache-miss path behaves 
as the PR describes.
   
   **Test change.** The existing smoke tests `test_08_resize_volume` and 
`test_12_resize_volume_with_only_size_parameter` only resized DATADISK volumes. 
I added a step to both tests that grows the VM's ROOT volume by 1 GB while the 
VM keeps running, and checks that the volume reaches the new size and is 
`Ready`. The step has no storage-type filter, so it runs on any primary storage.
   
   <details>
   <summary>Diff of the test change 
(test/integration/smoke/test_volumes.py)</summary>
   
   ```diff
   @@ -746,6 +746,8 @@ class TestVolumes(cloudstackTestCase):
                    "Check if the root volume resized appropriately"
                )
    
   +        self.resize_root_volume()
   +
            # start the vm if it is on xenserver
    
            if hosts[0].hypervisor == "XenServer":
   @@ -977,6 +979,8 @@ class TestVolumes(cloudstackTestCase):
                "Check if the data volume resized appropriately"
            )
    
   +        self.resize_root_volume()
   +
            # start the vm if it is on xenserver
    
            if hosts[0].hypervisor == "XenServer":
   @@ -984,6 +988,28 @@ class TestVolumes(cloudstackTestCase):
                time.sleep(30)
            return
    
   +    def resize_root_volume(self):
   +        """Grow the ROOT volume of the VM by one GB, on any primary storage 
type."""
   +        root = self.wait_for_attributes_and_return_root_vol()
   +        new_size_gb = int(math.ceil(float(root.size) / (1024 ** 3))) + 1
   +        self.debug("Resize ROOT volume (ID: %s) to %d GB" % (root.id, 
new_size_gb))
   +
   +        cmd = resizeVolume.resizeVolumeCmd()
   +        cmd.id = root.id
   +        cmd.size = new_size_gb
   +        self.apiClient.resizeVolume(cmd)
   +
   +        def root_resized():
   +            vols = Volume.list(self.apiClient, id=root.id, listall=True)
   +            if isinstance(vols, list) and len(vols) > 0:
   +                vol = vols[0]
   +                if int(vol.size) == new_size_gb * (1024 ** 3) and vol.state 
== 'Ready':
   +                    return True, vol
   +            return False, None
   +
   +        res, _ = wait_until(5, 36, root_resized)
   +        self.assertTrue(res, "Check if the ROOT volume resized 
appropriately")
   +
        def wait_for_attributes_and_return_root_vol(self):
            def checkVolumeResponse():
   ```
   
   </details>
   
   **Reproduction.** I created a data volume, attached it to a running VM on 
one host (which makes the agent create the RBD image through librbd), then 
resized it right away. Right after the attach, `virsh vol-info` on that host 
returned `Storage volume not found`, so libvirt's cache did not have the image. 
On the unpatched agent, the resize then failed with the `Storage volume not 
found` error from this PR.
   
   **Results.**
   - Unpatched agent, 6 runs of `test_08` and `test_12`: 3 runs failed in the 
ROOT-volume resize with this error. One more run failed earlier, in a test 
helper, before the resize.
   - Patched agent, same repro, 5 runs: all 5 resizes succeeded. In 3 of them 
the agent logged that the volume was missing from libvirt's cache, refreshed 
the pool, and found the volume on the retry.
   
   **Notes.** The refresh runs on the pool lookup, so it is limited to the RBD 
pool and the one lookup that misses. The unpatched runs show that the refresh 
is needed, and the patched runs show that it recovers from the miss. I have not 
tested a non-RBD pool, a volume that is already in libvirt's cache, or a shrink.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to