diff --git a/cmd/sabactl/machines.go b/cmd/sabactl/machines.go index 94b58dcb..b2f27ee1 100644 --- a/cmd/sabactl/machines.go +++ b/cmd/sabactl/machines.go @@ -174,7 +174,7 @@ STATE can be one of: uninitialized The machine is not yet initialized. healthy The machine has no problems. unhealthy The machine has some problems. - dead The machine does not communicate with others. + unreachable The machine does not communicate with others. updating The machine is updating. retiring The machine should soon be retired/repaired. `, diff --git a/docs/api.md b/docs/api.md index d1f97de8..4c3ec7bc 100644 --- a/docs/api.md +++ b/docs/api.md @@ -277,7 +277,7 @@ The new state is given by contents of request body and should be one of: * `uninitialized` * `healthy` * `unhealthy` -* `dead` +* `unreachable` * `updating` * `retiring` @@ -313,7 +313,7 @@ The state will be returned by response body and should be one of: * uninitialized * healthy * unhealthy -* dead +* unreachable * updating * retiring * retired diff --git a/docs/lifecycle.md b/docs/lifecycle.md index 9e47eb16..8fd02fae 100644 --- a/docs/lifecycle.md +++ b/docs/lifecycle.md @@ -28,7 +28,7 @@ Sabakan defines following machine states: * **Uninitialized**: Machines to not be initialized. * **Healthy**: Machines that can run applications * **Unhealthy**: Machines having problems to be repaired -* **Dead**: Machines that cannot be accessed +* **Unreachable**: Machines that cannot be accessed * **Updating**: Machines to be updating * **Retiring**: Machines to be retired/repaired * **Retired**: Machines whose disk encryption keys were deleted @@ -40,16 +40,16 @@ External controllers are expected to: * Prepare **Uninitialized** machines to (re)join to application clusters. * Allocate **Healthy** machines to applications like Kubernetes or Ceph. * Reboot the **Updating** machines, Machines will be **Uninitialized** after reboot. -* Drain **Unhealthy**, **Dead** and **Retiring** machines from applications. +* Drain **Unhealthy**, **Unreachable** and **Retiring** machines from applications. * Remove disk encryption keys of **Retiring** machines after drain. ### Transition constraints -* **Uninitialized**, ***Healthy**, **Unhealthy**, or **Dead** machine can transition to **Retiring**. +* **Uninitialized**, ***Healthy**, **Unhealthy**, or **Unreachable** machine can transition to **Retiring**. * A **Retiring** machine can transition only to **Retired**. -* A **Healthy** machine can transition to **Unhealthy**, **Dead**, **Retiring**, and **Updating**. -* A **Unhealthy** machine can transition to **Dead**. -* **Uneahlthy** and **Dead** machine can not return to **Healthy** directly. +* A **Healthy** machine can transition to **Unhealthy**, **Unreachable**, **Retiring**, and **Updating**. +* A **Unreachable** machine can transition to **Healthy**. +* **Uneahlthy** machine cannot return to **Healthy** directly. * Disk encryption keys of a machine can be deleted if the machine is in **Retiring** state. * A machine transitions to **Retired** when its disk encryption keys are deleted. * Only **Retired** machines can be removed from sabakan. @@ -64,4 +64,4 @@ sabakan. ### Transition diagram -![state transition diagram](http://www.plantuml.com/plantuml/png/ZP91JuH038NlyojwDY7UEPWrxa4lncoo9-EXC5sPCDCXfRZ1No-3B3h4nBsGbdxlFMYwwnL5X-3DwyqR53QUkRY38pjswj2xJx8cww2Ove-4NflnZyc1r8dZznBsL7jqGY3BAsCMsGmUkVdk4gbKQm_8G29HCcvFQ4ju9Zr7QM5W8QmRh3nbr2RsT-gA3LsAxIng0jVgza1LZAa2RGZ2PE-OZBdCeTWkf8JxavA0pCA9vEQwJyd0hUVJsa107j3xSID8gp0cFVyBMfbDnejGby3iHyt5wCSriGSAyOFwcRMkRu6ubh5J5nbQ6XSPNPspuEkDJVTMmWCoI0hAM3X93D1ZXIsosH7R8VWl) +![state transition diagram](http://www.plantuml.com/plantuml/png/ZPB1JiCm38RlUGgVaIhkFQ0XTe0BGfKu8GvUuz6eYLEvBbDvUfgnXQL2QBVO_dv_RPJDg2Ww1M_URjwXil70rHsyicEd3htx8ckA2gfb_aZejPl_c3IaJXn_rB2brgCJ0ZcrZ3d55Z0fkfygaKgjZe0C91AbuBQ4jePdqaEK7YOMmhR3dQU2McalhHcRXgGTB6e2y-cseLsCwGJQ4OHblMCovZo7QdqXDTplbGJa65n8xgxxb19SxNpA1GJa2RsVZTaIbZUU6_zeChCol0WD2RpupGkLEM_yNPz23ONuIUCnPDtO0t4hyw0kClGqds9qhJ3ZvwUsFBiQ7f11agXWOIynm8Wxx97DXjXEmNy3) \ No newline at end of file diff --git a/docs/sabactl.md b/docs/sabactl.md index c5641949..a1e81b13 100644 --- a/docs/sabactl.md +++ b/docs/sabactl.md @@ -90,7 +90,7 @@ Detailed specification of the query parameters and the output JSON content is sa ---------------------------- Set the state of a machine. -State is one of `uninitialized`, `healthy`, `unhealthy`, `dead`, `updating` or `retiring`. +State is one of `uninitialized`, `healthy`, `unhealthy`, `unreachable`, `updating` or `retiring`. ```console $ sabactl machines set-state @@ -100,7 +100,7 @@ $ sabactl machines set-state ---------------------------- Get the state of a machine. -State is one of `uninitialized`, `healthy`, `unhealthy`, `dead`, `updating`, `retiring` or `retired`. +State is one of `uninitialized`, `healthy`, `unhealthy`, `unreachable`, `updating`, `retiring` or `retired`. ```console $ sabactl machines get-state diff --git a/machines.go b/machines.go index 525c3240..9240e7a6 100644 --- a/machines.go +++ b/machines.go @@ -19,7 +19,7 @@ const ( StateUninitialized = MachineState("uninitialized") StateHealthy = MachineState("healthy") StateUnhealthy = MachineState("unhealthy") - StateDead = MachineState("dead") + StateUnreachable = MachineState("unreachable") StateUpdating = MachineState("updating") StateRetiring = MachineState("retiring") StateRetired = MachineState("retired") @@ -111,11 +111,11 @@ func (m *Machine) SetState(ms MachineState) error { return errors.New("transition to " + ms.String() + " is forbidden") } case StateUnhealthy: - if ms == StateHealthy || ms == StateUpdating || ms == StateRetired { + if ms != StateUninitialized && ms != StateRetiring { return errors.New("transition to " + ms.String() + " is forbidden") } - case StateDead: - if ms == StateHealthy || ms == StateUpdating || ms == StateRetired || ms == StateUnhealthy { + case StateUnreachable: + if ms == StateUpdating || ms == StateRetired || ms == StateUnhealthy { return errors.New("transition to " + ms.String() + " is forbidden") } case StateUpdating: diff --git a/query_test.go b/query_test.go index 1ea9f737..7007dc11 100644 --- a/query_test.go +++ b/query_test.go @@ -27,7 +27,7 @@ func TestMatch(t *testing.T) { {Query{"ipv6": "aa::ff"}, NewMachine(MachineSpec{IPv6: []string{"bb::ff", "cc::ff"}}), false}, {Query{"ipv4": "10.20.30.40"}, NewMachine(MachineSpec{}), false}, {Query{"ipv6": "aa::ff"}, NewMachine(MachineSpec{}), false}, - {Query{"state": "dead"}, NewMachine(MachineSpec{}), false}, + {Query{"state": "unreachable"}, NewMachine(MachineSpec{}), false}, } for _, c := range cases { diff --git a/web/machines_test.go b/web/machines_test.go index 3a886ee4..e13c05af 100644 --- a/web/machines_test.go +++ b/web/machines_test.go @@ -256,7 +256,7 @@ func testMachinesGet(t *testing.T) { expected: nil, }, { - query: map[string][]string{"state": {"dead"}}, + query: map[string][]string{"state": {"unreachable"}}, status: http.StatusNotFound, expected: nil, }, diff --git a/web/state.go b/web/state.go index 496d73ad..7d99a2ad 100644 --- a/web/state.go +++ b/web/state.go @@ -52,7 +52,7 @@ func (s Server) handleStatePut(w http.ResponseWriter, r *http.Request, serial st ms := sabakan.MachineState(state) switch ms { - case sabakan.StateUninitialized, sabakan.StateHealthy, sabakan.StateUnhealthy, sabakan.StateDead, sabakan.StateUpdating, sabakan.StateRetiring: + case sabakan.StateUninitialized, sabakan.StateHealthy, sabakan.StateUnhealthy, sabakan.StateUnreachable, sabakan.StateUpdating, sabakan.StateRetiring: default: renderError(r.Context(), w, BadRequest("invalid state: "+string(state))) return diff --git a/web/state_test.go b/web/state_test.go index 96a3e327..ab28a15e 100644 --- a/web/state_test.go +++ b/web/state_test.go @@ -79,9 +79,14 @@ func testStatePut(t *testing.T) { {"unhealthy", 500}, {"uninitialized", 200}, {"healthy", 200}, + {"unreachable", 200}, + {"healthy", 200}, + {"unreachable", 200}, + {"unhealthy", 500}, + {"healthy", 200}, {"unhealthy", 200}, {"healthy", 500}, - {"dead", 200}, + {"unreachable", 500}, {"uninitialized", 200}, {"healthy", 200}, {"retired", 400},