Skip to content

Commit ce3550f

Browse files
author
Anthony Xu
committed
CLOUDSTACK-6662
CLOUDSTACK-6844 exit status delivery might get delayed Please enter the commit message for your changes. Lines starting
1 parent bc4be52 commit ce3550f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

utils/src/com/cloud/utils/ssh/SSHCmdHelper.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ public static int sshExecuteCmdOneShotWithExitCode(com.trilead.ssh2.Connection s
155155
String result = sbResult.toString();
156156
if (result != null && !result.isEmpty())
157157
s_logger.debug(cmd + " output:" + result);
158-
159-
return sshSession.getExitStatus();
158+
// exit status delivery might get delayed
159+
for(int i = 0 ; i<10 ; i++ ) {
160+
Integer status = sshSession.getExitStatus();
161+
if( status != null ) {
162+
return status;
163+
}
164+
Thread.sleep(100);
165+
}
166+
return -1;
160167
} catch (Exception e) {
161168
s_logger.debug("Ssh executed failed", e);
162169
throw new SshException("Ssh executed failed " + e.getMessage());

0 commit comments

Comments
 (0)