Implement working lockfile for testnet lockout (#4013)
This commit is contained in:
parent
f5f5281f85
commit
08f0fb1e14
|
@ -378,27 +378,22 @@ deploy() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENABLED_LOCKFILE="${HOME}/${TESTNET}.is_enabled"
|
||||||
CREATED_LOCKFILE="${HOME}/${TESTNET}.is_created"
|
CREATED_LOCKFILE="${HOME}/${TESTNET}.is_created"
|
||||||
STARTED_LOCKFILE="${HOME}/${TESTNET}.is_started"
|
|
||||||
|
|
||||||
create-and-start() {
|
create-and-start() {
|
||||||
rm -f "${CREATED_LOCKFILE}"
|
rm -f "${CREATED_LOCKFILE}"
|
||||||
rm -f "${STARTED_LOCKFILE}"
|
|
||||||
deploy create start
|
deploy create start
|
||||||
touch "${CREATED_LOCKFILE}"
|
touch "${CREATED_LOCKFILE}"
|
||||||
touch "${STARTED_LOCKFILE}"
|
|
||||||
}
|
}
|
||||||
create() {
|
create() {
|
||||||
rm -f "${CREATED_LOCKFILE}"
|
rm -f "${CREATED_LOCKFILE}"
|
||||||
rm -f "${STARTED_LOCKFILE}"
|
|
||||||
deploy create
|
deploy create
|
||||||
touch "${CREATED_LOCKFILE}"
|
touch "${CREATED_LOCKFILE}"
|
||||||
}
|
}
|
||||||
start() {
|
start() {
|
||||||
if [[ -f ${CREATED_LOCKFILE} ]]; then
|
if [[ -f ${CREATED_LOCKFILE} ]]; then
|
||||||
rm -f "${STARTED_LOCKFILE}"
|
|
||||||
deploy "" start
|
deploy "" start
|
||||||
touch "${STARTED_LOCKFILE}"
|
|
||||||
else
|
else
|
||||||
echo "Unable to start ${TESTNET}. Are the nodes created?
|
echo "Unable to start ${TESTNET}. Are the nodes created?
|
||||||
Re-run ci/testnet-manager.sh with \$TESTNET_OP=create or \$TESTNET_OP=create-and-start"
|
Re-run ci/testnet-manager.sh with \$TESTNET_OP=create or \$TESTNET_OP=create-and-start"
|
||||||
|
@ -407,43 +402,68 @@ start() {
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
deploy "" ""
|
deploy "" ""
|
||||||
rm -f "${STARTED_LOCKFILE}"
|
|
||||||
}
|
}
|
||||||
delete() {
|
delete() {
|
||||||
deploy "" "" "" delete
|
deploy "" "" "" delete
|
||||||
rm -f "${CREATED_LOCKFILE}"
|
rm -f "${CREATED_LOCKFILE}"
|
||||||
rm -f "${STARTED_LOCKFILE}"
|
}
|
||||||
|
enable_testnet() {
|
||||||
|
touch "${ENABLED_LOCKFILE}"
|
||||||
|
}
|
||||||
|
disable_testnet() {
|
||||||
|
rm -f "${ENABLED_LOCKFILE}"
|
||||||
|
}
|
||||||
|
is_testnet_enabled() {
|
||||||
|
if [[ ! -f ${ENABLED_LOCKFILE} ]]; then
|
||||||
|
echo "--- ${TESTNET} is currently disabled. Enable ${TESTNET} by running ci/testnet-manager.sh with \$TESTNET_OP=enable, then re-run with current settings."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case $TESTNET_OP in
|
case $TESTNET_OP in
|
||||||
|
enable)
|
||||||
|
enable_testnet
|
||||||
|
;;
|
||||||
|
disable)
|
||||||
|
delete
|
||||||
|
disable_testnet
|
||||||
|
;;
|
||||||
create-and-start)
|
create-and-start)
|
||||||
|
is_testnet_enabled
|
||||||
create-and-start
|
create-and-start
|
||||||
;;
|
;;
|
||||||
create)
|
create)
|
||||||
|
is_testnet_enabled
|
||||||
create
|
create
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
|
is_testnet_enabled
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
is_testnet_enabled
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
sanity)
|
sanity)
|
||||||
|
is_testnet_enabled
|
||||||
sanity
|
sanity
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
|
is_testnet_enabled
|
||||||
delete
|
delete
|
||||||
;;
|
;;
|
||||||
update-or-restart)
|
update-or-restart)
|
||||||
|
is_testnet_enabled
|
||||||
if start; then
|
if start; then
|
||||||
echo Update successful
|
echo Update successful
|
||||||
else
|
else
|
||||||
echo "+++ Update failed, restarting the network"
|
echo "+++ Update failed, restarting the network"
|
||||||
$metricsWriteDatapoint "testnet-manager update-failure=1"
|
$metricsWriteDatapoint "testnet-manager update-failure=1"
|
||||||
start
|
create-and-start
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
sanity-or-restart)
|
sanity-or-restart)
|
||||||
|
is_testnet_enabled
|
||||||
if sanity; then
|
if sanity; then
|
||||||
echo Pass
|
echo Pass
|
||||||
else
|
else
|
||||||
|
@ -458,10 +478,10 @@ sanity-or-restart)
|
||||||
else
|
else
|
||||||
echo "+++ Update failed, restarting the network"
|
echo "+++ Update failed, restarting the network"
|
||||||
$metricsWriteDatapoint "testnet-manager update-failure=1"
|
$metricsWriteDatapoint "testnet-manager update-failure=1"
|
||||||
start
|
create-and-start
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
start
|
create-and-start
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue