From e0072edf4b842d577f35b87732a479ea36b44442 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 23 Feb 2012 14:09:48 -0800 Subject: [PATCH] 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 --- utils/src/com/cloud/utils/script/Script.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/utils/src/com/cloud/utils/script/Script.java b/utils/src/com/cloud/utils/script/Script.java index 91835cb405c..31da66e4ac0 100755 --- a/utils/src/com/cloud/utils/script/Script.java +++ b/utils/src/com/cloud/utils/script/Script.java @@ -48,7 +48,7 @@ public class Script implements Callable { 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 { _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 { 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 { _logger.trace("Script ran within the alloted time"); } catch (IllegalThreadStateException e) { _logger.warn("Interrupting script."); + _isTimeOut = true; _thread.interrupt(); } return null;