Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix pot internal state in start-cleanup #227

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [0.15.1] 2022-09-16
### Fixed
- set-status: fix a bug that delete the status (#224)
- set-status: fix a bug that deletes the status (#224)
- start: fix pot getting stuck in state "starting" on pot start failure (#227)

## [0.15.0] 2022-09-11
### Added
Expand Down
12 changes: 7 additions & 5 deletions share/pot/set-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# shellcheck disable=SC3033,SC3040,SC3043
:

: "${_POT_INTERNAL_STATUS:="starting started stopping stopped"}"
: "${_POT_INTERNAL_STATUS:="starting doa started stopping stopped"}"

set-status-help()
{
cat <<-"EOH"
cat <<-EOH
Internal command, DO NOT USE IF YOU DON'T KNOW WHAT YOU ARE DOING!
This command is meant to be invoked using lockf
pot set-status [-hv] [-p pname] [-s status]
-h print this help
-v verbose
-p pname : pot name
-s status : the status [starting started stopping stopped]
-s status : the status [$_POT_INTERNAL_STATUS]
EOH
}

Expand Down Expand Up @@ -106,14 +106,16 @@ pot-set-status()
return 1
fi
;;
"started")
"started" | "doa")
if [ "$_current_status" != "starting" ]; then
return 1
fi
;;
"stopping")
# you can always stop a stopped pot (for cleanup reasons)
if [ "$_current_status" != "started" ] && [ "$_current_status" != "stopped" ]; then
if [ "$_current_status" != "started" ] &&
[ "$_current_status" != "doa" ] &&
[ "$_current_status" != "stopped" ]; then
return 1
fi
;;
Expand Down
2 changes: 2 additions & 0 deletions share/pot/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ start-cleanup()
if [ -z "$_pname" ]; then
return
fi
# doa state will only be set if pot is in state "starting"
lockf "${POT_TMP:-/tmp}/pot-lock-$_pname" "${_POT_PATHNAME}" set-status -p "$_pname" -s doa
if [ -n "$_iface" ] && _is_valid_netif "$_iface" ; then
pot-cmd stop -p "$_pname" -i "$_iface" -s
else
Expand Down