Skip to content

Commit 68f309d

Browse files
committed
clvm HA 상태 체크 쉘 스크립트 버그 수정
1 parent 6fc8dda commit 68f309d

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public String createHeartBeatCommand(HAStoragePool primaryStoragePool, String ho
400400
rbdPoolName = pdef.getSourceDir();
401401
authUserName = pdef.getAuthUserName();
402402
}
403-
if (pdef.getPoolType() == PoolType.DIR) {
403+
if (pdef.getPoolType() == PoolType.DIR && !"/var/lib/libvirt/images".equals(pdef.getTargetPath())) {
404404
logger.debug(String.format("SharedMountPoint Pool source path [%s]", pdef.getTargetPath()));
405405
smpTargetPath = pdef.getTargetPath();
406406
}
@@ -484,7 +484,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
484484
rbdPoolName = pdef.getSourceDir();
485485
authUserName = pdef.getAuthUserName();
486486
}
487-
if (pdef.getPoolType() == PoolType.DIR) {
487+
if (pdef.getPoolType() == PoolType.DIR && !"/var/lib/libvirt/images".equals(pdef.getTargetPath())) {
488488
logger.debug(String.format("SharedMountPoint Pool source path [%s]", pdef.getTargetPath()));
489489
smpTargetPath = pdef.getTargetPath();
490490
}
@@ -608,7 +608,7 @@ public Boolean vmActivityCheck(HAStoragePool pool, HostTO host, Duration activit
608608
rbdPoolName = pdef.getSourceDir();
609609
authUserName = pdef.getAuthUserName();
610610
}
611-
if (pdef.getPoolType() == PoolType.DIR) {
611+
if (pdef.getPoolType() == PoolType.DIR && !"/var/lib/libvirt/images".equals(pdef.getTargetPath())) {
612612
logger.debug(String.format("SharedMountPoint Pool source path [%s]", pdef.getTargetPath()));
613613
smpTargetPath = pdef.getTargetPath();
614614
}

scripts/vm/hypervisor/kvm/kvmheartbeat_clvm.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
# under the License.
1818

1919
help() {
20-
printf "Usage: $0
20+
printf "Usage: $0
2121
-p rbd pool name
2222
-n rbd pool auth username
2323
-g sharedmountpoint type GFS2 path
2424
-h host ip
2525
-q clvm pool mount source path
26-
-r write/read hb log
26+
-r write/read hb log
2727
-c cleanup
2828
-t interval between read hb log\n"
2929
exit 1
@@ -34,11 +34,11 @@ RbdPoolAuthUserName=
3434
GfsPoolPath=
3535
HostIP=
3636
poolPath=
37-
interval=
37+
interval=0
3838
rflag=0
3939
cflag=0
4040

41-
while getopts 'p:n:g:h:q:t:r:c' OPTION
41+
while getopts 'p:n:g:h:q:t:rc' OPTION
4242
do
4343
case $OPTION in
4444
p)
@@ -55,23 +55,22 @@ do
5555
;;
5656
q)
5757
poolPath="$OPTARG"
58-
;;
58+
;;
5959
t)
6060
interval="$OPTARG"
6161
;;
6262
r)
63-
rflag=1
63+
rflag=1
6464
;;
6565
c)
66-
cflag=1
66+
cflag=1
6767
;;
6868
*)
6969
help
7070
;;
7171
esac
7272
done
7373

74-
7574
hbFolder=$GfsPoolPath/MOLD-HB
7675
hbFile=$hbFolder/$HostIP
7776

@@ -83,19 +82,18 @@ write_hbLog() {
8382
if [ $? -eq 0 ]
8483
then
8584
Timestamp=$(date +%s)
86-
if [ -n $RbdPoolName ] ; then
85+
if [ -n "$RbdPoolName" ]; then
8786
obj=$(rbd -p $RbdPoolName ls --id $RbdPoolAuthUserName | grep MOLD-HB)
8887
if [ $? -gt 0 ]; then
8988
rbd -p $RbdPoolName create --size 1 --id $RbdPoolAuthUserName MOLD-HB
9089
fi
91-
obj=$(rbd -p $RbdPoolName --id $RbdPoolAuthUserName image-meta set MOLD-HB $HostIP $Timestamp)`
92-
93-
elif [ -n $GfsPoolPath ] ; then
90+
obj=$(rbd -p $RbdPoolName --id $RbdPoolAuthUserName image-meta set MOLD-HB $HostIP $Timestamp)
91+
elif [ -n "$GfsPoolPath" ] ; then
9492
stat $hbFile &> /dev/null
9593
if [ $? -gt 0 ] ; then
9694
mkdir -p $hbFolder &> /dev/null
9795
touch $hbFile &> /dev/null
98-
if [ $? -gt 0 ] ; then
96+
if [ $? -gt 0 ] ; then
9997
printf "Failed to create $hbFile"
10098
return 2
10199
fi
@@ -119,13 +117,13 @@ write_hbLog() {
119117
check_hbLog() {
120118
#check the heart beat log
121119
now=$(date +%s)
122-
if [ -n $RbdPoolName ] ; then
120+
if [ -n "$RbdPoolName" ] ; then
123121
getHbTime=$(rbd -p $RbdPoolName --id $RbdPoolAuthUserName image-meta get MOLD-HB $HostIP)
124122
if [ $? -gt 0 ] || [ -z "$getHbTime" ]; then
125123
return 1
126124
fi
127125
diff=$(expr $now - $getHbTime)
128-
elif [ -n $GfsPoolPath ] ; then
126+
elif [ -n "$GfsPoolPath" ] ; then
129127
now=$(date +%s)
130128
hb=$(cat $hbFile)
131129
diff=$(expr $now - $hb)

scripts/vm/hypervisor/kvm/kvmheartbeat_rbd.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ if [ -n "$UUIDList" ]; then
9393
objId=$(rbd -p $PoolName info $uuid --id $PoolAuthUserName | grep 'id:')
9494
objId=${objId#*id: }
9595
res=$(timeout 3s bash -c "rados -p $PoolName touch rbd_object_map.$objId")
96-
if [ $? -eq 0 ]; then
97-
# 정상적인 touch 상태면 image meta에 key: uuid / value : timestamp 입력
98-
rbd -p $PoolName --id $PoolAuthUserName image-meta set MOLD-AC $uuid $HostIP:$timestamp
99-
else
100-
# 정상적으로 touch 상태가 아니면 image meta에 key : uuid 삭제
101-
rbd -p $PoolName --id $PoolAuthUserName image-meta rm MOLD-AC $uuid
102-
fi
103-
done
96+
if [ $? -eq 0 ]; then
97+
# 정상적인 touch 상태면 image meta에 key: uuid / value : timestamp 입력
98+
rbd -p $PoolName --id $PoolAuthUserName image-meta set MOLD-AC $uuid $HostIP:$timestamp
99+
else
100+
# 정상적으로 touch 상태가 아니면 image meta에 key : uuid 삭제
101+
rbd -p $PoolName --id $PoolAuthUserName image-meta rm MOLD-AC $uuid
102+
fi
103+
done
104104
fi
105105

106106
#write the heart beat log

0 commit comments

Comments
 (0)