@@ -5316,6 +5316,21 @@ private boolean noStorageAccessible(){
53165316 return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0 ;
53175317 }
53185318
5319+ @ Transactional (readOnly = true )
5320+ private long getKvmAgentEchoTimeoutAfterDeploy (boolean deployed , boolean restartLibvirtdDuringDeploy ) {
5321+ if (!deployed || !restartLibvirtdDuringDeploy ) {
5322+ return TimeUnit .SECONDS .toMillis (CoreGlobalProperty .REST_FACADE_ECHO_TIMEOUT );
5323+ }
5324+
5325+ long vmCount = Q .New (VmInstanceVO .class )
5326+ .eq (VmInstanceVO_ .hostUuid , self .getUuid ())
5327+ .count ();
5328+ long timeout = KVMHostUtils .calculateLibvirtRestartEchoTimeoutMillis (vmCount );
5329+ logger .info (String .format ("extend kvmagent echo timeout after libvirtd restart on host[uuid:%s, vmCount:%s] to %sms" ,
5330+ self .getUuid (), vmCount , timeout ));
5331+ return timeout ;
5332+ }
5333+
53195334 private void updateHostOsInformation (String distro , String release , String version ) {
53205335 final KVMHostVO kvmHostVO = getSelf ();
53215336 kvmHostVO .setOsDistribution (distro );
@@ -5586,6 +5601,7 @@ public void connectHook(final ConnectHostInfo info, final Completion complete) {
55865601 chain .allowWatch ();
55875602 chain .then (new ShareFlow () {
55885603 boolean deployed = false ;
5604+ boolean restartLibvirtdDuringDeploy = false ;
55895605 @ Override
55905606 public void setup () {
55915607 flow (new NoRollbackFlow () {
@@ -5935,6 +5951,8 @@ public void run(final FlowTrigger trigger, Map data) {
59355951 if (deployArguments .isForceRun ()) {
59365952 runner .setForceRun (true );
59375953 }
5954+ restartLibvirtdDuringDeploy = KVMHostUtils .shouldRestartLibvirtdDuringDeploy (
5955+ deployArguments .getInit (), deployArguments .getRestartLibvirtd ());
59385956
59395957 UriComponentsBuilder ub = UriComponentsBuilder .fromHttpUrl (restf .getBaseUrl ());
59405958 ub .path (new StringBind (KVMConstant .KVM_ANSIBLE_LOG_PATH_FROMAT ).bind ("uuid" , self .getUuid ()).toString ());
@@ -6023,6 +6041,7 @@ public boolean skip(Map data) {
60236041
60246042 @ Override
60256043 public void run (final FlowTrigger trigger , Map data ) {
6044+ final long echoTimeout = getKvmAgentEchoTimeoutAfterDeploy (deployed , restartLibvirtdDuringDeploy );
60266045 restf .echo (echoPath , new Completion (trigger ) {
60276046 @ Override
60286047 public void success () {
@@ -6054,7 +6073,7 @@ public void success() {
60546073 public void fail (ErrorCode errorCode ) {
60556074 trigger .fail (errorCode );
60566075 }
6057- });
6076+ }, TimeUnit . SECONDS . toMillis ( 1 ), echoTimeout );
60586077 }
60596078
60606079 @ Override
@@ -6066,7 +6085,7 @@ public void fail(ErrorCode errorCode) {
60666085 trigger .fail (errorCode );
60676086 }
60686087 }
6069- });
6088+ }, TimeUnit . SECONDS . toMillis ( 1 ), echoTimeout );
60706089 }
60716090 });
60726091
0 commit comments