RosiKyu commented on PR #11981:
URL: https://github.com/apache/cloudstack/pull/11981#issuecomment-3811353819
Sorry, verification failed:
With the following:
The PR improves error messaging by:
- Showing detailed failure info (`e.getMessage()`) for **admin users**
- Showing generic "Please contact administrator" for **regular users**
- Including VM UUID in the error message
- Code Change
```java
// Before
throw new CloudRuntimeException("Network is unavailable. Please contact
administrator", e).add(VirtualMachine.class, vmUuid);
// After
Account callingAccount = CallContext.current().getCallingAccount();
String errorSuffix = (callingAccount != null && callingAccount.getType() ==
Account.Type.ADMIN) ?
String.format("Failure: %s", e.getMessage()) :
"Please contact administrator.";
throw new CloudRuntimeException(String.format("The Network for VM %s is
unavailable. %s", vmUuid, errorSuffix), e).add(VirtualMachine.class, vmUuid);
```
- Test Scenarios Attempted
Scenario 1: Stop VR and Deploy VM
**Steps:**
1. Created isolated network `test-network`
2. Deployed VM to trigger VR creation
3. Stopped VR via CloudMonkey: `stop router id=<uuid>`
4. Attempted to deploy another VM
**Result:** Could not reproduce
CloudStack automatically started the VR when deploying a new VM.
---
Scenario 2: Destroy VR at Hypervisor Level
**Steps:**
1. Destroyed VR using `virsh destroy r-4-VM` on KVM host
2. Attempted to deploy a new VM
**Result:** Code path not triggered
**Error received:**
```
Unable to start a VM [282c7323-bc57-4925-a80f-2d822346c3e0] due to [Unable
to create a deployment for VM instance {...}]
```
**Log analysis:**
```
ResourceUnavailableException: Resource [DataCenter:1] is unreachable: Unable
to apply dhcp entry on router
```
The exception scope was `DataCenter`, not `VirtualRouter.class`. The PR's
condition `e.getScope().equals(VirtualRouter.class)` was **not satisfied**.
---
Scenario 3: Simulate VR Version Mismatch via DB
**Steps:**
1. Updated database: `UPDATE domain_router SET update_state =
'UPDATE_NEEDED' WHERE id = 4;`
2. Updated database: `UPDATE domain_router SET software_version = '4.19.0.0'
WHERE id = 4;`
3. Stopped VR
4. Attempted to deploy a new VM
**Result:** Could not reproduce
CloudStack deployed the VM successfully, ignoring the `UPDATE_NEEDED` state.
**Note:** Global setting `router.version.check = true` was already enabled.
---
### Observations
1. **Auto-start behavior:** CloudStack automatically starts a stopped VR
when a VM deployment requires it.
2. **Exception scope mismatch:** The `ResourceUnavailableException` we
triggered had scope `DataCenter`, not `VirtualRouter.class`. The PR's code path
requires `VirtualRouter.class` scope.
3. **Version check bypass:** Setting `update_state = 'UPDATE_NEEDED'` in the
database did not prevent VM deployments or trigger the expected error path.
4. **Original issue context:** The original issue (#11980) describes a
scenario with actual VR version mismatch (VR on 4.20.1, MS on 4.20.2) during a
live upgrade. This specific condition could not be simulated in the test
environment.
#### Conclusion
**Status:** Unable to reproduce the exact error path
The specific code path modified by PR #11981 requires a
`ResourceUnavailableException` with scope `VirtualRouter.class`. Despite
multiple attempts to simulate VR unavailability:
- Stopping the VR
- Destroying the VR at hypervisor level
- Manipulating database version/state fields
I could not trigger the exact condition where this error message would be
displayed.
--
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]