2018-05-14 08:56:01 +00:00
|
|
|
# Lifecycle hooks & Finalizers
|
2018-05-11 12:58:49 +00:00
|
|
|
|
2018-05-11 14:56:20 +00:00
|
|
|
The ArangoDB operator expects full control of the `Pods` and `PersistentVolumeClaims` it creates.
|
|
|
|
Therefore it takes measures to prevent the removal of those resources
|
|
|
|
until it is safe to do so.
|
2018-05-11 12:58:49 +00:00
|
|
|
|
|
|
|
To achieve this, the server containers in the `Pods` have
|
2018-05-11 14:56:20 +00:00
|
|
|
a `preStop` hook configured and finalizers are added to the `Pods`
|
2018-05-15 08:17:02 +00:00
|
|
|
and `PersistentVolumeClaims`.
|
2018-05-11 12:58:49 +00:00
|
|
|
|
|
|
|
The `preStop` hook executes a binary that waits until all finalizers of
|
|
|
|
the current pod have been removed.
|
|
|
|
Until this `preStop` hook terminates, Kubernetes will not send a `TERM` signal
|
|
|
|
to the processes inside the container, which ensures that the server remains running
|
|
|
|
until it is safe to stop them.
|
|
|
|
|
2018-05-11 14:56:20 +00:00
|
|
|
The operator performs all actions needed when a delete of a `Pod` or
|
|
|
|
`PersistentVolumeClaims` has been triggered.
|
|
|
|
E.g. for a dbserver it cleans out the server if the `Pod` and `PersistentVolumeClaim` are being deleted.
|
2018-05-11 12:58:49 +00:00
|
|
|
|
|
|
|
## Lifecycle init-container
|
|
|
|
|
|
|
|
Because the binary that is called in the `preStop` hook is not part of a standard
|
|
|
|
ArangoDB docker image, it has to be brought into the filesystem of a `Pod`.
|
|
|
|
This is done by an initial container that copies the binary to an `emptyDir` volume that
|
|
|
|
is shared between the init-container and the server container.
|
2018-05-14 08:56:01 +00:00
|
|
|
|
|
|
|
## Finalizers
|
|
|
|
|
|
|
|
The ArangoDB operators adds the following finalizers to `Pods`.
|
|
|
|
|
|
|
|
- `dbserver.database.arangodb.com/drain`: Added to DBServers, removed only when the dbserver can be restarted or is completely drained
|
|
|
|
- `agent.database.arangodb.com/agency-serving`: Added to Agents, removed only when enough agents are left to keep the agency serving
|
|
|
|
|
|
|
|
The ArangoDB operators adds the following finalizers to `PersistentVolumeClaims`.
|
|
|
|
|
|
|
|
- `pvc.database.arangodb.com/member-exists`: removed only when its member exists no longer exists or can be safely rebuild
|