Commit 6b4e74f
authored
[DPE-10450] Fix crash restoring non-settable unit status in PG14 (#1791)
* [DPE-10450] Fix crash restoring non-settable unit status in _check_detached_storage
The unit.status getter can return statuses the setter rejects (e.g. an
"error" status left over from a previously failed hook). When storage is
already attached, _check_detached_storage restored the cached status
verbatim, raising InvalidStatusError ("status must be in active, blocked,
maintenance, waiting, not 'error'") and deadlocking the unit in error.
Only restore the cached status when it is a settable status type.
Assisted-by: Claude:claude-4.8-opus
* [DPE-10450] Guard restore of non-settable status in enable_disable_extensions
enable_disable_extensions caches the current unit status and restores it
verbatim at the end, exactly like _check_detached_storage did. The status
getter can return statuses the setter rejects (e.g. an "error" status left
over from a previously failed hook), so this restore hit the same
InvalidStatusError crash.
Extract the settable-status check into a shared _restore_unit_status helper
and route both restore paths through it. Also cover the "unknown" status
(not just "error") in both tests.
Backport of 66ffc20de7e6bb5ff964de24dcfbc9f29c6ced8a; adapted to this branch,
which sets self.unit.status directly (no set_unit_status helper).
Assisted-by: Claude:claude-4.8-opus1 parent 29b0f7e commit 6b4e74f
2 files changed
Lines changed: 55 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
1293 | 1294 | | |
1294 | 1295 | | |
1295 | 1296 | | |
1296 | | - | |
| 1297 | + | |
1297 | 1298 | | |
1298 | 1299 | | |
1299 | 1300 | | |
| |||
1963 | 1964 | | |
1964 | 1965 | | |
1965 | 1966 | | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
1966 | 1978 | | |
1967 | 1979 | | |
1968 | 1980 | | |
| |||
1978 | 1990 | | |
1979 | 1991 | | |
1980 | 1992 | | |
1981 | | - | |
| 1993 | + | |
1982 | 1994 | | |
1983 | 1995 | | |
1984 | 1996 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
405 | 434 | | |
406 | 435 | | |
407 | 436 | | |
| |||
1023 | 1052 | | |
1024 | 1053 | | |
1025 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1026 | 1067 | | |
1027 | 1068 | | |
1028 | 1069 | | |
| |||
0 commit comments