bhouse-nexthop opened a new pull request, #14741: URL: https://github.com/apache/cloudstack/pull/14741
### Description This PR runs the KVM agent restart in `cancelHostMaintenance` with `sudo` when the host user is not root. With `kvm.ssh.to.agent=true`, cancelling maintenance on a KVM host whose agent is not Up restarts the agent over SSH as the host's stored user. The command had no `sudo`: - A host can be added with a non-root user. `LibvirtServerDiscoverer` already runs `sudo cloudstack-setup-agent` for one. - For such a host the restart fails: `Could not restart agent on Host ... Failed to restart cloudstack-agent.service: Interactive authentication required.` Fix: new `getAgentRestartCommand(username)`: | Host user | Command | |---|---| | `root` | `service cloudstack-agent restart` (unchanged) | | other | `sudo service cloudstack-agent restart` | ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] Build/CI - [ ] Test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [x] Minor - [ ] Trivial ### How Has This Been Tested? - Seen on 4.22.1: Ubuntu 24.04 KVM hosts added with user `cloudstack`, which has NOPASSWD sudo for `/usr/sbin/service`. - `ResourceManagerImplTest` passes (74 tests). The mocked host user is `user`, so the existing restart tests now expect `sudo`. New `testGetAgentRestartCommand` covers root and non-root. - Checkstyle is clean for `server`. - Not yet run on the cluster. #### How did you try to break this feature and the system with this change? - Root hosts get the same command as before. - A non-root host user needs passwordless sudo for `service`, which the discoverer already needs for `cloudstack-setup-agent`. -- 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]
