Mailing List Archive

Two git patchs for resource-agents
Hi,

1. Add a functionality that modifies utilization of resource automatically, please see fate 310117.

I added 3 ocf parameters:
- dynamic_utilization, if set, the utilization parameter of resource will be reset if there are
difference between resource parameters and system parameters when agent monitor.
Otherwise, the resource parameters will be set once when agent start.
- set_utilization_cpu, enable setting cpu of utilization.
- set_utilization_memory, enable setting memory of utilization.

2. Create a new agent: AutoSetting, it detects system parameters, such as cpu, memory, and put them into
utilization of node, it runs on every node as clone resource. please see fate 310115.
I implemented 3 ocf parameters:
- dynamic
- utilization_cpu
- utilization_memory




if any questions, send me a mail, thanks

- John Shi
Re: Two git patchs for resource-agents [ In reply to ]
On 2011-07-11T05:01:23, John Shi <jshi@novell.com> wrote:

> +<content type="boolean" default="$OCF_RESKEY_dynamic" />

You can't put a shell variable as a value here.

> +<parameter name="pidfile" unique="0" required="0">
> +<longdesc lang="en">PID file</longdesc>
> +<shortdesc lang="en">PID file</shortdesc>
> +<content type="string" default="$OCF_RESKEY_pidfile" />

Why can this be configured? Is this necessary?


> +set_utilization() {
> + host_name="$(hostname)"
> +
> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> + sys_cpu=$(grep -c processor /proc/cpuinfo)
> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)

This counts just the number of cores; I think it should be multiplied by
their frequency. That's still only an approximation (and doesn't really
compare across differently powerful CPU architectures), but it is more
meaningful I think.

Probably this is one of the areas where we will need to have multiple
algorithms to choose from.


> + if [ "$OCF_RESKEY_utilization_memory" = "true" -o "$OCF_RESKEY_utilization_memory" = "1" ]; then
> + sys_mem=$(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo)
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n memory 2>/dev/null)

Here we need the ability to reduce this number by a configurable amount
(to account for the HVM domain/Dom0, for example).


> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="$OCF_RESKEY_set_utilization_cpu" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="$OCF_RESKEY_set_utilization_memory" />
> +</parameter>

For these, we also need the ability to specify a multiplier; that would
allow one to configure VMs with a "overcommit" factor, which I'm quite
sure a number of customers would want ...


Thanks,
Lars

--
Architect Storage/HA, OPS Engineering, Novell, Inc.
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 21284 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Random question - should this be in pacemaker or agents?
Its not really useful outside of a pacemaker cluster which is usually
my criteria for putting it in the former.

On Tue, Jul 12, 2011 at 9:51 PM, Lars Marowsky-Bree <lmb@suse.de> wrote:
> On 2011-07-11T05:01:23, John Shi <jshi@novell.com> wrote:
>
>> +<content type="boolean" default="$OCF_RESKEY_dynamic" />
>
> You can't put a shell variable as a value here.
>
>> +<parameter name="pidfile" unique="0" required="0">
>> +<longdesc lang="en">PID file</longdesc>
>> +<shortdesc lang="en">PID file</shortdesc>
>> +<content type="string" default="$OCF_RESKEY_pidfile" />
>
> Why can this be configured? Is this necessary?
>
>
>> +set_utilization() {
>> +    host_name="$(hostname)"
>> +
>> +    if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
>> +        sys_cpu=$(grep -c processor /proc/cpuinfo)
>> +        uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
>
> This counts just the number of cores; I think it should be multiplied by
> their frequency. That's still only an approximation (and doesn't really
> compare across differently powerful CPU architectures), but it is more
> meaningful I think.
>
> Probably this is one of the areas where we will need to have multiple
> algorithms to choose from.
>
>
>> +    if [ "$OCF_RESKEY_utilization_memory" = "true" -o "$OCF_RESKEY_utilization_memory" = "1" ]; then
>> +        sys_mem=$(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo)
>> +        uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n memory 2>/dev/null)
>
> Here we need the ability to reduce this number by a configurable amount
> (to account for the HVM domain/Dom0, for example).
>
>
>> +<parameter name="set_utilization_cpu" unique="0" required="0">
>> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
>> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
>> +<content type="boolean" default="$OCF_RESKEY_set_utilization_cpu" />
>> +</parameter>
>> +
>> +<parameter name="set_utilization_memory" unique="0" required="0">
>> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
>> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
>> +<content type="boolean" default="$OCF_RESKEY_set_utilization_memory" />
>> +</parameter>
>
> For these, we also need the ability to specify a multiplier; that would
> allow one to configure VMs with a "overcommit" factor, which I'm quite
> sure a number of customers would want ...
>
>
> Thanks,
>    Lars
>
> --
> Architect Storage/HA, OPS Engineering, Novell, Inc.
> SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 21284 (AG Nürnberg)
> "Experience is the name everyone gives to their mistakes." -- Oscar Wilde
>
> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
>
_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
在 2011-07-12二的 13:51 +0200,Lars Marowsky-Bree写道:
> On 2011-07-11T05:01:23, John Shi <jshi@novell.com> wrote:

> > + if [ "$OCF_RESKEY_utilization_memory" = "true" -o "$OCF_RESKEY_utilization_memory" = "1" ]; then
> > + sys_mem=$(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo)
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n memory 2>/dev/null)
>
> Here we need the ability to reduce this number by a configurable amount
> (to account for the HVM domain/Dom0, for example).

The memory used by HVM domani/Dom0 cannot be calc in all situation (for
Xen/KVM at least), sadly.

I also think it make more sense to set both host_memory and hvm_memory.
host_memory can be used by those resources running inside HVM domain,
while hvm_memory is for domU.

And one more thing.
As we are discussing how to improve OCF spec already, how about adding a
new interface for utilization ? I believe pacemaker will evolute to a
stage that can handle utilization in a more flexible way. So why not let
pacemaker ask the resource for a utilization requirements, instead of
messing around it in monitor_0/probe.

My .2 cents

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
On 2011-07-13T04:09:40, Xin Wei Hu <xwhu@novell.com> wrote:

> > Here we need the ability to reduce this number by a configurable amount
> > (to account for the HVM domain/Dom0, for example).
> The memory used by HVM domani/Dom0 cannot be calc in all situation (for
> Xen/KVM at least), sadly.

That is why I suggested to allow a configurable amount of memory to be
subtracted.

> As we are discussing how to improve OCF spec already, how about adding a
> new interface for utilization ? I believe pacemaker will evolute to a
> stage that can handle utilization in a more flexible way. So why not let
> pacemaker ask the resource for a utilization requirements, instead of
> messing around it in monitor_0/probe.

Good idea. I look forward to a proposal ;-)

Basically, a "discover" call prior to scheduling start?

Anyhow - we will not get that done for this round, and for now, we need
to mess around with it in probe or elsewhere.


Regards,
Lars

--
Architect Storage/HA, OPS Engineering, Novell, Inc.
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 21284 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
On 2011-07-13T15:00:05, Andrew Beekhof <andrew@beekhof.net> wrote:

> Random question - should this be in pacemaker or agents?

The modification to VirtualDomain belongs there, I guess; for
SysInfo/SysCapacity/WhateverItIsCalled, I don't care either way.

> Its not really useful outside of a pacemaker cluster which is usually
> my criteria for putting it in the former.

True.


Regards,
Lars

--
Architect Storage/HA, OPS Engineering, Novell, Inc.
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 21284 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
>>> Lars Marowsky-Bree 11年07月12日 下午 19:57 >>>
On 2011-07-11T05:01:23, John Shi wrote:
>
> +
>
>You can't put a shell variable as a value here.

Ok, I see, but why did the shell variable also appear in SysInfo meta_data, I just copied that.

>
> +
> +PID file
> +PID file
> +

>Why can this be configured? Is this necessary?

It's no necessary, I'll remove this parameter.

>> +set_utilization() {
>> + host_name="$(hostname)"
>> +
>> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
>> + sys_cpu=$(grep -c processor /proc/cpuinfo)
>> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
>
>This counts just the number of cores; I think it should be multiplied by
>their frequency. That's still only an approximation (and doesn't really
>compare across differently powerful CPU architectures), but it is more
>meaningful I think.
>
>Probably this is one of the areas where we will need to have multiple
>algorithms to choose from.

Yes, I also think it is more meaningful,
But we can only compute the number of cores by the existing algorithms,
because maybe there is difference between utilization_cpu of node and
utilization_cpu of resource if they are multiplied by their frequency, is that right ?

>
>
>> + if [ "$OCF_RESKEY_utilization_memory" = "true" -o "$OCF_RESKEY_utilization_memory" = "1" ]; then
>> + sys_mem=$(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo)
>> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n memory 2>/dev/null)
>
>Here we need the ability to reduce this number by a configurable amount
>(to account for the HVM domain/Dom0, for example).

Xinwei and I discussed this matter,
how can we know that node is ready to run Xen RA or other RA,
Xen RA cares about the memory which is "physical_mem - (dom0_min_mem + domU_mem * run_num)"
but other RA just care about the physical memory or dom0 memory(Xen kernel).

Can we separate the memory of utilization to dom0_mem and domU_mem ?


--
Thanks,
John
Re: Two git patchs for resource-agents [ In reply to ]
On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:

> >Probably this is one of the areas where we will need to have multiple
> >algorithms to choose from.
> Yes, I also think it is more meaningful,
> But we can only compute the number of cores by the existing algorithms,
> because maybe there is difference between utilization_cpu of node and
> utilization_cpu of resource if they are multiplied by their frequency, is that right ?

I'm sorry, I don't understand the question. Can you rephrase please?
(I've had a long week, I may be missing something.)

> how can we know that node is ready to run Xen RA or other RA, Xen RA
> cares about the memory which is "physical_mem - (dom0_min_mem +
> domU_mem * run_num)" but other RA just care about the physical memory
> or dom0 memory(Xen kernel).
>
> Can we separate the memory of utilization to dom0_mem and domU_mem ?

Indeed, there's a difference between the memory available to the
hypervisor/domain 0/base OS and that available for running guests; this
probably should be handled by os_mem and vm_mem.

I think the main use case with virtualized environments is that they run
"just" VMs, so nobody cares about the memory available in the HVM, but
you're right, it's good to have a clean separation immediately.

Good catch!


Regards,
Lars

--
Architect Storage/HA, OPS Engineering, Novell, Inc.
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 21284 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
>>> Lars Marowsky-Bree 07/22/11 7:40 ?? >>>
On 2011-07-13T22:56:06, John Shi wrote:

>> how can we know that node is ready to run Xen RA or other RA, Xen RA
>> cares about the memory which is "physical_mem - (dom0_min_mem +
>> domU_mem * run_num)" but other RA just care about the physical memory
>> or dom0 memory(Xen kernel).
>>
>> Can we separate the memory of utilization to dom0_mem and domU_mem ?
>
>Indeed, there's a difference between the memory available to the
>hypervisor/domain 0/base OS and that available for running guests; this
>probably should be handled by os_mem and vm_mem.
>
>I think the main use case with virtualized environments is that they run
>"just" VMs, so nobody cares about the memory available in the HVM, but
>you're right, it's good to have a clean separation immediately.
>
>Good catch!


Hi,
Xinwei Hu and I improved the 2 resource-agents patches,
1. Separate the memory of utilization to host_memory and hypervisor_memory.
2. Add some parameters for cpu/memory reservation.
3. VirtualDomain RA just cares about hypervisor_memory.

I know more details we need to discuss, but could we put them into upstream first ?
We can gradually improve these features in future.

Regards,
John
Re: Two git patchs for resource-agents [ In reply to ]
>>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>


>>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:

>> how can we know that node is ready to run Xen RA or other RA, Xen RA
>> cares about the memory which is "physical_mem - (dom0_min_mem +
>> domU_mem * run_num)" but other RA just care about the physical memory
>> or dom0 memory(Xen kernel).
>>
>> Can we separate the memory of utilization to dom0_mem and domU_mem ?
>
>Indeed, there's a difference between the memory available to the
>hypervisor/domain 0/base OS and that available for running guests; this
>probably should be handled by os_mem and vm_mem.
>
>I think the main use case with virtualized environments is that they run
>"just" VMs, so nobody cares about the memory available in the HVM, but
>you're right, it's good to have a clean separation immediately.
>
>Good catch!


Hi,
Xinwei Hu and I improved the 2 resource-agents patches,
1. Separate the memory of utilization to host_memory and hypervisor_memory.
2. Add some parameters for cpu/memory reservation.
3. VirtualDomain RA just cares about hypervisor_memory.

I know more details we need to discuss, but could we put them into upstream first ?
We can gradually improve these features in future.

Regards,
John
Re: Two git patchs for resource-agents [ In reply to ]
Hi John,

On Thu, Aug 18, 2011 at 12:20:26AM -0600, John Shi wrote:
>
>
>
> >>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>
>
>
> >>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
> On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:
>
> >> how can we know that node is ready to run Xen RA or other RA, Xen RA
> >> cares about the memory which is "physical_mem - (dom0_min_mem +
> >> domU_mem * run_num)" but other RA just care about the physical memory
> >> or dom0 memory(Xen kernel).
> >>
> >> Can we separate the memory of utilization to dom0_mem and domU_mem ?
> >
> >Indeed, there's a difference between the memory available to the
> >hypervisor/domain 0/base OS and that available for running guests; this
> >probably should be handled by os_mem and vm_mem.
> >
> >I think the main use case with virtualized environments is that they run
> >"just" VMs, so nobody cares about the memory available in the HVM, but
> >you're right, it's good to have a clean separation immediately.
> >
> >Good catch!
>
>
> Hi,
> Xinwei Hu and I improved the 2 resource-agents patches,
> 1. Separate the memory of utilization to host_memory and hypervisor_memory.
> 2. Add some parameters for cpu/memory reservation.
> 3. VirtualDomain RA just cares about hypervisor_memory.
>
> I know more details we need to discuss, but could we put them into upstream first ?

I wasn't involved in the discussion earlier. Can you please
reiterate which details are still open?

Also, should the new NodeUtilization RA go into the pacemaker tree?

Cheers,

Dejan

P.S. Is this a resend of the same patches you sent on Aug 12?

> We can gradually improve these features in future.
>
> Regards,
> John

> From 9071409ecd0e0951af74a7823d5d2f712a0f22f3 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@novell.com>
> Date: Sat, 13 Aug 2011 02:18:50 +0800
> Subject: [PATCH] Build: Add a new agent: NodeUtilization.
> This agent detects system parameters and put them into CIB by crm_attribute,
> and it runs on every node as clone resource.
>
> ---
> heartbeat/Makefile.am | 1 +
> heartbeat/NodeUtilization | 229 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 230 insertions(+), 0 deletions(-)
> create mode 100755 heartbeat/NodeUtilization
>
> diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
> index dacf3bd..3a3d221 100644
> --- a/heartbeat/Makefile.am
> +++ b/heartbeat/Makefile.am
> @@ -77,6 +77,7 @@ ocf_SCRIPTS = ClusterMon \
> mysql \
> mysql-proxy \
> nfsserver \
> + NodeUtilization \
> oracle \
> oralsnr \
> pingd \
> diff --git a/heartbeat/NodeUtilization b/heartbeat/NodeUtilization
> new file mode 100755
> index 0000000..dca0d9a
> --- /dev/null
> +++ b/heartbeat/NodeUtilization
> @@ -0,0 +1,229 @@
> +#!/bin/sh
> +#
> +#
> +# NodeUtilization OCF Resource Agent
> +#
> +# Copyright (c) 2011 SUSE LINUX, John Shi
> +# All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of version 2 of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +#
> +# Further, this software is distributed without any warranty that it is
> +# free of the rightful claim of any third person regarding infringement
> +# or the like. Any license provided herein, whether implied or
> +# otherwise, applies only to this software file. Patent licenses, if
> +# any, provided herein do not apply to combinations of this program with
> +# other software, or any other product whatsoever.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> +#
> +#######################################################################
> +# Initialization:
> +
> +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
> +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
> +
> +#######################################################################
> +
> +meta_data() {
> + cat <<END
> +<?xml version="1.0"?>
> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> +<resource-agent name="NodeUtilization">
> +<version>1.0</version>
> +
> +<longdesc lang="en">
> +This is an NodeUtilization Resource Agent.
> +This agent detects system parameters and put them into CIB by crm_attribute,
> +and it runs on every node as clone resource.
> +</longdesc>
> +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> +
> +<parameters>
> +<parameter name="dynamic" unique="0" required="0">
> +<longdesc lang="en">
> +If set, some of the HA parameters will be reset if there are
> +difference between HA parameters and system parameters when HA monitor.
> +Otherwise, the HA parameters will be set once when the resource instance starts.
> +</longdesc>
> +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> +<content type="integer" default="1" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +</parameters>
> +
> +<actions>
> +<action name="start" timeout="90" />
> +<action name="stop" timeout="100" />
> +<action name="monitor" timeout="20s" interval="60s"/>
> +<action name="meta-data" timeout="5" />
> +<action name="validate-all" timeout="30" />
> +</actions>
> +</resource-agent>
> +END
> +}
> +
> +set_utilization() {
> + host_name="$(hostname)"
> +
> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> +
> + if [ "$sys_cpu" != "$uti_cpu" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> +
> + if [ "$sys_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ -x /usr/sbin/xm ]; then
> + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> +
> + if [ "$hv_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> + fi
> +}
> +
> +NodeUtilization_usage() {
> + cat <<END
> +usage: $0 {start|stop|monitor|validate-all|meta-data}
> +
> +Expects to have a fully populated OCF RA-compliant environment set.
> +END
> +}
> +
> +NodeUtilization_start() {
> + if ! touch "$OCF_RESKEY_pidfile"; then
> + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> + exit $OCF_ERR_GENERIC
> + fi
> + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_stop() {
> + rm -f $OCF_RESKEY_pidfile
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_monitor() {
> + if [ ! -f $OCF_RESKEY_pidfile ]; then
> + exit $OCF_NOT_RUNNING
> + fi
> +
> + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_validate() {
> + exit $OCF_SUCCESS
> +}
> +
> +
> +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> +: ${OCF_RESKEY_dynamic:="true"}
> +: ${OCF_RESKEY_utilization_cpu:="true"}
> +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> +: ${OCF_RESKEY_utilization_host_memory:="true"}
> +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> +
> +if [ $# -ne 1 ]; then
> + NodeUtilization_usage
> + exit $OCF_ERR_ARGS
> +fi
> +
> +case $__OCF_ACTION in
> +meta-data) meta_data
> + exit $OCF_SUCCESS
> + ;;
> +start) NodeUtilization_start
> + ;;
> +stop) NodeUtilization_stop
> + ;;
> +monitor) NodeUtilization_monitor
> + ;;
> +validate-all) NodeUtilization_validate
> + ;;
> +usage|help) NodeUtilization_usage
> + exit $OCF_SUCCESS
> + ;;
> +*) NodeUtilization_usage
> + exit $OCF_ERR_UNIMPLEMENTED
> + ;;
> +esac
> +
> +exit $?
> --
> 1.7.2.5
>

> From 3f26aa2cf5f9f7da40182008079c6ea7498f96fd Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@novell.com>
> Date: Sat, 13 Aug 2011 02:25:37 +0800
> Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifiesutilization of resource automatically.
>
> ---
> heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> index 0786944..d9321d9 100755
> --- a/heartbeat/VirtualDomain
> +++ b/heartbeat/VirtualDomain
> @@ -19,9 +19,15 @@
> # Defaults
> OCF_RESKEY_force_stop_default=0
> OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> +OCF_RESKEY_dynamic_utilization_default="true"
> +OCF_RESKEY_set_utilization_cpu_default="true"
> +OCF_RESKEY_set_utilization_memory_default="true"
>
> : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> #######################################################################
>
> ## I'd very much suggest to make this RA use bash,
> @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> <content type="string" default="" />
> </parameter>
>
> +<parameter name="dynamic_utilization" unique="0" required="0">
> +<longdesc lang="en">
> +If set, the utilization parameter of resource will be reset if there are
> +difference between resource parameters and system parameters when agent monitor.
> +Otherwise, the resource parameters will be set once when agent start.
> +</longdesc>
> +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> </parameters>
>
> <actions>
> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> EOF
> }
>
> +set_utilization() {
> + local dom_cpu dom_mem
> + local uti_cpu uti_mem
> +
> + read dom_cpu dom_mem <<EOF
> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> +EOF
> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> +
> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> + if [ "$dom_cpu" != "$uti_cpu" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> + fi
> + fi
> + fi
> + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> + if [ "$dom_mem" != "$uti_mem" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> + fi
> + fi
> + fi
> +}
> +
> # Set options to be passed to virsh:
> VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
>
> @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> while ! VirtualDomain_Monitor; do
> sleep 1
> done
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> + set_utilization
> + fi
> +
> return $OCF_SUCCESS
> }
>
> @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> fi
> done
> fi
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> + if ocf_is_probe; then
> + set_utilization
> + fi
> + fi
> +
> return ${rc}
> }
>
> --
> 1.7.2.5
>


_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi Dejan,
I made the new patch for pacemaker, it contains the new NodeUtilization RA.
Yes, this is a resend of the same patches I sent last time, but just separate the NodeUtilization RA to pacemaker.

Regards,
John


>>> Dejan Muhamedagic <dejan@suse.de> 8/19/2011 8:18 下午 >>>
Hi John,

On Thu, Aug 18, 2011 at 12:20:26AM -0600, John Shi wrote:
>
>
>
> >>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>
>
>
> >>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
> On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:
>
> >> how can we know that node is ready to run Xen RA or other RA, Xen RA
> >> cares about the memory which is "physical_mem - (dom0_min_mem +
> >> domU_mem * run_num)" but other RA just care about the physical memory
> >> or dom0 memory(Xen kernel).
> >>
> >> Can we separate the memory of utilization to dom0_mem and domU_mem ?
> >
> >Indeed, there's a difference between the memory available to the
> >hypervisor/domain 0/base OS and that available for running guests; this
> >probably should be handled by os_mem and vm_mem.
> >
> >I think the main use case with virtualized environments is that they run
> >"just" VMs, so nobody cares about the memory available in the HVM, but
> >you're right, it's good to have a clean separation immediately.
> >
> >Good catch!
>
>
> Hi,
> Xinwei Hu and I improved the 2 resource-agents patches,
> 1. Separate the memory of utilization to host_memory and hypervisor_memory.
> 2. Add some parameters for cpu/memory reservation.
> 3. VirtualDomain RA just cares about hypervisor_memory.
>
> I know more details we need to discuss, but could we put them into upstream first ?

I wasn't involved in the discussion earlier. Can you please
reiterate which details are still open?

Also, should the new NodeUtilization RA go into the pacemaker tree?

Cheers,

Dejan

P.S. Is this a resend of the same patches you sent on Aug 12?

> We can gradually improve these features in future.
>
> Regards,
> John

> From 9071409ecd0e0951af74a7823d5d2f712a0f22f3 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@novell.com>
> Date: Sat, 13 Aug 2011 02:18:50 +0800
> Subject: [PATCH] Build: Add a new agent: NodeUtilization.
> This agent detects system parameters and put them into CIB by crm_attribute,
> and it runs on every node as clone resource.
>
> ---
> heartbeat/Makefile.am | 1 +
> heartbeat/NodeUtilization | 229 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 230 insertions(+), 0 deletions(-)
> create mode 100755 heartbeat/NodeUtilization
>
> diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
> index dacf3bd..3a3d221 100644
> --- a/heartbeat/Makefile.am
> +++ b/heartbeat/Makefile.am
> @@ -77,6 +77,7 @@ ocf_SCRIPTS = ClusterMon\
> mysql\
> mysql-proxy\
> nfsserver\
> +NodeUtilization\
> oracle\
> oralsnr\
> pingd\
> diff --git a/heartbeat/NodeUtilization b/heartbeat/NodeUtilization
> new file mode 100755
> index 0000000..dca0d9a
> --- /dev/null
> +++ b/heartbeat/NodeUtilization
> @@ -0,0 +1,229 @@
> +#!/bin/sh
> +#
> +#
> +#NodeUtilization OCF Resource Agent
> +#
> +# Copyright (c) 2011 SUSE LINUX, John Shi
> +# All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of version 2 of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +#
> +# Further, this software is distributed without any warranty that it is
> +# free of the rightful claim of any third person regarding infringement
> +# or the like. Any license provided herein, whether implied or
> +# otherwise, applies only to this software file. Patent licenses, if
> +# any, provided herein do not apply to combinations of this program with
> +# other software, or any other product whatsoever.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> +#
> +#######################################################################
> +# Initialization:
> +
> +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
> +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
> +
> +#######################################################################
> +
> +meta_data() {
> +cat <<END
> +<?xml version="1.0"?>
> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> +<resource-agent name="NodeUtilization">
> +<version>1.0</version>
> +
> +<longdesc lang="en">
> +This is an NodeUtilization Resource Agent.
> +This agent detects system parameters and put them into CIB by crm_attribute,
> +and it runs on every node as clone resource.
> +</longdesc>
> +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> +
> +<parameters>
> +<parameter name="dynamic" unique="0" required="0">
> +<longdesc lang="en">
> +If set, some of the HA parameters will be reset if there are
> +difference between HA parameters and system parameters when HA monitor.
> +Otherwise, the HA parameters will be set once when the resource instance starts.
> +</longdesc>
> +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> +<content type="integer" default="1" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +</parameters>
> +
> +<actions>
> +<action name="start" timeout="90" />
> +<action name="stop" timeout="100" />
> +<action name="monitor" timeout="20s" interval="60s"/>
> +<action name="meta-data" timeout="5" />
> +<action name="validate-all" timeout="30" />
> +</actions>
> +</resource-agent>
> +END
> +}
> +
> +set_utilization() {
> + host_name="$(hostname)"
> +
> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> +
> + if [ "$sys_cpu" != "$uti_cpu" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> +
> + if [ "$sys_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ -x /usr/sbin/xm ]; then
> + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> +
> + if [ "$hv_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> + fi
> +}
> +
> +NodeUtilization_usage() {
> +cat <<END
> +usage: $0 {start|stop|monitor|validate-all|meta-data}
> +
> +Expects to have a fully populated OCF RA-compliant environment set.
> +END
> +}
> +
> +NodeUtilization_start() {
> + if ! touch "$OCF_RESKEY_pidfile"; then
> + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> + exit $OCF_ERR_GENERIC
> + fi
> + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_stop() {
> + rm -f $OCF_RESKEY_pidfile
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_monitor() {
> + if [ ! -f $OCF_RESKEY_pidfile ]; then
> + exit $OCF_NOT_RUNNING
> + fi
> +
> + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_validate() {
> + exit $OCF_SUCCESS
> +}
> +
> +
> +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> +: ${OCF_RESKEY_dynamic:="true"}
> +: ${OCF_RESKEY_utilization_cpu:="true"}
> +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> +: ${OCF_RESKEY_utilization_host_memory:="true"}
> +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> +
> +if [ $# -ne 1 ]; then
> + NodeUtilization_usage
> + exit $OCF_ERR_ARGS
> +fi
> +
> +case $__OCF_ACTION in
> +meta-data)meta_data
> +exit $OCF_SUCCESS
> +;;
> +start)NodeUtilization_start
> +;;
> +stop)NodeUtilization_stop
> +;;
> +monitor)NodeUtilization_monitor
> +;;
> +validate-all)NodeUtilization_validate
> +;;
> +usage|help)NodeUtilization_usage
> +exit $OCF_SUCCESS
> +;;
> +*)NodeUtilization_usage
> +exit $OCF_ERR_UNIMPLEMENTED
> +;;
> +esac
> +
> +exit $?
> --
> 1.7.2.5
>

> From 3f26aa2cf5f9f7da40182008079c6ea7498f96fd Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@novell.com>
> Date: Sat, 13 Aug 2011 02:25:37 +0800
> Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifiesutilization of resource automatically.
>
> ---
> heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> index 0786944..d9321d9 100755
> --- a/heartbeat/VirtualDomain
> +++ b/heartbeat/VirtualDomain
> @@ -19,9 +19,15 @@
> # Defaults
> OCF_RESKEY_force_stop_default=0
> OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> +OCF_RESKEY_dynamic_utilization_default="true"
> +OCF_RESKEY_set_utilization_cpu_default="true"
> +OCF_RESKEY_set_utilization_memory_default="true"
>
> : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> #######################################################################
>
> ## I'd very much suggest to make this RA use bash,
> @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> <content type="string" default="" />
> </parameter>
>
> +<parameter name="dynamic_utilization" unique="0" required="0">
> +<longdesc lang="en">
> +If set, the utilization parameter of resource will be reset if there are
> +difference between resource parameters and system parameters when agent monitor.
> +Otherwise, the resource parameters will be set once when agent start.
> +</longdesc>
> +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> </parameters>
>
> <actions>
> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> EOF
> }
>
> +set_utilization() {
> + local dom_cpu dom_mem
> + local uti_cpu uti_mem
> +
> + read dom_cpu dom_mem <<EOF
> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> +EOF
> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> +
> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> + if [ "$dom_cpu" != "$uti_cpu" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> + fi
> + fi
> + fi
> + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> + if [ "$dom_mem" != "$uti_mem" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> + fi
> + fi
> + fi
> +}
> +
> # Set options to be passed to virsh:
> VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
>
> @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> while ! VirtualDomain_Monitor; do
> sleep 1
> done
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> + set_utilization
> + fi
> +
> return $OCF_SUCCESS
> }
>
> @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> fi
> done
> fi
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> + if ocf_is_probe; then
> + set_utilization
> + fi
> + fi
> +
> return ${rc}
> }
>
> --
> 1.7.2.5
>


_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi John,

On Fri, Oct 28, 2011 at 08:21:28AM -0600, John Shi wrote:
>
> Hi Dejan,
> I made the new patch for pacemaker, it contains the new NodeUtilization RA.
> Yes, this is a resend of the same patches I sent last time, but just separate the NodeUtilization RA to pacemaker.

So, which issues do you still think are open?

Cheers,

Dejan

> Regards,
> John
>
>
> >>> Dejan Muhamedagic <dejan@suse.de> 8/19/2011 8:18 下午 >>>
> Hi John,
>
> On Thu, Aug 18, 2011 at 12:20:26AM -0600, John Shi wrote:
> >
> >
> >
> > >>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>
> >
> >
> > >>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
> > On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:
> >
> > >> how can we know that node is ready to run Xen RA or other RA, Xen RA
> > >> cares about the memory which is "physical_mem - (dom0_min_mem +
> > >> domU_mem * run_num)" but other RA just care about the physical memory
> > >> or dom0 memory(Xen kernel).
> > >>
> > >> Can we separate the memory of utilization to dom0_mem and domU_mem ?
> > >
> > >Indeed, there's a difference between the memory available to the
> > >hypervisor/domain 0/base OS and that available for running guests; this
> > >probably should be handled by os_mem and vm_mem.
> > >
> > >I think the main use case with virtualized environments is that they run
> > >"just" VMs, so nobody cares about the memory available in the HVM, but
> > >you're right, it's good to have a clean separation immediately.
> > >
> > >Good catch!
> >
> >
> > Hi,
> > Xinwei Hu and I improved the 2 resource-agents patches,
> > 1. Separate the memory of utilization to host_memory and hypervisor_memory.
> > 2. Add some parameters for cpu/memory reservation.
> > 3. VirtualDomain RA just cares about hypervisor_memory.
> >
> > I know more details we need to discuss, but could we put them into upstream first ?
>
> I wasn't involved in the discussion earlier. Can you please
> reiterate which details are still open?
>
> Also, should the new NodeUtilization RA go into the pacemaker tree?
>
> Cheers,
>
> Dejan
>
> P.S. Is this a resend of the same patches you sent on Aug 12?
>
> > We can gradually improve these features in future.
> >
> > Regards,
> > John
>
> > From 9071409ecd0e0951af74a7823d5d2f712a0f22f3 Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@novell.com>
> > Date: Sat, 13 Aug 2011 02:18:50 +0800
> > Subject: [PATCH] Build: Add a new agent: NodeUtilization.
> > This agent detects system parameters and put them into CIB by crm_attribute,
> > and it runs on every node as clone resource.
> >
> > ---
> > heartbeat/Makefile.am | 1 +
> > heartbeat/NodeUtilization | 229 +++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 230 insertions(+), 0 deletions(-)
> > create mode 100755 heartbeat/NodeUtilization
> >
> > diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
> > index dacf3bd..3a3d221 100644
> > --- a/heartbeat/Makefile.am
> > +++ b/heartbeat/Makefile.am
> > @@ -77,6 +77,7 @@ ocf_SCRIPTS = ClusterMon\
> > mysql\
> > mysql-proxy\
> > nfsserver\
> > +NodeUtilization\
> > oracle\
> > oralsnr\
> > pingd\
> > diff --git a/heartbeat/NodeUtilization b/heartbeat/NodeUtilization
> > new file mode 100755
> > index 0000000..dca0d9a
> > --- /dev/null
> > +++ b/heartbeat/NodeUtilization
> > @@ -0,0 +1,229 @@
> > +#!/bin/sh
> > +#
> > +#
> > +#NodeUtilization OCF Resource Agent
> > +#
> > +# Copyright (c) 2011 SUSE LINUX, John Shi
> > +# All Rights Reserved.
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of version 2 of the GNU General Public License as
> > +# published by the Free Software Foundation.
> > +#
> > +# This program is distributed in the hope that it would be useful, but
> > +# WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > +#
> > +# Further, this software is distributed without any warranty that it is
> > +# free of the rightful claim of any third person regarding infringement
> > +# or the like. Any license provided herein, whether implied or
> > +# otherwise, applies only to this software file. Patent licenses, if
> > +# any, provided herein do not apply to combinations of this program with
> > +# other software, or any other product whatsoever.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write the Free Software Foundation,
> > +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> > +#
> > +#######################################################################
> > +# Initialization:
> > +
> > +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
> > +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
> > +
> > +#######################################################################
> > +
> > +meta_data() {
> > +cat <<END
> > +<?xml version="1.0"?>
> > +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> > +<resource-agent name="NodeUtilization">
> > +<version>1.0</version>
> > +
> > +<longdesc lang="en">
> > +This is an NodeUtilization Resource Agent.
> > +This agent detects system parameters and put them into CIB by crm_attribute,
> > +and it runs on every node as clone resource.
> > +</longdesc>
> > +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> > +
> > +<parameters>
> > +<parameter name="dynamic" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, some of the HA parameters will be reset if there are
> > +difference between HA parameters and system parameters when HA monitor.
> > +Otherwise, the HA parameters will be set once when the resource instance starts.
> > +</longdesc>
> > +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> > +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> > +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> > +<content type="integer" default="1" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> > +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> > +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +</parameters>
> > +
> > +<actions>
> > +<action name="start" timeout="90" />
> > +<action name="stop" timeout="100" />
> > +<action name="monitor" timeout="20s" interval="60s"/>
> > +<action name="meta-data" timeout="5" />
> > +<action name="validate-all" timeout="30" />
> > +</actions>
> > +</resource-agent>
> > +END
> > +}
> > +
> > +set_utilization() {
> > + host_name="$(hostname)"
> > +
> > + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> > + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> > + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> > +
> > + if [ "$sys_cpu" != "$uti_cpu" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> > + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> > + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> > +
> > + if [ "$sys_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> > + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ -x /usr/sbin/xm ]; then
> > + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> > + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> > +
> > + if [ "$hv_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> > + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > +NodeUtilization_usage() {
> > +cat <<END
> > +usage: $0 {start|stop|monitor|validate-all|meta-data}
> > +
> > +Expects to have a fully populated OCF RA-compliant environment set.
> > +END
> > +}
> > +
> > +NodeUtilization_start() {
> > + if ! touch "$OCF_RESKEY_pidfile"; then
> > + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_stop() {
> > + rm -f $OCF_RESKEY_pidfile
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_monitor() {
> > + if [ ! -f $OCF_RESKEY_pidfile ]; then
> > + exit $OCF_NOT_RUNNING
> > + fi
> > +
> > + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_validate() {
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +
> > +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> > +: ${OCF_RESKEY_dynamic:="true"}
> > +: ${OCF_RESKEY_utilization_cpu:="true"}
> > +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> > +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> > +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> > +: ${OCF_RESKEY_utilization_host_memory:="true"}
> > +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> > +
> > +if [ $# -ne 1 ]; then
> > + NodeUtilization_usage
> > + exit $OCF_ERR_ARGS
> > +fi
> > +
> > +case $__OCF_ACTION in
> > +meta-data)meta_data
> > +exit $OCF_SUCCESS
> > +;;
> > +start)NodeUtilization_start
> > +;;
> > +stop)NodeUtilization_stop
> > +;;
> > +monitor)NodeUtilization_monitor
> > +;;
> > +validate-all)NodeUtilization_validate
> > +;;
> > +usage|help)NodeUtilization_usage
> > +exit $OCF_SUCCESS
> > +;;
> > +*)NodeUtilization_usage
> > +exit $OCF_ERR_UNIMPLEMENTED
> > +;;
> > +esac
> > +
> > +exit $?
> > --
> > 1.7.2.5
> >
>
> > From 3f26aa2cf5f9f7da40182008079c6ea7498f96fd Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@novell.com>
> > Date: Sat, 13 Aug 2011 02:25:37 +0800
> > Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifiesutilization of resource automatically.
> >
> > ---
> > heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 67 insertions(+), 0 deletions(-)
> >
> > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> > index 0786944..d9321d9 100755
> > --- a/heartbeat/VirtualDomain
> > +++ b/heartbeat/VirtualDomain
> > @@ -19,9 +19,15 @@
> > # Defaults
> > OCF_RESKEY_force_stop_default=0
> > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> > +OCF_RESKEY_dynamic_utilization_default="true"
> > +OCF_RESKEY_set_utilization_cpu_default="true"
> > +OCF_RESKEY_set_utilization_memory_default="true"
> >
> > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> > +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> > +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> > +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> > #######################################################################
> >
> > ## I'd very much suggest to make this RA use bash,
> > @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > <content type="string" default="" />
> > </parameter>
> >
> > +<parameter name="dynamic_utilization" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, the utilization parameter of resource will be reset if there are
> > +difference between resource parameters and system parameters when agent monitor.
> > +Otherwise, the resource parameters will be set once when agent start.
> > +</longdesc>
> > +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > </parameters>
> >
> > <actions>
> > @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > EOF
> > }
> >
> > +set_utilization() {
> > + local dom_cpu dom_mem
> > + local uti_cpu uti_mem
> > +
> > + read dom_cpu dom_mem <<EOF
> > +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> > +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> > +EOF
> > + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> > + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> > +
> > + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> > + if [ "$dom_cpu" != "$uti_cpu" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> > + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> > + if [ "$dom_mem" != "$uti_mem" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> > + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > # Set options to be passed to virsh:
> > VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
> >
> > @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> > while ! VirtualDomain_Monitor; do
> > sleep 1
> > done
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> > + set_utilization
> > + fi
> > +
> > return $OCF_SUCCESS
> > }
> >
> > @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> > fi
> > done
> > fi
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> > + if ocf_is_probe; then
> > + set_utilization
> > + fi
> > + fi
> > +
> > return ${rc}
> > }
> >
> > --
> > 1.7.2.5
> >
>
>
> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical

> From e39948043d94c30557851d2b759468da3935d072 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.de>
> Date: Fri, 28 Oct 2011 21:53:33 +0800
> Subject: [PATCH] Low: Build: New agent NodeUtilization which is detecting os information and putting them into CIB by crm_attribute
>
> ---
> extra/resources/Makefile.am | 1 +
> extra/resources/NodeUtilization | 228 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 229 insertions(+), 0 deletions(-)
> create mode 100644 extra/resources/NodeUtilization
>
> diff --git a/extra/resources/Makefile.am b/extra/resources/Makefile.am
> index bc35401..210e9ed 100644
> --- a/extra/resources/Makefile.am
> +++ b/extra/resources/Makefile.am
> @@ -27,6 +27,7 @@ ocf_SCRIPTS = ClusterMon \
> Dummy \
> HealthCPU \
> HealthSMART \
> + NodeUtilization \
> o2cb \
> ping \
> pingd \
> diff --git a/extra/resources/NodeUtilization b/extra/resources/NodeUtilization
> new file mode 100644
> index 0000000..483053a
> --- /dev/null
> +++ b/extra/resources/NodeUtilization
> @@ -0,0 +1,228 @@
> +#!/bin/sh
> +#
> +#
> +# NodeUtilization OCF Resource Agent
> +#
> +# Copyright (c) 2011 SUSE LINUX, John Shi
> +# All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of version 2 of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +#
> +# Further, this software is distributed without any warranty that it is
> +# free of the rightful claim of any third person regarding infringement
> +# or the like. Any license provided herein, whether implied or
> +# otherwise, applies only to this software file. Patent licenses, if
> +# any, provided herein do not apply to combinations of this program with
> +# other software, or any other product whatsoever.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> +#
> +#######################################################################
> +# Initialization:
> +
> +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
> +
> +#######################################################################
> +
> +meta_data() {
> + cat <<END
> +<?xml version="1.0"?>
> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> +<resource-agent name="NodeUtilization">
> +<version>1.0</version>
> +
> +<longdesc lang="en">
> +This is an NodeUtilization Resource Agent.
> +This agent detects system parameters and put them into CIB by crm_attribute,
> +and it runs on every node as clone resource.
> +</longdesc>
> +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> +
> +<parameters>
> +<parameter name="dynamic" unique="0" required="0">
> +<longdesc lang="en">
> +If set, some of the HA parameters will be reset if there are
> +difference between HA parameters and system parameters when HA monitor.
> +Otherwise, the HA parameters will be set once when the resource instance starts.
> +</longdesc>
> +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> +<content type="integer" default="1" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +</parameters>
> +
> +<actions>
> +<action name="start" timeout="90" />
> +<action name="stop" timeout="100" />
> +<action name="monitor" timeout="20s" interval="60s"/>
> +<action name="meta-data" timeout="5" />
> +<action name="validate-all" timeout="30" />
> +</actions>
> +</resource-agent>
> +END
> +}
> +
> +set_utilization() {
> + host_name="$(hostname)"
> +
> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> +
> + if [ "$sys_cpu" != "$uti_cpu" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> +
> + if [ "$sys_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ -x /usr/sbin/xm ]; then
> + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> +
> + if [ "$hv_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> + fi
> +}
> +
> +NodeUtilization_usage() {
> + cat <<END
> +usage: $0 {start|stop|monitor|validate-all|meta-data}
> +
> +Expects to have a fully populated OCF RA-compliant environment set.
> +END
> +}
> +
> +NodeUtilization_start() {
> + if ! touch "$OCF_RESKEY_pidfile"; then
> + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> + exit $OCF_ERR_GENERIC
> + fi
> + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_stop() {
> + rm -f $OCF_RESKEY_pidfile
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_monitor() {
> + if [ ! -f $OCF_RESKEY_pidfile ]; then
> + exit $OCF_NOT_RUNNING
> + fi
> +
> + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_validate() {
> + exit $OCF_SUCCESS
> +}
> +
> +
> +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> +: ${OCF_RESKEY_dynamic:="true"}
> +: ${OCF_RESKEY_utilization_cpu:="true"}
> +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> +: ${OCF_RESKEY_utilization_host_memory:="true"}
> +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> +
> +if [ $# -ne 1 ]; then
> + NodeUtilization_usage
> + exit $OCF_ERR_ARGS
> +fi
> +
> +case $__OCF_ACTION in
> +meta-data) meta_data
> + exit $OCF_SUCCESS
> + ;;
> +start) NodeUtilization_start
> + ;;
> +stop) NodeUtilization_stop
> + ;;
> +monitor) NodeUtilization_monitor
> + ;;
> +validate-all) NodeUtilization_validate
> + ;;
> +usage|help) NodeUtilization_usage
> + exit $OCF_SUCCESS
> + ;;
> +*) NodeUtilization_usage
> + exit $OCF_ERR_UNIMPLEMENTED
> + ;;
> +esac
> +
> +exit $?
> --
> 1.6.0.2
>

> From 7fffa2d22efb1610a4ca2424b6bc9455f1f5cce8 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.de>
> Date: Fri, 28 Oct 2011 21:56:51 +0800
> Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifies utilization of resource automatically.
>
> ---
> heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> index 0786944..d9321d9 100755
> --- a/heartbeat/VirtualDomain
> +++ b/heartbeat/VirtualDomain
> @@ -19,9 +19,15 @@
> # Defaults
> OCF_RESKEY_force_stop_default=0
> OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> +OCF_RESKEY_dynamic_utilization_default="true"
> +OCF_RESKEY_set_utilization_cpu_default="true"
> +OCF_RESKEY_set_utilization_memory_default="true"
>
> : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> #######################################################################
>
> ## I'd very much suggest to make this RA use bash,
> @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> <content type="string" default="" />
> </parameter>
>
> +<parameter name="dynamic_utilization" unique="0" required="0">
> +<longdesc lang="en">
> +If set, the utilization parameter of resource will be reset if there are
> +difference between resource parameters and system parameters when agent monitor.
> +Otherwise, the resource parameters will be set once when agent start.
> +</longdesc>
> +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> </parameters>
>
> <actions>
> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> EOF
> }
>
> +set_utilization() {
> + local dom_cpu dom_mem
> + local uti_cpu uti_mem
> +
> + read dom_cpu dom_mem <<EOF
> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> +EOF
> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> +
> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> + if [ "$dom_cpu" != "$uti_cpu" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> + fi
> + fi
> + fi
> + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> + if [ "$dom_mem" != "$uti_mem" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> + fi
> + fi
> + fi
> +}
> +
> # Set options to be passed to virsh:
> VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
>
> @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> while ! VirtualDomain_Monitor; do
> sleep 1
> done
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> + set_utilization
> + fi
> +
> return $OCF_SUCCESS
> }
>
> @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> fi
> done
> fi
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> + if ocf_is_probe; then
> + set_utilization
> + fi
> + fi
> +
> return ${rc}
> }
>
> --
> 1.6.4.2
>

> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi Dejan,
I think we can close these two issues, if we want to improve, or someone has good idea,
we can open a new issue.

Regards,
John

>>> Dejan Muhamedagic <dejan@suse.de> 10/28/2011 10:39 下午 >>>
Hi John,

On Fri, Oct 28, 2011 at 08:21:28AM -0600, John Shi wrote:
>
> Hi Dejan,
> I made the new patch for pacemaker, it contains the new NodeUtilization RA.
> Yes, this is a resend of the same patches I sent last time, but just separate the NodeUtilization RA to pacemaker.

So, which issues do you still think are open?

Cheers,

Dejan

> Regards,
> John
>
>
> >>> Dejan Muhamedagic <dejan@suse.de> 8/19/2011 8:18 下午 >>>
> Hi John,
>
> On Thu, Aug 18, 2011 at 12:20:26AM -0600, John Shi wrote:
> >
> >
> >
> > >>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>
> >
> >
> > >>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
> > On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:
> >
> > >> how can we know that node is ready to run Xen RA or other RA, Xen RA
> > >> cares about the memory which is "physical_mem - (dom0_min_mem +
> > >> domU_mem * run_num)" but other RA just care about the physical memory
> > >> or dom0 memory(Xen kernel).
> > >>
> > >> Can we separate the memory of utilization to dom0_mem and domU_mem ?
> > >
> > >Indeed, there's a difference between the memory available to the
> > >hypervisor/domain 0/base OS and that available for running guests; this
> > >probably should be handled by os_mem and vm_mem.
> > >
> > >I think the main use case with virtualized environments is that they run
> > >"just" VMs, so nobody cares about the memory available in the HVM, but
> > >you're right, it's good to have a clean separation immediately.
> > >
> > >Good catch!
> >
> >
> > Hi,
> > Xinwei Hu and I improved the 2 resource-agents patches,
> > 1. Separate the memory of utilization to host_memory and hypervisor_memory.
> > 2. Add some parameters for cpu/memory reservation.
> > 3. VirtualDomain RA just cares about hypervisor_memory.
> >
> > I know more details we need to discuss, but could we put them into upstream first ?
>
> I wasn't involved in the discussion earlier. Can you please
> reiterate which details are still open?
>
> Also, should the new NodeUtilization RA go into the pacemaker tree?
>
> Cheers,
>
> Dejan
>
> P.S. Is this a resend of the same patches you sent on Aug 12?
>
> > We can gradually improve these features in future.
> >
> > Regards,
> > John
>
> > From 9071409ecd0e0951af74a7823d5d2f712a0f22f3 Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@novell.com>
> > Date: Sat, 13 Aug 2011 02:18:50 +0800
> > Subject: [PATCH] Build: Add a new agent: NodeUtilization.
> > This agent detects system parameters and put them into CIB by crm_attribute,
> > and it runs on every node as clone resource.
> >
> > ---
> > heartbeat/Makefile.am | 1 +
> > heartbeat/NodeUtilization | 229 +++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 230 insertions(+), 0 deletions(-)
> > create mode 100755 heartbeat/NodeUtilization
> >
> > diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
> > index dacf3bd..3a3d221 100644
> > --- a/heartbeat/Makefile.am
> > +++ b/heartbeat/Makefile.am
> > @@ -77,6 +77,7 @@ ocf_SCRIPTS = ClusterMon\
> > mysql\
> > mysql-proxy\
> > nfsserver\
> > +NodeUtilization\
> > oracle\
> > oralsnr\
> > pingd\
> > diff --git a/heartbeat/NodeUtilization b/heartbeat/NodeUtilization
> > new file mode 100755
> > index 0000000..dca0d9a
> > --- /dev/null
> > +++ b/heartbeat/NodeUtilization
> > @@ -0,0 +1,229 @@
> > +#!/bin/sh
> > +#
> > +#
> > +#NodeUtilization OCF Resource Agent
> > +#
> > +# Copyright (c) 2011 SUSE LINUX, John Shi
> > +# All Rights Reserved.
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of version 2 of the GNU General Public License as
> > +# published by the Free Software Foundation.
> > +#
> > +# This program is distributed in the hope that it would be useful, but
> > +# WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > +#
> > +# Further, this software is distributed without any warranty that it is
> > +# free of the rightful claim of any third person regarding infringement
> > +# or the like. Any license provided herein, whether implied or
> > +# otherwise, applies only to this software file. Patent licenses, if
> > +# any, provided herein do not apply to combinations of this program with
> > +# other software, or any other product whatsoever.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write the Free Software Foundation,
> > +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> > +#
> > +#######################################################################
> > +# Initialization:
> > +
> > +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
> > +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
> > +
> > +#######################################################################
> > +
> > +meta_data() {
> > +cat <<END
> > +<?xml version="1.0"?>
> > +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> > +<resource-agent name="NodeUtilization">
> > +<version>1.0</version>
> > +
> > +<longdesc lang="en">
> > +This is an NodeUtilization Resource Agent.
> > +This agent detects system parameters and put them into CIB by crm_attribute,
> > +and it runs on every node as clone resource.
> > +</longdesc>
> > +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> > +
> > +<parameters>
> > +<parameter name="dynamic" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, some of the HA parameters will be reset if there are
> > +difference between HA parameters and system parameters when HA monitor.
> > +Otherwise, the HA parameters will be set once when the resource instance starts.
> > +</longdesc>
> > +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> > +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> > +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> > +<content type="integer" default="1" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> > +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> > +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +</parameters>
> > +
> > +<actions>
> > +<action name="start" timeout="90" />
> > +<action name="stop" timeout="100" />
> > +<action name="monitor" timeout="20s" interval="60s"/>
> > +<action name="meta-data" timeout="5" />
> > +<action name="validate-all" timeout="30" />
> > +</actions>
> > +</resource-agent>
> > +END
> > +}
> > +
> > +set_utilization() {
> > + host_name="$(hostname)"
> > +
> > + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> > + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> > + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> > +
> > + if [ "$sys_cpu" != "$uti_cpu" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> > + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> > + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> > +
> > + if [ "$sys_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> > + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ -x /usr/sbin/xm ]; then
> > + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> > + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> > +
> > + if [ "$hv_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> > + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > +NodeUtilization_usage() {
> > +cat <<END
> > +usage: $0 {start|stop|monitor|validate-all|meta-data}
> > +
> > +Expects to have a fully populated OCF RA-compliant environment set.
> > +END
> > +}
> > +
> > +NodeUtilization_start() {
> > + if ! touch "$OCF_RESKEY_pidfile"; then
> > + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_stop() {
> > + rm -f $OCF_RESKEY_pidfile
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_monitor() {
> > + if [ ! -f $OCF_RESKEY_pidfile ]; then
> > + exit $OCF_NOT_RUNNING
> > + fi
> > +
> > + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_validate() {
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +
> > +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> > +: ${OCF_RESKEY_dynamic:="true"}
> > +: ${OCF_RESKEY_utilization_cpu:="true"}
> > +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> > +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> > +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> > +: ${OCF_RESKEY_utilization_host_memory:="true"}
> > +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> > +
> > +if [ $# -ne 1 ]; then
> > + NodeUtilization_usage
> > + exit $OCF_ERR_ARGS
> > +fi
> > +
> > +case $__OCF_ACTION in
> > +meta-data)meta_data
> > +exit $OCF_SUCCESS
> > +;;
> > +start)NodeUtilization_start
> > +;;
> > +stop)NodeUtilization_stop
> > +;;
> > +monitor)NodeUtilization_monitor
> > +;;
> > +validate-all)NodeUtilization_validate
> > +;;
> > +usage|help)NodeUtilization_usage
> > +exit $OCF_SUCCESS
> > +;;
> > +*)NodeUtilization_usage
> > +exit $OCF_ERR_UNIMPLEMENTED
> > +;;
> > +esac
> > +
> > +exit $?
> > --
> > 1.7.2.5
> >
>
> > From 3f26aa2cf5f9f7da40182008079c6ea7498f96fd Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@novell.com>
> > Date: Sat, 13 Aug 2011 02:25:37 +0800
> > Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifiesutilization of resource automatically.
> >
> > ---
> > heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 67 insertions(+), 0 deletions(-)
> >
> > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> > index 0786944..d9321d9 100755
> > --- a/heartbeat/VirtualDomain
> > +++ b/heartbeat/VirtualDomain
> > @@ -19,9 +19,15 @@
> > # Defaults
> > OCF_RESKEY_force_stop_default=0
> > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> > +OCF_RESKEY_dynamic_utilization_default="true"
> > +OCF_RESKEY_set_utilization_cpu_default="true"
> > +OCF_RESKEY_set_utilization_memory_default="true"
> >
> > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> > +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> > +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> > +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> > #######################################################################
> >
> > ## I'd very much suggest to make this RA use bash,
> > @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > <content type="string" default="" />
> > </parameter>
> >
> > +<parameter name="dynamic_utilization" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, the utilization parameter of resource will be reset if there are
> > +difference between resource parameters and system parameters when agent monitor.
> > +Otherwise, the resource parameters will be set once when agent start.
> > +</longdesc>
> > +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > </parameters>
> >
> > <actions>
> > @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > EOF
> > }
> >
> > +set_utilization() {
> > + local dom_cpu dom_mem
> > + local uti_cpu uti_mem
> > +
> > + read dom_cpu dom_mem <<EOF
> > +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> > +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> > +EOF
> > + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> > + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> > +
> > + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> > + if [ "$dom_cpu" != "$uti_cpu" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> > + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> > + if [ "$dom_mem" != "$uti_mem" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> > + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > # Set options to be passed to virsh:
> > VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
> >
> > @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> > while ! VirtualDomain_Monitor; do
> > sleep 1
> > done
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> > + set_utilization
> > + fi
> > +
> > return $OCF_SUCCESS
> > }
> >
> > @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> > fi
> > done
> > fi
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> > + if ocf_is_probe; then
> > + set_utilization
> > + fi
> > + fi
> > +
> > return ${rc}
> > }
> >
> > --
> > 1.7.2.5
> >
>
>
> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical

> From e39948043d94c30557851d2b759468da3935d072 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.de>
> Date: Fri, 28 Oct 2011 21:53:33 +0800
> Subject: [PATCH] Low: Build: New agent NodeUtilization which is detecting os information and putting them into CIB by crm_attribute
>
> ---
> extra/resources/Makefile.am | 1 +
> extra/resources/NodeUtilization | 228 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 229 insertions(+), 0 deletions(-)
> create mode 100644 extra/resources/NodeUtilization
>
> diff --git a/extra/resources/Makefile.am b/extra/resources/Makefile.am
> index bc35401..210e9ed 100644
> --- a/extra/resources/Makefile.am
> +++ b/extra/resources/Makefile.am
> @@ -27,6 +27,7 @@ ocf_SCRIPTS = ClusterMon \
> Dummy\
> HealthCPU\
> HealthSMART\
> +NodeUtilization\
> o2cb\
> ping\
> pingd\
> diff --git a/extra/resources/NodeUtilization b/extra/resources/NodeUtilization
> new file mode 100644
> index 0000000..483053a
> --- /dev/null
> +++ b/extra/resources/NodeUtilization
> @@ -0,0 +1,228 @@
> +#!/bin/sh
> +#
> +#
> +#NodeUtilization OCF Resource Agent
> +#
> +# Copyright (c) 2011 SUSE LINUX, John Shi
> +# All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of version 2 of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> +#
> +# Further, this software is distributed without any warranty that it is
> +# free of the rightful claim of any third person regarding infringement
> +# or the like. Any license provided herein, whether implied or
> +# otherwise, applies only to this software file. Patent licenses, if
> +# any, provided herein do not apply to combinations of this program with
> +# other software, or any other product whatsoever.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> +#
> +#######################################################################
> +# Initialization:
> +
> +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
> +
> +#######################################################################
> +
> +meta_data() {
> +cat <<END
> +<?xml version="1.0"?>
> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> +<resource-agent name="NodeUtilization">
> +<version>1.0</version>
> +
> +<longdesc lang="en">
> +This is an NodeUtilization Resource Agent.
> +This agent detects system parameters and put them into CIB by crm_attribute,
> +and it runs on every node as clone resource.
> +</longdesc>
> +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> +
> +<parameters>
> +<parameter name="dynamic" unique="0" required="0">
> +<longdesc lang="en">
> +If set, some of the HA parameters will be reset if there are
> +difference between HA parameters and system parameters when HA monitor.
> +Otherwise, the HA parameters will be set once when the resource instance starts.
> +</longdesc>
> +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> +<content type="integer" default="1" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> +<content type="integer" default="512" />
> +</parameter>
> +</parameters>
> +
> +<actions>
> +<action name="start" timeout="90" />
> +<action name="stop" timeout="100" />
> +<action name="monitor" timeout="20s" interval="60s"/>
> +<action name="meta-data" timeout="5" />
> +<action name="validate-all" timeout="30" />
> +</actions>
> +</resource-agent>
> +END
> +}
> +
> +set_utilization() {
> + host_name="$(hostname)"
> +
> + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> +
> + if [ "$sys_cpu" != "$uti_cpu" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> +
> + if [ "$sys_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> +
> + if [ -x /usr/sbin/xm ]; then
> + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> +
> + if [ "$hv_mem" != "$uti_mem" ]; then
> + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> + return 1
> + fi
> + fi
> + fi
> + fi
> +}
> +
> +NodeUtilization_usage() {
> +cat <<END
> +usage: $0 {start|stop|monitor|validate-all|meta-data}
> +
> +Expects to have a fully populated OCF RA-compliant environment set.
> +END
> +}
> +
> +NodeUtilization_start() {
> + if ! touch "$OCF_RESKEY_pidfile"; then
> + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> + exit $OCF_ERR_GENERIC
> + fi
> + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_stop() {
> + rm -f $OCF_RESKEY_pidfile
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_monitor() {
> + if [ ! -f $OCF_RESKEY_pidfile ]; then
> + exit $OCF_NOT_RUNNING
> + fi
> +
> + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> + if ! set_utilization; then
> + exit $OCF_ERR_GENERIC
> + fi
> + fi
> + exit $OCF_SUCCESS
> +}
> +
> +NodeUtilization_validate() {
> + exit $OCF_SUCCESS
> +}
> +
> +
> +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> +: ${OCF_RESKEY_dynamic:="true"}
> +: ${OCF_RESKEY_utilization_cpu:="true"}
> +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> +: ${OCF_RESKEY_utilization_host_memory:="true"}
> +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> +
> +if [ $# -ne 1 ]; then
> + NodeUtilization_usage
> + exit $OCF_ERR_ARGS
> +fi
> +
> +case $__OCF_ACTION in
> +meta-data)meta_data
> +exit $OCF_SUCCESS
> +;;
> +start)NodeUtilization_start
> +;;
> +stop)NodeUtilization_stop
> +;;
> +monitor)NodeUtilization_monitor
> +;;
> +validate-all)NodeUtilization_validate
> +;;
> +usage|help)NodeUtilization_usage
> +exit $OCF_SUCCESS
> +;;
> +*)NodeUtilization_usage
> +exit $OCF_ERR_UNIMPLEMENTED
> +;;
> +esac
> +
> +exit $?
> --
> 1.6.0.2
>

> From 7fffa2d22efb1610a4ca2424b6bc9455f1f5cce8 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.de>
> Date: Fri, 28 Oct 2011 21:56:51 +0800
> Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifies utilization of resource automatically.
>
> ---
> heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> index 0786944..d9321d9 100755
> --- a/heartbeat/VirtualDomain
> +++ b/heartbeat/VirtualDomain
> @@ -19,9 +19,15 @@
> # Defaults
> OCF_RESKEY_force_stop_default=0
> OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> +OCF_RESKEY_dynamic_utilization_default="true"
> +OCF_RESKEY_set_utilization_cpu_default="true"
> +OCF_RESKEY_set_utilization_memory_default="true"
>
> : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> #######################################################################
>
> ## I'd very much suggest to make this RA use bash,
> @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> <content type="string" default="" />
> </parameter>
>
> +<parameter name="dynamic_utilization" unique="0" required="0">
> +<longdesc lang="en">
> +If set, the utilization parameter of resource will be reset if there are
> +difference between resource parameters and system parameters when agent monitor.
> +Otherwise, the resource parameters will be set once when agent start.
> +</longdesc>
> +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> </parameters>
>
> <actions>
> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> EOF
> }
>
> +set_utilization() {
> + local dom_cpu dom_mem
> + local uti_cpu uti_mem
> +
> + read dom_cpu dom_mem <<EOF
> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> +EOF
> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> +
> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> + if [ "$dom_cpu" != "$uti_cpu" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> + fi
> + fi
> + fi
> + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> + if [ "$dom_mem" != "$uti_mem" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> + fi
> + fi
> + fi
> +}
> +
> # Set options to be passed to virsh:
> VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
>
> @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> while ! VirtualDomain_Monitor; do
> sleep 1
> done
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> + set_utilization
> + fi
> +
> return $OCF_SUCCESS
> }
>
> @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> fi
> done
> fi
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> + if ocf_is_probe; then
> + set_utilization
> + fi
> + fi
> +
> return ${rc}
> }
>
> --
> 1.6.4.2
>

> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi John,

On Tue, Nov 01, 2011 at 04:46:04AM -0600, John Shi wrote:
>
> Hi Dejan,
> I think we can close these two issues, if we want to improve, or someone has good idea,
> we can open a new issue.

OK. I'll review again the VirtualDomain part.

Andrew, can you please pick the NodeUtilization which should be
part of pacemaker.

Thanks,

Dejan

> Regards,
> John
>
> >>> Dejan Muhamedagic <dejan@suse.de> 10/28/2011 10:39 下午 >>>
> Hi John,
>
> On Fri, Oct 28, 2011 at 08:21:28AM -0600, John Shi wrote:
> >
> > Hi Dejan,
> > I made the new patch for pacemaker, it contains the new NodeUtilization RA.
> > Yes, this is a resend of the same patches I sent last time, but just separate the NodeUtilization RA to pacemaker.
>
> So, which issues do you still think are open?
>
> Cheers,
>
> Dejan
>
> > Regards,
> > John
> >
> >
> > >>> Dejan Muhamedagic <dejan@suse.de> 8/19/2011 8:18 下午 >>>
> > Hi John,
> >
> > On Thu, Aug 18, 2011 at 12:20:26AM -0600, John Shi wrote:
> > >
> > >
> > >
> > > >>> "John Shi" <jshi@novell.com> 8/13/2011 2:56 上午 >>>
> > >
> > >
> > > >>> Lars Marowsky-Bree <lmb@suse.de> 07/22/11 7:40 ?? >>>
> > > On 2011-07-13T22:56:06, John Shi <jshi@novell.com> wrote:
> > >
> > > >> how can we know that node is ready to run Xen RA or other RA, Xen RA
> > > >> cares about the memory which is "physical_mem - (dom0_min_mem +
> > > >> domU_mem * run_num)" but other RA just care about the physical memory
> > > >> or dom0 memory(Xen kernel).
> > > >>
> > > >> Can we separate the memory of utilization to dom0_mem and domU_mem ?
> > > >
> > > >Indeed, there's a difference between the memory available to the
> > > >hypervisor/domain 0/base OS and that available for running guests; this
> > > >probably should be handled by os_mem and vm_mem.
> > > >
> > > >I think the main use case with virtualized environments is that they run
> > > >"just" VMs, so nobody cares about the memory available in the HVM, but
> > > >you're right, it's good to have a clean separation immediately.
> > > >
> > > >Good catch!
> > >
> > >
> > > Hi,
> > > Xinwei Hu and I improved the 2 resource-agents patches,
> > > 1. Separate the memory of utilization to host_memory and hypervisor_memory.
> > > 2. Add some parameters for cpu/memory reservation.
> > > 3. VirtualDomain RA just cares about hypervisor_memory.
> > >
> > > I know more details we need to discuss, but could we put them into upstream first ?
> >
> > I wasn't involved in the discussion earlier. Can you please
> > reiterate which details are still open?
> >
> > Also, should the new NodeUtilization RA go into the pacemaker tree?
> >
> > Cheers,
> >
> > Dejan
> >
> > P.S. Is this a resend of the same patches you sent on Aug 12?
> >
> > > We can gradually improve these features in future.
> > >
> > > Regards,
> > > John
> >
> > > From 9071409ecd0e0951af74a7823d5d2f712a0f22f3 Mon Sep 17 00:00:00 2001
> > > From: John Shi <jshi@novell.com>
> > > Date: Sat, 13 Aug 2011 02:18:50 +0800
> > > Subject: [PATCH] Build: Add a new agent: NodeUtilization.
> > > This agent detects system parameters and put them into CIB by crm_attribute,
> > > and it runs on every node as clone resource.
> > >
> > > ---
> > > heartbeat/Makefile.am | 1 +
> > > heartbeat/NodeUtilization | 229 +++++++++++++++++++++++++++++++++++++++++++++
> > > 2 files changed, 230 insertions(+), 0 deletions(-)
> > > create mode 100755 heartbeat/NodeUtilization
> > >
> > > diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
> > > index dacf3bd..3a3d221 100644
> > > --- a/heartbeat/Makefile.am
> > > +++ b/heartbeat/Makefile.am
> > > @@ -77,6 +77,7 @@ ocf_SCRIPTS = ClusterMon\
> > > mysql\
> > > mysql-proxy\
> > > nfsserver\
> > > +NodeUtilization\
> > > oracle\
> > > oralsnr\
> > > pingd\
> > > diff --git a/heartbeat/NodeUtilization b/heartbeat/NodeUtilization
> > > new file mode 100755
> > > index 0000000..dca0d9a
> > > --- /dev/null
> > > +++ b/heartbeat/NodeUtilization
> > > @@ -0,0 +1,229 @@
> > > +#!/bin/sh
> > > +#
> > > +#
> > > +#NodeUtilization OCF Resource Agent
> > > +#
> > > +# Copyright (c) 2011 SUSE LINUX, John Shi
> > > +# All Rights Reserved.
> > > +#
> > > +# This program is free software; you can redistribute it and/or modify
> > > +# it under the terms of version 2 of the GNU General Public License as
> > > +# published by the Free Software Foundation.
> > > +#
> > > +# This program is distributed in the hope that it would be useful, but
> > > +# WITHOUT ANY WARRANTY; without even the implied warranty of
> > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > > +#
> > > +# Further, this software is distributed without any warranty that it is
> > > +# free of the rightful claim of any third person regarding infringement
> > > +# or the like. Any license provided herein, whether implied or
> > > +# otherwise, applies only to this software file. Patent licenses, if
> > > +# any, provided herein do not apply to combinations of this program with
> > > +# other software, or any other product whatsoever.
> > > +#
> > > +# You should have received a copy of the GNU General Public License
> > > +# along with this program; if not, write the Free Software Foundation,
> > > +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> > > +#
> > > +#######################################################################
> > > +# Initialization:
> > > +
> > > +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
> > > +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
> > > +
> > > +#######################################################################
> > > +
> > > +meta_data() {
> > > +cat <<END
> > > +<?xml version="1.0"?>
> > > +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> > > +<resource-agent name="NodeUtilization">
> > > +<version>1.0</version>
> > > +
> > > +<longdesc lang="en">
> > > +This is an NodeUtilization Resource Agent.
> > > +This agent detects system parameters and put them into CIB by crm_attribute,
> > > +and it runs on every node as clone resource.
> > > +</longdesc>
> > > +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> > > +
> > > +<parameters>
> > > +<parameter name="dynamic" unique="0" required="0">
> > > +<longdesc lang="en">
> > > +If set, some of the HA parameters will be reset if there are
> > > +difference between HA parameters and system parameters when HA monitor.
> > > +Otherwise, the HA parameters will be set once when the resource instance starts.
> > > +</longdesc>
> > > +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_cpu" unique="0" required="0">
> > > +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> > > +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> > > +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> > > +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> > > +<content type="integer" default="1" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_host_memory" unique="0" required="0">
> > > +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> > > +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> > > +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> > > +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> > > +<content type="integer" default="512" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_hv_memory" unique="0" required="0">
> > > +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> > > +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> > > +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> > > +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> > > +<content type="integer" default="512" />
> > > +</parameter>
> > > +</parameters>
> > > +
> > > +<actions>
> > > +<action name="start" timeout="90" />
> > > +<action name="stop" timeout="100" />
> > > +<action name="monitor" timeout="20s" interval="60s"/>
> > > +<action name="meta-data" timeout="5" />
> > > +<action name="validate-all" timeout="30" />
> > > +</actions>
> > > +</resource-agent>
> > > +END
> > > +}
> > > +
> > > +set_utilization() {
> > > + host_name="$(hostname)"
> > > +
> > > + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> > > + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> > > + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> > > +
> > > + if [ "$sys_cpu" != "$uti_cpu" ]; then
> > > + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> > > + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> > > + return 1
> > > + fi
> > > + fi
> > > + fi
> > > +
> > > + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> > > + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> > > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> > > +
> > > + if [ "$sys_mem" != "$uti_mem" ]; then
> > > + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> > > + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> > > + return 1
> > > + fi
> > > + fi
> > > + fi
> > > +
> > > + if [ -x /usr/sbin/xm ]; then
> > > + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> > > + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> > > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> > > +
> > > + if [ "$hv_mem" != "$uti_mem" ]; then
> > > + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> > > + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> > > + return 1
> > > + fi
> > > + fi
> > > + fi
> > > + fi
> > > +}
> > > +
> > > +NodeUtilization_usage() {
> > > +cat <<END
> > > +usage: $0 {start|stop|monitor|validate-all|meta-data}
> > > +
> > > +Expects to have a fully populated OCF RA-compliant environment set.
> > > +END
> > > +}
> > > +
> > > +NodeUtilization_start() {
> > > + if ! touch "$OCF_RESKEY_pidfile"; then
> > > + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> > > + exit $OCF_ERR_GENERIC
> > > + fi
> > > + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> > > + if ! set_utilization; then
> > > + exit $OCF_ERR_GENERIC
> > > + fi
> > > + fi
> > > + exit $OCF_SUCCESS
> > > +}
> > > +
> > > +NodeUtilization_stop() {
> > > + rm -f $OCF_RESKEY_pidfile
> > > + exit $OCF_SUCCESS
> > > +}
> > > +
> > > +NodeUtilization_monitor() {
> > > + if [ ! -f $OCF_RESKEY_pidfile ]; then
> > > + exit $OCF_NOT_RUNNING
> > > + fi
> > > +
> > > + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> > > + if ! set_utilization; then
> > > + exit $OCF_ERR_GENERIC
> > > + fi
> > > + fi
> > > + exit $OCF_SUCCESS
> > > +}
> > > +
> > > +NodeUtilization_validate() {
> > > + exit $OCF_SUCCESS
> > > +}
> > > +
> > > +
> > > +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> > > +: ${OCF_RESKEY_dynamic:="true"}
> > > +: ${OCF_RESKEY_utilization_cpu:="true"}
> > > +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> > > +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> > > +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> > > +: ${OCF_RESKEY_utilization_host_memory:="true"}
> > > +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> > > +
> > > +if [ $# -ne 1 ]; then
> > > + NodeUtilization_usage
> > > + exit $OCF_ERR_ARGS
> > > +fi
> > > +
> > > +case $__OCF_ACTION in
> > > +meta-data)meta_data
> > > +exit $OCF_SUCCESS
> > > +;;
> > > +start)NodeUtilization_start
> > > +;;
> > > +stop)NodeUtilization_stop
> > > +;;
> > > +monitor)NodeUtilization_monitor
> > > +;;
> > > +validate-all)NodeUtilization_validate
> > > +;;
> > > +usage|help)NodeUtilization_usage
> > > +exit $OCF_SUCCESS
> > > +;;
> > > +*)NodeUtilization_usage
> > > +exit $OCF_ERR_UNIMPLEMENTED
> > > +;;
> > > +esac
> > > +
> > > +exit $?
> > > --
> > > 1.7.2.5
> > >
> >
> > > From 3f26aa2cf5f9f7da40182008079c6ea7498f96fd Mon Sep 17 00:00:00 2001
> > > From: John Shi <jshi@novell.com>
> > > Date: Sat, 13 Aug 2011 02:25:37 +0800
> > > Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifiesutilization of resource automatically.
> > >
> > > ---
> > > heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> > > 1 files changed, 67 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> > > index 0786944..d9321d9 100755
> > > --- a/heartbeat/VirtualDomain
> > > +++ b/heartbeat/VirtualDomain
> > > @@ -19,9 +19,15 @@
> > > # Defaults
> > > OCF_RESKEY_force_stop_default=0
> > > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> > > +OCF_RESKEY_dynamic_utilization_default="true"
> > > +OCF_RESKEY_set_utilization_cpu_default="true"
> > > +OCF_RESKEY_set_utilization_memory_default="true"
> > >
> > > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> > > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> > > +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> > > +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> > > +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> > > #######################################################################
> > >
> > > ## I'd very much suggest to make this RA use bash,
> > > @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > > <content type="string" default="" />
> > > </parameter>
> > >
> > > +<parameter name="dynamic_utilization" unique="0" required="0">
> > > +<longdesc lang="en">
> > > +If set, the utilization parameter of resource will be reset if there are
> > > +difference between resource parameters and system parameters when agent monitor.
> > > +Otherwise, the resource parameters will be set once when agent start.
> > > +</longdesc>
> > > +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="set_utilization_cpu" unique="0" required="0">
> > > +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> > > +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > +<parameter name="set_utilization_memory" unique="0" required="0">
> > > +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> > > +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> > > +<content type="boolean" default="true" />
> > > +</parameter>
> > > +
> > > </parameters>
> > >
> > > <actions>
> > > @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > > EOF
> > > }
> > >
> > > +set_utilization() {
> > > + local dom_cpu dom_mem
> > > + local uti_cpu uti_mem
> > > +
> > > + read dom_cpu dom_mem <<EOF
> > > +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> > > +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> > > +EOF
> > > + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> > > + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> > > +
> > > + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> > > + if [ "$dom_cpu" != "$uti_cpu" ]; then
> > > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> > > + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> > > + fi
> > > + fi
> > > + fi
> > > + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> > > + if [ "$dom_mem" != "$uti_mem" ]; then
> > > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> > > + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> > > + fi
> > > + fi
> > > + fi
> > > +}
> > > +
> > > # Set options to be passed to virsh:
> > > VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
> > >
> > > @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> > > while ! VirtualDomain_Monitor; do
> > > sleep 1
> > > done
> > > +
> > > + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> > > + set_utilization
> > > + fi
> > > +
> > > return $OCF_SUCCESS
> > > }
> > >
> > > @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> > > fi
> > > done
> > > fi
> > > +
> > > + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> > > + if ocf_is_probe; then
> > > + set_utilization
> > > + fi
> > > + fi
> > > +
> > > return ${rc}
> > > }
> > >
> > > --
> > > 1.7.2.5
> > >
> >
> >
> > _______________________________________________
> > ha-wg-technical mailing list
> > ha-wg-technical@lists.linux-foundation.org
> > https://lists.linux-foundation.org/mailman/listinfo/ha-wg-technical
>
> > From e39948043d94c30557851d2b759468da3935d072 Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@suse.de>
> > Date: Fri, 28 Oct 2011 21:53:33 +0800
> > Subject: [PATCH] Low: Build: New agent NodeUtilization which is detecting os information and putting them into CIB by crm_attribute
> >
> > ---
> > extra/resources/Makefile.am | 1 +
> > extra/resources/NodeUtilization | 228 +++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 229 insertions(+), 0 deletions(-)
> > create mode 100644 extra/resources/NodeUtilization
> >
> > diff --git a/extra/resources/Makefile.am b/extra/resources/Makefile.am
> > index bc35401..210e9ed 100644
> > --- a/extra/resources/Makefile.am
> > +++ b/extra/resources/Makefile.am
> > @@ -27,6 +27,7 @@ ocf_SCRIPTS = ClusterMon \
> > Dummy\
> > HealthCPU\
> > HealthSMART\
> > +NodeUtilization\
> > o2cb\
> > ping\
> > pingd\
> > diff --git a/extra/resources/NodeUtilization b/extra/resources/NodeUtilization
> > new file mode 100644
> > index 0000000..483053a
> > --- /dev/null
> > +++ b/extra/resources/NodeUtilization
> > @@ -0,0 +1,228 @@
> > +#!/bin/sh
> > +#
> > +#
> > +#NodeUtilization OCF Resource Agent
> > +#
> > +# Copyright (c) 2011 SUSE LINUX, John Shi
> > +# All Rights Reserved.
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of version 2 of the GNU General Public License as
> > +# published by the Free Software Foundation.
> > +#
> > +# This program is distributed in the hope that it would be useful, but
> > +# WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > +#
> > +# Further, this software is distributed without any warranty that it is
> > +# free of the rightful claim of any third person regarding infringement
> > +# or the like. Any license provided herein, whether implied or
> > +# otherwise, applies only to this software file. Patent licenses, if
> > +# any, provided herein do not apply to combinations of this program with
> > +# other software, or any other product whatsoever.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write the Free Software Foundation,
> > +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> > +#
> > +#######################################################################
> > +# Initialization:
> > +
> > +. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
> > +
> > +#######################################################################
> > +
> > +meta_data() {
> > +cat <<END
> > +<?xml version="1.0"?>
> > +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> > +<resource-agent name="NodeUtilization">
> > +<version>1.0</version>
> > +
> > +<longdesc lang="en">
> > +This is an NodeUtilization Resource Agent.
> > +This agent detects system parameters and put them into CIB by crm_attribute,
> > +and it runs on every node as clone resource.
> > +</longdesc>
> > +<shortdesc lang="en">NodeUtilization resource agent</shortdesc>
> > +
> > +<parameters>
> > +<parameter name="dynamic" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, some of the HA parameters will be reset if there are
> > +difference between HA parameters and system parameters when HA monitor.
> > +Otherwise, the HA parameters will be set once when the resource instance starts.
> > +</longdesc>
> > +<shortdesc lang="en">Set HA parameters when start or monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu utilization.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_cpu_reservation" unique="0" required="0">
> > +<longdesc lang="en">CPU reserved for non-HA related usage.</longdesc>
> > +<shortdesc lang="en">CPU reserved for non-HA related usage.</shortdesc>
> > +<content type="integer" default="1" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory utilization of host.</longdesc>
> > +<shortdesc lang="en">Enable setting memory utilization of host.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_host_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for other services inside host, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for other services inside host, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting the memory utilization of hypervisor.</longdesc>
> > +<shortdesc lang="en">Enable setting the memory utilization of hypervisor.</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="utilization_hv_memory_reservation" unique="0" required="0">
> > +<longdesc lang="en">Memory reserved for the hypervisor, in MB.</longdesc>
> > +<shortdesc lang="en">Memory reserved for the hypervisor, in MB.</shortdesc>
> > +<content type="integer" default="512" />
> > +</parameter>
> > +</parameters>
> > +
> > +<actions>
> > +<action name="start" timeout="90" />
> > +<action name="stop" timeout="100" />
> > +<action name="monitor" timeout="20s" interval="60s"/>
> > +<action name="meta-data" timeout="5" />
> > +<action name="validate-all" timeout="30" />
> > +</actions>
> > +</resource-agent>
> > +END
> > +}
> > +
> > +set_utilization() {
> > + host_name="$(hostname)"
> > +
> > + if [ "$OCF_RESKEY_utilization_cpu" = "true" -o "$OCF_RESKEY_utilization_cpu" = "1" ]; then
> > + sys_cpu=$(( $(grep -c processor /proc/cpuinfo) - $OCF_RESKEY_utilization_cpu_reservation ))
> > + uti_cpu=$(crm_attribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)
> > +
> > + if [ "$sys_cpu" != "$uti_cpu" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then
> > + ocf_log err "Failed to set cpu of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ "$OCF_RESKEY_utilization_host_memory" = "true" -o "$OCF_RESKEY_utilization_host_memory" = "1" ]; then
> > + sys_mem=$(( $(awk '/MemTotal/{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_host_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n host_memory 2>/dev/null)
> > +
> > + if [ "$sys_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n host_memory -v $sys_mem; then
> > + ocf_log err "Failed to set host_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > +
> > + if [ -x /usr/sbin/xm ]; then
> > + if [ "$OCF_RESKEY_utilization_hv_memory" = "true" -o "$OCF_RESKEY_utilization_hv_memory" = "1" ]; then
> > + hv_mem=$(( $(xm info | awk '/max_free_memory/{printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservation ))
> > + uti_mem=$(crm_attribute -Q -t nodes -U "$host_name" -z -n hv_memory 2>/dev/null)
> > +
> > + if [ "$hv_mem" != "$uti_mem" ]; then
> > + if ! crm_attribute -t nodes -U "$host_name" -z -n hv_memory -v $hv_mem; then
> > + ocf_log err "Failed to set hv_memory of utilization by crm_attribute."
> > + return 1
> > + fi
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > +NodeUtilization_usage() {
> > +cat <<END
> > +usage: $0 {start|stop|monitor|validate-all|meta-data}
> > +
> > +Expects to have a fully populated OCF RA-compliant environment set.
> > +END
> > +}
> > +
> > +NodeUtilization_start() {
> > + if ! touch "$OCF_RESKEY_pidfile"; then
> > + ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}."
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + if [ "$OCF_RESKEY_dynamic" = "false" -o "$OCF_RESKEY_dynamic" = "0" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_stop() {
> > + rm -f $OCF_RESKEY_pidfile
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_monitor() {
> > + if [ ! -f $OCF_RESKEY_pidfile ]; then
> > + exit $OCF_NOT_RUNNING
> > + fi
> > +
> > + if [ "$OCF_RESKEY_dynamic" = "true" -o "$OCF_RESKEY_dynamic" = "1" ]; then
> > + if ! set_utilization; then
> > + exit $OCF_ERR_GENERIC
> > + fi
> > + fi
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +NodeUtilization_validate() {
> > + exit $OCF_SUCCESS
> > +}
> > +
> > +
> > +: ${OCF_RESKEY_pidfile:="$HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}
> > +: ${OCF_RESKEY_dynamic:="true"}
> > +: ${OCF_RESKEY_utilization_cpu:="true"}
> > +: ${OCF_RESKEY_utilization_cpu_reservation="1"}
> > +: ${OCF_RESKEY_utilization_hv_memory:="true"}
> > +: ${OCF_RESKEY_utilization_hv_memory_reservation="512"}
> > +: ${OCF_RESKEY_utilization_host_memory:="true"}
> > +: ${OCF_RESKEY_utilization_host_memory_reservation="512"}
> > +
> > +if [ $# -ne 1 ]; then
> > + NodeUtilization_usage
> > + exit $OCF_ERR_ARGS
> > +fi
> > +
> > +case $__OCF_ACTION in
> > +meta-data)meta_data
> > +exit $OCF_SUCCESS
> > +;;
> > +start)NodeUtilization_start
> > +;;
> > +stop)NodeUtilization_stop
> > +;;
> > +monitor)NodeUtilization_monitor
> > +;;
> > +validate-all)NodeUtilization_validate
> > +;;
> > +usage|help)NodeUtilization_usage
> > +exit $OCF_SUCCESS
> > +;;
> > +*)NodeUtilization_usage
> > +exit $OCF_ERR_UNIMPLEMENTED
> > +;;
> > +esac
> > +
> > +exit $?
> > --
> > 1.6.0.2
> >
>
> > From 7fffa2d22efb1610a4ca2424b6bc9455f1f5cce8 Mon Sep 17 00:00:00 2001
> > From: John Shi <jshi@suse.de>
> > Date: Fri, 28 Oct 2011 21:56:51 +0800
> > Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifies utilization of resource automatically.
> >
> > ---
> > heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 67 insertions(+), 0 deletions(-)
> >
> > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> > index 0786944..d9321d9 100755
> > --- a/heartbeat/VirtualDomain
> > +++ b/heartbeat/VirtualDomain
> > @@ -19,9 +19,15 @@
> > # Defaults
> > OCF_RESKEY_force_stop_default=0
> > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> > +OCF_RESKEY_dynamic_utilization_default="true"
> > +OCF_RESKEY_set_utilization_cpu_default="true"
> > +OCF_RESKEY_set_utilization_memory_default="true"
> >
> > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> > +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> > +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> > +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> > #######################################################################
> >
> > ## I'd very much suggest to make this RA use bash,
> > @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > <content type="string" default="" />
> > </parameter>
> >
> > +<parameter name="dynamic_utilization" unique="0" required="0">
> > +<longdesc lang="en">
> > +If set, the utilization parameter of resource will be reset if there are
> > +difference between resource parameters and system parameters when agent monitor.
> > +Otherwise, the resource parameters will be set once when agent start.
> > +</longdesc>
> > +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_cpu" unique="0" required="0">
> > +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > +<parameter name="set_utilization_memory" unique="0" required="0">
> > +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> > +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> > +<content type="boolean" default="true" />
> > +</parameter>
> > +
> > </parameters>
> >
> > <actions>
> > @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> > EOF
> > }
> >
> > +set_utilization() {
> > + local dom_cpu dom_mem
> > + local uti_cpu uti_mem
> > +
> > + read dom_cpu dom_mem <<EOF
> > +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> > +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> > +EOF
> > + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> > + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> > +
> > + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> > + if [ "$dom_cpu" != "$uti_cpu" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> > + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> > + if [ "$dom_mem" != "$uti_mem" ]; then
> > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> > + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> > + fi
> > + fi
> > + fi
> > +}
> > +
> > # Set options to be passed to virsh:
> > VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
> >
> > @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> > while ! VirtualDomain_Monitor; do
> > sleep 1
> > done
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> > + set_utilization
> > + fi
> > +
> > return $OCF_SUCCESS
> > }
> >
> > @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> > fi
> > done
> > fi
> > +
> > + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> > + if ocf_is_probe; then
> > + set_utilization
> > + fi
> > + fi
> > +
> > return ${rc}
> > }
> >
> > --
> > 1.6.4.2
> >
>
> > _______________________________________________
> > ha-wg-technical mailing list
> > ha-wg-technical@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
>
> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical

> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi John,

On Tue, Nov 01, 2011 at 04:46:04AM -0600, John Shi wrote:
>
> Hi Dejan,
> I think we can close these two issues, if we want to improve, or someone has good idea,
> we can open a new issue.
>
> Regards,
> John

I'll quote here the VirtualDomain part:

> From 7fffa2d22efb1610a4ca2424b6bc9455f1f5cce8 Mon Sep 17 00:00:00 2001
> From: John Shi <jshi@suse.de>
> Date: Fri, 28 Oct 2011 21:56:51 +0800
> Subject: [PATCH] Low: VirtualDomain: Add a functionality that modifies utilization of resource automatically.
>
> ---
> heartbeat/VirtualDomain | 67 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 67 insertions(+), 0 deletions(-)
>
> diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
> index 0786944..d9321d9 100755
> --- a/heartbeat/VirtualDomain
> +++ b/heartbeat/VirtualDomain
> @@ -19,9 +19,15 @@
> # Defaults
> OCF_RESKEY_force_stop_default=0
> OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
> +OCF_RESKEY_dynamic_utilization_default="true"
> +OCF_RESKEY_set_utilization_cpu_default="true"
> +OCF_RESKEY_set_utilization_memory_default="true"
>
> : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}}
> : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
> +: ${OCF_RESKEY_dynamic_utilization=${OCF_RESKEY_dynamic_utilization_default}}
> +: ${OCF_RESKEY_set_utilization_cpu=${OCF_RESKEY_set_utilization_cpu_default}}
> +: ${OCF_RESKEY_set_utilization_memory=${OCF_RESKEY_set_utilization_memory_default}}
> #######################################################################
>
> ## I'd very much suggest to make this RA use bash,
> @@ -117,6 +123,28 @@ Be sure to set the timeout of these operations to accommodate this delay.
> <content type="string" default="" />
> </parameter>
>
> +<parameter name="dynamic_utilization" unique="0" required="0">
> +<longdesc lang="en">
> +If set, the utilization parameter of resource will be reset if there are
> +difference between resource parameters and system parameters when agent monitor.
> +Otherwise, the resource parameters will be set once when agent start.

This doesn't match the code. A probe is not equal start.
Though I guess that you already discussed that, what happens if
on probe prerequisites are not started (e.g. storage)? Shouldn't
this really be in start when the chance that other dependencies
are satisfied.

The description is not precise. "resource parameters will be
set" should probably read "utilization parameters ...". Also,
"will be reset" doesn't explain well what is going to happen.

> +</longdesc>
> +<shortdesc lang="en">Set utilization of resource when agent monitor</shortdesc>

So, "modify utilization on monitor" actually happens if
dynamic_utilization is set to false. Why is setting utilization
on start only "dynamic", but setting it on every monitor isn't?

> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_cpu" unique="0" required="0">
> +<longdesc lang="en">Enable setting cpu of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting cpu of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> +<parameter name="set_utilization_memory" unique="0" required="0">
> +<longdesc lang="en">Enable setting memory of utilization.</longdesc>
> +<shortdesc lang="en">Enable setting memory of utilization</shortdesc>
> +<content type="boolean" default="true" />
> +</parameter>
> +
> </parameters>

These two parameters are useful only when dynamic_utilization is
set to false. You should also mention which particular
attributes are set ("cpu" and "hv_memory"). And to what value.

> <actions>
> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> EOF
> }
>
> +set_utilization() {
> + local dom_cpu dom_mem
> + local uti_cpu uti_mem
> +
> + read dom_cpu dom_mem <<EOF
> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> +EOF
> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> +
> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then

Please use ocf_is_true. Ditto for similar stuff below.

> + if [ "$dom_cpu" != "$uti_cpu" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu; then
> + ocf_log warn "Failed to set cpu of utilization by crm_resource."
> + fi
> + fi
> + fi
> + if [ "$OCF_RESKEY_set_utilization_memory" = "true" -o "$OCF_RESKEY_set_utilization_memory" = "1" ]; then
> + if [ "$dom_mem" != "$uti_mem" ]; then
> + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem; then
> + ocf_log warn "Failed to set hv_memory of utilization by crm_resource."
> + fi
> + fi
> + fi
> +}
> +
> # Set options to be passed to virsh:
> VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
>
> @@ -236,6 +291,11 @@ VirtualDomain_Start() {
> while ! VirtualDomain_Monitor; do
> sleep 1
> done
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "false" -o "$OCF_RESKEY_dynamic_utilization" = "0" ]; then
> + set_utilization
> + fi
> +
> return $OCF_SUCCESS
> }
>
> @@ -404,6 +464,13 @@ VirtualDomain_Monitor() {
> fi
> done
> fi
> +
> + if [ "$OCF_RESKEY_dynamic_utilization" = "true" -o "$OCF_RESKEY_dynamic_utilization" = "1" ]; then
> + if ocf_is_probe; then
> + set_utilization
> + fi
> + fi
> +
> return ${rc}
> }

Cheers,

Dejan
_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
Re: Two git patchs for resource-agents [ In reply to ]
Hi Dejan,

>> +
>> +
>> +If set, the utilization parameter of resource will be reset if there are
>> +difference between resource parameters and system parameters when agent monitor.
>> +Otherwise, the resource parameters will be set once when agent start.
>
>This doesn't match the code. A probe is not equal start.
>Though I guess that you already discussed that, what happens if
>on probe prerequisites are not started (e.g. storage)? Shouldn't
>this really be in start when the chance that other dependencies
>are satisfied.

Ok, I think the probe on start shoule be removed,
probe the values and put them into utilization
only on monitor if dynamic_utilization is set to true,
and dynamic_utilization can be renamed to just like autoset_utilization ?

>
>The description is not precise. "resource parameters will be
>set" should probably read "utilization parameters ...". Also,
>"will be reset" doesn't explain well what is going to happen.

Ok, I'll improve.

>> +
>> +Set utilization of resource when agent monitor
>
>So, "modify utilization on monitor" actually happens if
>dynamic_utilization is set to false. Why is setting utilization
>on start only "dynamic", but setting it on every monitor isn't?

No, that is not match my code, "modify utilization on monitor"
actually happens if dynamic_utilization is set to ture.

>> +
>> +Enable setting cpu of utilization.
>> +Enable setting cpu of utilization
>> +
>> +
>> +
>> +
>> +Enable setting memory of utilization.
>> +Enable setting memory of utilization
>> +
>> +
>> +
>>
>
>These two parameters are useful only when dynamic_utilization is
>set to false. You should also mention which particular
>attributes are set ("cpu" and "hv_memory"). And to what value.

These two parameters are useful only when dynamic_utilization is
set to true and monitor happens if we decide probe&modify only in monitor.

>
>>
>> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
>> EOF
>> }
>>
>> +set_utilization() {
>> + local dom_cpu dom_mem
>> + local uti_cpu uti_mem
>> +
>> + read dom_cpu dom_mem <> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
>> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
>> +EOF
>> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
>> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
>> +
>> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
>
>Please use ocf_is_true. Ditto for similar stuff below.

Thanks, I'll modify.




Regards,
John
Re: Two git patchs for resource-agents [ In reply to ]
Hi John,

On Fri, Nov 11, 2011 at 06:00:21AM -0700, John Shi wrote:
> Hi Dejan,
>
> >> +
> >> +
> >> +If set, the utilization parameter of resource will be reset if there are
> >> +difference between resource parameters and system parameters when agent monitor.
> >> +Otherwise, the resource parameters will be set once when agent start.
> >
> >This doesn't match the code. A probe is not equal start.
> >Though I guess that you already discussed that, what happens if
> >on probe prerequisites are not started (e.g. storage)? Shouldn't
> >this really be in start when the chance that other dependencies
> >are satisfied.
>
> Ok, I think the probe on start shoule be removed,
> probe the values and put them into utilization
> only on monitor if dynamic_utilization is set to true,
> and dynamic_utilization can be renamed to just like autoset_utilization ?

Yes, it sounds better to me.

> >The description is not precise. "resource parameters will be
> >set" should probably read "utilization parameters ...". Also,
> >"will be reset" doesn't explain well what is going to happen.
>
> Ok, I'll improve.
>
> >> +
> >> +Set utilization of resource when agent monitor
> >
> >So, "modify utilization on monitor" actually happens if
> >dynamic_utilization is set to false. Why is setting utilization
> >on start only "dynamic", but setting it on every monitor isn't?
>
> No, that is not match my code, "modify utilization on monitor"
> actually happens if dynamic_utilization is set to ture.

OK, perhaps I misread the code then. I'll wait for an update to
check again :)

> >> +
> >> +Enable setting cpu of utilization.
> >> +Enable setting cpu of utilization
> >> +
> >> +
> >> +
> >> +
> >> +Enable setting memory of utilization.
> >> +Enable setting memory of utilization
> >> +
> >> +
> >> +
> >>
> >
> >These two parameters are useful only when dynamic_utilization is
> >set to false. You should also mention which particular
> >attributes are set ("cpu" and "hv_memory"). And to what value.
>
> These two parameters are useful only when dynamic_utilization is
> set to true and monitor happens if we decide probe&modify only in monitor.

OK. I'm still a bit confused on what actually triggers the
modifications. Just please state in the description what is going
to happen.

> >
> >>
> >> @@ -133,6 +161,33 @@ Be sure to set the timeout of these operations to accommodate this delay.
> >> EOF
> >> }
> >>
> >> +set_utilization() {
> >> + local dom_cpu dom_mem
> >> + local uti_cpu uti_mem
> >> +
> >> + read dom_cpu dom_mem <> +$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} |
> >> +awk '/CPU\(s\)/{cpu=$2} /Max memory/{mem=$3} END{printf("%d %d\n", cpu, mem/1024)}')
> >> +EOF
> >> + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null)
> >> + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null)
> >> +
> >> + if [ "$OCF_RESKEY_set_utilization_cpu" = "true" -o "$OCF_RESKEY_set_utilization_cpu" = "1" ]; then
> >
> >Please use ocf_is_true. Ditto for similar stuff below.
>
> Thanks, I'll modify.

Cheers,

Dejan

>
>
> Regards,
> John
>

> _______________________________________________
> ha-wg-technical mailing list
> ha-wg-technical@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical

_______________________________________________
ha-wg-technical mailing list
ha-wg-technical@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical