Skip to content

Commit 284e2d6

Browse files
In case we cannot update the password of all hosts in a cluster, please stop and notify the user about the failure.
- The host id that failed to get updated will be informed in the error. Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
1 parent ea9db19 commit 284e2d6

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,28 +2234,31 @@ private boolean doUpdateHostPassword(final long hostId) {
22342234
nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
22352235
final String password = nv.getValue();
22362236
final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password);
2237-
_agentMgr.easySend(hostId, cmd);
2238-
return true;
2237+
final Answer answer = _agentMgr.easySend(hostId, cmd);
2238+
return answer != null;
22392239
}
22402240

22412241
@Override
22422242
public boolean updateClusterPassword(final UpdateHostPasswordCmd command) {
22432243
// get agents for the cluster
22442244
final List<HostVO> hosts = listAllHostsInCluster(command.getClusterId());
2245-
for (final HostVO h : hosts) {
2245+
for (final HostVO host : hosts) {
22462246
try {
22472247
/*
22482248
* FIXME: this is a buggy logic, check with alex. Shouldn't
22492249
* return if propagation return non null
22502250
*/
2251-
final Boolean result = propagateResourceEvent(h.getId(), ResourceState.Event.UpdatePassword);
2251+
final Boolean result = propagateResourceEvent(host.getId(), ResourceState.Event.UpdatePassword);
22522252
if (result != null) {
22532253
return result;
22542254
}
22552255
} catch (final AgentUnavailableException e) {
22562256
s_logger.error("Agent is not availbale!", e);
22572257
}
2258-
doUpdateHostPassword(h.getId());
2258+
final boolean isUpdated = doUpdateHostPassword(host.getId());
2259+
if (!isUpdated) {
2260+
throw new CloudRuntimeException("CloudStack failed to update the password of the Host with ID ==> " + host.getId() + ". Please make sure you are still able to connect to your hosts.");
2261+
}
22592262
}
22602263

22612264
return true;

0 commit comments

Comments
 (0)