[ClusterLabs] Best way to create a floating identity file

Ken Gaillot kgaillot at redhat.com
Tue Dec 15 12:29:31 EST 2020


On Tue, 2020-12-15 at 17:02 +0300, Andrei Borzenkov wrote:
> On Tue, Dec 15, 2020 at 4:58 PM Tony Stocker <akostocker at gmail.com>
> wrote:
> > 
> > I'm trying to figure out the best way to do the following on our
> > 2-node clusters.
> > 
> > Whichever node is the primary (all services run on a single node) I
> > want to create a file that contains an identity descriptor, e.g.
> > /var/local/project/identity and the contents are "httpserver". This
> > is
> > so that we can utilize this file in cron scripts (and other
> > programs)
> > to determine on which system log files should get rotated, services
> > should get HUP'd, etc. When the resource group moves between nodes,
> > this file gets deleted on the (now) inactive node and written to on
> > the active node.
> > 
> 
> You could simply query whether a specific resource (group) is active
> on the node where your script runs. I used a similar approach in two
> node cluster (in this case I simply needed to make sure only one node
> runs cron job so I checked for CB master).
> 
> > Is there already a resource agent that does this? If so, could
> > someone
> > point me at it?
> > 
> > If not, what's the best way to accomplish this? Is it necessary to
> > write a complete resource agent script just to do this? Or is there
> > a
> > simpler way?
> > 
> > Thanks for your help

Just for fun, some other possibilities:

You could write your script/cron as an OCF RA itself, with an
OCF_CHECK_LEVEL=20 monitor doing the actual work, scheduled to run at
whatever interval you want (or using time-based rules, enabling it to
run at a particular time). Then you can colocate it with the workload
resources.

Or you could write a systemd timer unit to call your script when
desired, and colocate that with the workload as a systemd resource in
the cluster.

Or similar to the crm_resource method, you could colocate an
ocf:pacemaker:attribute resource with the workload, and have your
script check the value of the node attribute (with attrd_updater -Q) to
know whether to do stuff or not.
-- 
Ken Gaillot <kgaillot at redhat.com>



More information about the Users mailing list