Bug 13962 - CloudRuntimeException: Failed to update keypairs on disk: cannot create key file null/.ssh/id_rsa

using a flag instead of calculating timeout value. The monitor thread may have inaccurate execution time which
 may cause script forever hang

 status 13962: resolved fixed
 reviewed-by: Alex, Edison
This commit is contained in:
frank 2012-02-23 14:09:48 -08:00
parent 3c61e205a1
commit e0072edf4b
1 changed files with 3 additions and 6 deletions

View File

@ -48,7 +48,7 @@ public class Script implements Callable<String> {
public static final String ERR_EXECUTE = "execute.error";
public static final String ERR_TIMEOUT = "timeout";
private int _defaultTimeout = 3600 * 1000; /* 1 hour */
private long _createTime = System.currentTimeMillis();
private volatile boolean _isTimeOut = false;
private boolean _passwordCommand = false;
@ -117,10 +117,6 @@ public class Script implements Callable<String> {
_workDir = workDir;
}
private boolean isTimeout() {
return (System.currentTimeMillis() - _timeout) > _createTime;
}
protected String buildCommandLine(String[] command) {
StringBuilder builder = new StringBuilder();
boolean obscureParam = false;
@ -213,7 +209,7 @@ public class Script implements Callable<String> {
break;
}
} catch (InterruptedException e) {
if (!isTimeout()) {
if (!_isTimeOut) {
/* This is not timeout, we are interrupted by others, continue */
_logger.debug("We are interrupted but it's not a timeout, just continue");
continue;
@ -284,6 +280,7 @@ public class Script implements Callable<String> {
_logger.trace("Script ran within the alloted time");
} catch (IllegalThreadStateException e) {
_logger.warn("Interrupting script.");
_isTimeOut = true;
_thread.interrupt();
}
return null;