bhouse-nexthop commented on PR #14207:
URL: https://github.com/apache/cloudstack/pull/14207#issuecomment-7138399058

   @jmsperu thanks for testing, and for checking the unknown-instance side.
   
   The race is hard to hit by hand because two things have to line up: the 
forced report has to be **collected** before the new domain exists, and 
**processed** after the start job has finished (while the job is still pending, 
the report is postponed). Normally the report is processed moments after it is 
collected, so the window is tiny. You can widen it with stock agent settings:
   
   1. On the test host, in `agent.properties`, then restart the agent:
      ```
      libvirt.events.enabled=true
      agent.health.check.script.path=/usr/local/bin/slow-ping.sh
      ```
      with `/usr/local/bin/slow-ping.sh` (executable):
      ```
      #!/bin/bash
      sleep 30
      exit 0
      ```
      - Without `libvirt.events.enabled=true` (default `false`) the agent sends 
no forced report at all, so a kill only shows up in the next regular ping, 
which keeps the graceful period.
      - `getCurrentStatus()` builds the instance list first and runs the health 
check script after it, so every ping (forced or not) now reaches the management 
server 30 s after its list was taken.
   2. Keep a throwaway domain W running on that host. It doesn't need to be a 
CloudStack instance.
   3. Crash W with `kill -9 <qemu pid>` or `poweroff` inside the guest. Not 
`virsh destroy`: that is a `DESTROYED` stop, and the agent ignores it.
   4. Right after that, deploy VM N to the same host (`hostid=`), with a non-HA 
offering and a template already on primary storage, so it is Running well 
within the 30 s.
   
   When the forced report lands, N is Running on the host, but it isn't in the 
report.
   - **Stock:** N is marked `PowerReportMissing`, its NIC is released and it 
goes to Stopped (`... is sync-ed to at Stopped state according to power-off 
report from hypervisor`), with no StopCommand. The domain keeps running in 
`virsh list`.
   - **With the PR:** `vm id: N - state changed at ..., which is within the 
graceful period (120000 ms); the report may have been collected before that 
change, skipping missing report`, and N stays Running.
   
   The 30 s sleep also delays agent startup and every regular ping by 30 s, so 
use it on a test host only, and remove it afterwards.
   
   ---
   
   This now has two code approvals (@DaanHoogland, @Damans227) and an 
independent test report. @DaanHoogland, could you merge it for 4.22.3 if you're 
happy with it? With the 24.0 freeze this week, merging it into 4.22 now also 
takes it into 24.0.
   


-- 
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