We erroneously instructed users to use `notify_fifo_script`, which is
wrong.
Update the section to note the need for a running kdnotify daemon, and
point at the systemd files we provide to that end
As we expect this project to be mostly run as a system service, provide
out of the box configuration files for systemd.
Notably, we add a .socket file allowing systemd to lazily start kdnotify
when a notify event is received on its socket.
We also hardlink the socket out into the /run/ directory, such that
keepalived does not need to peak inside kdnotify runtime dir.
We also link the lifecycle of kdnotify to keepalived, as once it has
been stopped it is unlikely we'll receive new messages.
Keepalived returns dirty instance names, containing any and all quotes
from the declaration in keepalived.conf, plus an additional pair of
double quotes.
Here we strip those out, as they will just cause confusion and make it
difficult to properly match of instances in WatchRules.
As an demonstration observed from keepalived (v2.2.7):
| .conf line | notify INSTANCE |
| - | - |
| my_instance | "my_instance" |
| 'my.instance' | "'my.instance'" |
| "my.instance" | ""my.instance"" |
After this commit, each will have all of its quotes stripped
Closes: #1
The go devs in their infinite wisdom have decided that extending gofmt /
go fmt to error on exit is simply too complicated, so we have to script
away their inadequacies for them.
The primary type exported is VrrpHandler, which interprets the given
WatchRules, applying them as necessary.
It implements watcher.MsgHandler, and can be considered the primary
implementation.
This package is responsible for maintaining the lifecycle of a
fifo.EventChannel.
The EventWatcher type handles a single instance of an EventChannel,
feeding messages it receives to a provided watcher.MsgHandler interface.
These are representations of user defined rules and contextual
information, which can be used to handle notify events.
Specifically, we allow this user to provide (and later access via .Cxt)
arbitrary data under the watch.context key, while providing us rules
under watch.rules.
Each rule consists of an 'Exec' template, and three conditions for
running it (State, Type, Instance). Omitted conditions are ignored.
The Exec value consists of a golang templated command to be executed
based on the conditions listed above.
It has access to two keys, '.Event', and '.Cxt'. .Event contains the
'.Instance', '.State' and '.Type' of the event which triggered this
Exec, while '.Cxt' refers to the arbitrary watch.context passed in.
This commit adds the fifo.EventChannel interface for consuming (VRRP)
events from keepalived.
This is what package users should accept when expecting a handle to the
event stream.
fifo.FifoChannel is an implementation of this against an IPC FIFO channel
opened via MkFifo(), and can be considered the primary "producer" of
fifo.EventChannel events, but importantly we can create other
producers, notably for testing.
The in-memory representation of a keepalived notify event.
Message is not strictly accurate for non VRRP events, but as we don't
care about IPVS events now this is fine for our purposes. We do
explicitly provide a VrrpMessage type however which is guaranteed to be
a VRRP event.
A uint number between 0 and 255, representing the new priority of the
associated INSTANCE. In newer versions of the VRRP protocol (v2+) a
instance's priority must be 255 to be considered MASTER, but older
versions only require the highest current priority to be MASTER.
This field is also _optional_ keepalived will only output it for VRRP
events, and then only if a setting is enabled in the conf file,
'vrrp_notify_priority_changes'.
TYPE INSTANCE STATE PRIORITY
^^^^^^^^
Representation of the STATE component in a keepalived notify event.
Can be one of: MASTER,BACKUP,STOP (for VRRP events)
TYPE INSTANCE STATE PRIORITY
^^^^^
These correspond to the TYPE produced by keepalived's notify events.
It may be one of: INSTANCE,GROUP,VS,RS as of this commit.
Our focus is only on supporting VRRP event types at present, but we do
recognize all the current event types.
TYPE INSTANCE STATE PRIORITY
^^^^
This is a "global" context object currently containing a cancellation
context and logger.
This struct can be considered as the lib's generic configuration, and
may be asked for in any public function.