Skip to content

Commit 22e7e49

Browse files
authored
Fix pot internal state in start-cleanup (#227)
This introduces a distinct state called "doa" (dead on arrival), which is also an allowed prerequisite for going to state stopping.
1 parent c5b8c88 commit 22e7e49

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88

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

1314
## [0.15.0] 2022-09-11
1415
### Added

share/pot/set-status.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
# shellcheck disable=SC3033,SC3040,SC3043
33
:
44

5-
: "${_POT_INTERNAL_STATUS:="starting started stopping stopped"}"
5+
: "${_POT_INTERNAL_STATUS:="starting doa started stopping stopped"}"
66

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

@@ -106,14 +106,16 @@ pot-set-status()
106106
return 1
107107
fi
108108
;;
109-
"started")
109+
"started" | "doa")
110110
if [ "$_current_status" != "starting" ]; then
111111
return 1
112112
fi
113113
;;
114114
"stopping")
115115
# you can always stop a stopped pot (for cleanup reasons)
116-
if [ "$_current_status" != "started" ] && [ "$_current_status" != "stopped" ]; then
116+
if [ "$_current_status" != "started" ] &&
117+
[ "$_current_status" != "doa" ] &&
118+
[ "$_current_status" != "stopped" ]; then
117119
return 1
118120
fi
119121
;;

share/pot/start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ start-cleanup()
3030
if [ -z "$_pname" ]; then
3131
return
3232
fi
33+
# doa state will only be set if pot is in state "starting"
34+
lockf "${POT_TMP:-/tmp}/pot-lock-$_pname" "${_POT_PATHNAME}" set-status -p "$_pname" -s doa
3335
if [ -n "$_iface" ] && _is_valid_netif "$_iface" ; then
3436
pot-cmd stop -p "$_pname" -i "$_iface" -s
3537
else

0 commit comments

Comments
 (0)