[ClusterLabs] Determine a resource's current host in the CIB
Ken Gaillot
kgaillot at redhat.com
Thu Sep 24 12:07:41 EDT 2020
On Thu, 2020-09-24 at 11:30 -0400, Digimer wrote:
> On 2020-09-24 5:00 a.m., Klaus Wenninger wrote:
> > On 9/24/20 9:19 AM, Reid Wahl wrote:
> > > **Directly via the CIB**, I don't see a more obvious way than
> > > looking
> > > for the most recent (perhaps by last-rc-change) successful
> > > (rc-code="0" or rc-code="8") monitor operation. That might be
> > > error-prone. I haven't looked into exactly how crm_simulate
> > > parses
> > > resource status from the CIB XML yet. Others on the list might
> > > know.
> > >
> > > Is there a particular reason why you need to parse the status
> > > directly
> > > from the CIB, as opposed to using other tools? Does your use case
> > > allow you to use crm_simulate with the cib.xml as input? (e.g.,
> > > `crm_simulate --xml-file=<cibfile>`)
> >
> > You might as well parse output of crm_mon using --xml-file.
> >
> > A quick look to the code shows that crm_resource - where we would
> > have --locate -does have the --xml-file as well. But that seems
> > not to do what I expected althoughI haven't looked into the
> > details.
--xml-file is deprecated for most commands, use CIB_file in the
environment instead.
E.g. CIB_file=mycib.xml crm_resource --locate -r myrsc
>
> This is an interesting option... I can see that it shows me running
> resources only (not what resources are configured but off). It does
> show
> more directly "VM x is on node y";
crm_resource --locate should say "resource myrsc is NOT running" if
it's not active
BTW crm_resource is next in line to get --output-as=xml, hopefully that
lands in 2.0.5.
> <resources>
> <resource id="srv07-el6" resource_agent="ocf::alteeve:server"
> role="Started" active="true" orphaned="false" blocked="false"
> managed="true" failed="false" failure_ignored="false"
> nodes_running_on="1">
> <node name="mk-a02n02" id="2" cached="true"/>
> </resource>
> </resources>
>
> I'd like to avoid writing a new parser as I'll still need to
> read/parse
> the CIB anyway to know about off resources, and I have to assume
> there
> is a way to determine the same from the CIB itself. How to determine
> what is running where has to be determinable...
The command-line tool XML output is intended to remain stable over a
very long time (as close to forever as possible). The status section of
the CIB has remained stable in practice, but can change with any
release.
In the distant future, once all the tools support --output-as=xml, the
next step would be to offer them all as C API functions generating the
same XML format. Those could then be used to create native APIs in
Python etc., which you could use to get structured objects back without
needing to parse XML yourself. But that's just a dream at this point
...
> digimer
>
> > > On Wed, Sep 23, 2020 at 11:04 PM Digimer <lists at alteeve.ca>
> > > wrote:
> > > > Hi all,
> > > >
> > > > I'm trying to parse the CIB to determine which node a given
> > > > resource
> > > > (VM) is currently running on. I notice that the 'monitor' shows
> > > > in both
> > > > node's status element (from when it last ran when the node
> > > > previously
> > > > hosted the resource).
> > > >
> > > > https://pastebin.com/6RCMWdgq
> > > >
> > > > Specifically, I see under node 1 (the active host when the CIB
> > > > was read):
> > > >
> > > > <lrm_rsc_op id="srv07-el6_monitor_60000"
> > > > operation_key="srv07-el6_monitor_60000" operation="monitor"
> > > > crm-debug-origin="do_update_resource" crm_feature_set="3.3.0"
> > > > transition-key="23:85:0:829209fd-35f2-4626-a9cd-f8a50a62871e"
> > > > transition-magic="0:0;23:85:0:829209fd-35f2-4626-a9cd-
> > > > f8a50a62871e"
> > > > exit-reason="" on_node="mk-a02n01" call-id="76" rc-code="0"
> > > > op-status="0" interval="60000" last-rc-change="1600925201"
> > > > exec-time="541" queue-time="0"
> > > > op-digest="65d0f0c9227f2593835f5de6c9cb9d0e"/>
> > > >
> > > > And under node 2 (hosted the server in the past):
> > > >
> > > > <lrm_rsc_op id="srv07-el6_monitor_60000"
> > > > operation_key="srv07-el6_monitor_60000" operation="monitor"
> > > > crm-debug-origin="do_update_resource" crm_feature_set="3.3.0"
> > > > transition-key="23:83:0:829209fd-35f2-4626-a9cd-f8a50a62871e"
> > > > transition-magic="0:0;23:83:0:829209fd-35f2-4626-a9cd-
> > > > f8a50a62871e"
> > > > exit-reason="" on_node="mk-a02n02" call-id="61" rc-code="0"
> > > > op-status="0" interval="60000" last-rc-change="1600925173"
> > > > exec-time="539" queue-time="0"
> > > > op-digest="65d0f0c9227f2593835f5de6c9cb9d0e"/>
> > > >
> > > > I don't see any specific entry in the CIB saying "resource X is
> > > > currently hosted on node Y", so I assume I should infer which
> > > > node is
> > > > the current host? If so, should I look at which node's 'exec-
> > > > time' is
> > > > higher, or which node has the higher 'call-id'?
> > > >
> > > > Or am I missing a more obvious way to tell what resource is
> > > > running on
> > > > which node?
> > > >
> > > > --
> > > > Digimer
> > > > Papers and Projects: https://alteeve.com/w/
> > > > "I am, somehow, less interested in the weight and convolutions
> > > > of
> > > > Einstein’s brain than in the near certainty that people of
> > > > equal talent
> > > > have lived and died in cotton fields and sweatshops." - Stephen
> > > > Jay Gould
> > > > _______________________________________________
> > > > Manage your subscription:
> > > > https://lists.clusterlabs.org/mailman/listinfo/users
> > > >
> > > > ClusterLabs home: https://www.clusterlabs.org/
> > >
> > >
>
>
--
Ken Gaillot <kgaillot at redhat.com>
More information about the Users
mailing list