Skip to content

Commit

Permalink
debug: get_nodes_order
Browse files Browse the repository at this point in the history
  • Loading branch information
djangoyi-yunify committed Mar 3, 2021
1 parent 0afceb0 commit cc96302
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ keys = [
"/env/maxConns",
"/env/oplogSize",
"/env/rsName",
"/env/port"
"/env/port",
]
reload_cmd = "appctl changeMongodbCfg"
46 changes: 33 additions & 13 deletions ansible/roles/mongodb/files/opt/app/current/bin/node/replicactl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MS_REPLNOTREADY=97

# flag files
APPCTL_CLUSTER_SCALEVERTICAL=/data/appctl/data/cluster.scalevertical
APPCTL_CLUSTER_STOP=/data/appctl/data/cluster.stop

# common functions

Expand Down Expand Up @@ -39,6 +40,10 @@ isClusterScaleVertical() {
test -f $APPCTL_CLUSTER_SCALEVERTICAL
}

isClusterStop() {
test -f $APPCTL_CLUSTER_STOP
}

# getSid
# desc: get sid from NODE_LIST string
# $1: a NODE_LIST item (5|192.168.1.2)
Expand Down Expand Up @@ -400,20 +405,29 @@ revive() {
start() {
_start

if ! isClusterInitialized; then return; fi
if ! isClusterInitialized; then log "It's a new node, normal start done!"; return; fi
if [ "$ADDING_HOSTS" = "true" ]; then log "Adding new node, it's ok to stop here!"; return; fi

log "cluster restart, or scale vertical, or upgrade"
log "cluster restarted: scale vertical, or upgrade, or normal restart"
# do some checks for sure that the cluster is ok
if [ isClusterScaleVertical ]; then
log "scale vertical ..."
rm -f APPCTL_CLUSTER_SCALEVERTICAL

# waiting for replicaSet's status to be ok
log "waiting for replicaSet's status to be ok"
retry 1200 3 0 rsIsStatusOK y
sleep 5s
log "stop waiting for next node's vertical scale"
# if isClusterScaleVertical; then
# log "scale vertical ..."
# rm -f APPCTL_CLUSTER_SCALEVERTICAL

# # waiting for replicaSet's status to be ok
# log "waiting for replicaSet's status to be ok"
# retry 1200 3 0 rsIsStatusOK y
# sleep 5s
# log "stop waiting for next node's vertical scale"
# fi
}

stop() {
if isClusterStop; then
log "stop cluster: node $MY_SID $MY_IP $MY_PORT"
rm -f APPCTL_CLUSTER_STOP
fi
_stop
}

makeNodeList() {
Expand All @@ -430,19 +444,25 @@ getActionOrder() {
local tmp=$(echo "$@" | cut -d':' -f2 | sed 's/^[ ]*//g')
tmp=${tmp%%\}}
if [ "$tmp" = "scale_vertical" ]; then
log "get order: scale_vertical"
touch APPCTL_CLUSTER_SCALEVERTICAL
makeNodeList $(sortHostList $(echo ${NODE_LIST[@]}))
elif [ "$tmp" = "stop" ]; then
log "get order: stop"
touch APPCTL_CLUSTER_STOP
makeNodeList $(sortHostList $(echo ${NODE_LIST[@]}))
else
log "get order: normal"
makeNodeList $(echo ${NODE_LIST[@]})
fi
}

changeMongodbCfg() {
echo "here"
log "here"
}

mytest() {
if [ ! isClusterInitialized ]; then
if ! isClusterInitialized; then
echo "here"
else
echo "there"
Expand Down
2 changes: 1 addition & 1 deletion app/cluster.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"container":{
"type":"kvm",
"zone":"sh1",
"image":"img-yhz37nc6"
"image":"img-mhbeoxdy"
},
"instance_class":{{cluster.replica.instance_class}},
"count":{{cluster.replica.count}},
Expand Down

0 comments on commit cc96302

Please sign in to comment.