Skip to content

Commit dec9133

Browse files
committed
CLOUDSTACK-7184: xenheartbeat gets passed timeout and interval
(cherry picked from commit 4d065b9) Conflicts: plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java server/src/com/cloud/configuration/Config.java server/src/com/cloud/configuration/ConfigurationManagerImpl.java server/src/com/cloud/resource/DiscovererBase.java
1 parent 2cd99e3 commit dec9133

9 files changed

Lines changed: 36 additions & 11 deletions

File tree

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui
346346
details.put("wait", Integer.toString(_wait));
347347
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
348348
params.put(Config.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenServerMaxNics.toString()));
349+
params.put(Config.XenServerHeartBeatTimeout.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatTimeout.toString()));
349350
params.put(Config.XenServerHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatInterval.toString()));
350351
params.put(Config.InstanceName.toString().toLowerCase(), _instance);
351352
details.put(Config.InstanceName.toString().toLowerCase(), _instance);

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
285285
protected IAgentControl _agentControl;
286286

287287
final int _maxWeight = 256;
288+
protected int _heartbeatTimeout = 120;
288289
protected int _heartbeatInterval = 60;
289290
protected final XsHost _host = new XsHost();
290291

@@ -4494,8 +4495,10 @@ private void cleanupTemplateSR(Connection conn) {
44944495
}
44954496

44964497
protected boolean launchHeartBeat(Connection conn) {
4497-
String result = callHostPluginPremium(conn, "heartbeat", "host", _host.uuid, "interval", Integer
4498-
.toString(_heartbeatInterval));
4498+
String result = callHostPluginPremium(conn, "heartbeat",
4499+
"host", _host.uuid,
4500+
"timeout", Integer.toString(_heartbeatTimeout),
4501+
"interval", Integer.toString(_heartbeatInterval));
44994502
if (result == null || !result.contains("> DONE <")) {
45004503
s_logger.warn("Unable to launch the heartbeat process on " + _host.ip);
45014504
return false;
@@ -5573,6 +5576,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
55735576
_storageNetworkName1 = (String)params.get("storage.network.device1");
55745577
_storageNetworkName2 = (String)params.get("storage.network.device2");
55755578

5579+
_heartbeatTimeout = NumbersUtil.parseInt((String)params.get("xenserver.heartbeat.timeout"), 120);
55765580
_heartbeatInterval = NumbersUtil.parseInt((String)params.get("xenserver.heartbeat.interval"), 60);
55775581

55785582
String value = (String)params.get("wait");

scripts/vm/hypervisor/xenserver/launch_hb.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ if [ -z $2 ]; then
3333
exit 3
3434
fi
3535

36+
if [ -z $3 ]; then
37+
usage
38+
exit 3
39+
fi
40+
3641
if [ ! -f /opt/cloud/bin/xenheartbeat.sh ]; then
3742
printf "Error: Unable to find xenheartbeat.sh to launch\n"
3843
exit 4
@@ -42,5 +47,5 @@ for psid in `ps -ef | grep xenheartbeat | grep -v grep | awk '{print $2}'`; do
4247
kill $psid
4348
done
4449

45-
nohup /opt/cloud/bin/xenheartbeat.sh $1 $2 >/dev/null 2>/dev/null &
50+
nohup /opt/cloud/bin/xenheartbeat.sh $1 $2 $3 >/dev/null 2>/dev/null &
4651
echo "======> DONE <======"

scripts/vm/hypervisor/xenserver/vmopspremium

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ def setup_heartbeat_file(session, args):
127127
@echo
128128
def heartbeat(session, args):
129129
host = args['host']
130+
timeout = args['timeout']
130131
interval = args['interval']
131132
try:
132-
cmd = ["/bin/bash", "/opt/cloud/bin/launch_hb.sh", host, interval]
133+
cmd = ["/bin/bash", "/opt/cloud/bin/launch_hb.sh", host, timeout, interval]
133134
txt = util.pread2(cmd)
134135
except:
135136
txt='fail'

scripts/vm/hypervisor/xenserver/xenheartbeat.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ usage() {
2626
if [ -z $1 ]; then
2727
usage
2828
exit 2
29+
else
30+
host=$1
2931
fi
3032

3133
if [ -z $2 ]; then
3234
usage
3335
exit 3
36+
else
37+
timeout=$2
3438
fi
3539

3640
if [ ! -z $3 ]; then
@@ -39,15 +43,15 @@ else
3943
interval=5
4044
fi
4145

42-
if [ $interval -gt $2 ]; then
46+
if [ $interval -gt $timeout ]; then
4347
usage
4448
exit 3
4549
fi
4650

4751
file=/opt/cloud/bin/heartbeat
4852
lastdate=$(($(date +%s) + $interval))
4953

50-
while [ $(date +%s) -lt $(($lastdate + $2)) ]
54+
while [ $(date +%s) -lt $(($lastdate + $timeout)) ]
5155
do
5256
sleep $interval
5357

@@ -69,7 +73,7 @@ do
6973
for dir in $dirs
7074
do
7175
if [ -d $dir ]; then
72-
hb=$dir/hb-$1
76+
hb=$dir/hb-$host
7377
date +%s | dd of=$hb count=100 bs=1 2>/dev/null
7478
if [ $? -ne 0 ]; then
7579
/usr/bin/logger -t heartbeat "Potential problem with $hb: not reachable since $(($(date +%s) - $lastdate)) seconds"
@@ -89,7 +93,7 @@ do
8993
do
9094
mp=`mount | grep $dir`
9195
if [ -n "$mp" ]; then
92-
hb=$dir/hb-$1
96+
hb=$dir/hb-$host
9397
date +%s | dd of=$hb count=100 bs=1 2>/dev/null
9498
if [ $? -ne 0 ]; then
9599
/usr/bin/logger -t heartbeat "Potential problem with $hb: not reachable since $(($(date +%s) - $lastdate)) seconds"

server/src/com/cloud/configuration/Config.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,21 @@ public enum Config {
10991099
null),
11001100
XenServerSetupMultipath("Advanced", ManagementServer.class, String.class, "xenserver.setup.multipath", "false", "Setup the host to do multipath", null),
11011101
XenServerBondStorageNic("Advanced", ManagementServer.class, String.class, "xenserver.bond.storage.nics", null, "Attempt to bond the two networks if found", null),
1102+
XenServerHeartBeatTimeout(
1103+
"Advanced",
1104+
ManagementServer.class,
1105+
Integer.class,
1106+
"xenserver.heartbeat.timeout",
1107+
"120",
1108+
"heartbeat timeout to use when implementing XenServer Self Fencing",
1109+
null),
11021110
XenServerHeartBeatInterval(
11031111
"Advanced",
11041112
ManagementServer.class,
11051113
Integer.class,
11061114
"xenserver.heartbeat.interval",
11071115
"60",
1108-
"heartbeat to use when implementing XenServer Self Fencing",
1116+
"heartbeat interval to use when checking before XenServer Self Fencing",
11091117
null),
11101118
XenServerGuestNetwork("Hidden", ManagementServer.class, String.class, "xenserver.guest.network.device", null, "Specify for guest network name label", null),
11111119
XenServerMaxNics("Advanced", AgentManager.class, Integer.class, "xenserver.nics.max", "7", "Maximum allowed nics for Vms created on XenServer", null),

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ private void populateConfigValuesForValidationSet() {
363363
configValuesForValidation.add("storage.cleanup.interval");
364364
configValuesForValidation.add("wait");
365365
configValuesForValidation.add("xenserver.heartbeat.interval");
366+
configValuesForValidation.add("xenserver.heartbeat.timeout");
366367
configValuesForValidation.add("incorrect.login.attempts.allowed");
367368
}
368369

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ protected HashMap<String, Object> buildConfigParams(HostVO host) {
137137
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
138138
params.put(Config.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenServerMaxNics.toString()));
139139
params.put(Config.XenServerHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatInterval.toString()));
140+
params.put(Config.XenServerHeartBeatTimeout.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatTimeout.toString()));
140141
params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
141142

142143
return params;

systemvm/patches/debian/config/root/redundant_router/check_heartbeat.sh.templ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ then
4545
[RROUTER_BIN_PATH]/primary-backup.sh fault >> [RROUTER_LOG] 2>&1
4646
service keepalived stop >> [RROUTER_LOG] 2>&1
4747
service conntrackd stop >> [RROUTER_LOG] 2>&1
48-
pkill -9 keepalived >> [RROUTER_LOG] 2>&1
49-
pkill -9 conntrackd >> [RROUTER_LOG] 2>&1
48+
pkill -9 keepalived >> [RROUTER_LOG] 2>&1
49+
pkill -9 conntrackd >> [RROUTER_LOG] 2>&1
5050
echo Status: FAULT \(keepalived process is dead\) >> [RROUTER_LOG]
5151
exit
5252
fi

0 commit comments

Comments
 (0)