
dejan at suse
Nov 24, 2011, 2:37 AM
Post #4 of 4
(653 views)
Permalink
|
|
Re: 答复: Re: Two git patchs for resource-agents
[In reply to]
|
|
Hi John, On Thu, Nov 24, 2011 at 12:52:51AM -0700, John Shi wrote: > > Hi Dejan, > > I removed the condition only on probe, > update_utilization is invoked when every monitor, > if the domain is not available when do update_utilization first time, then do noting, > just wait next time or next next time, the domain will ultimately be available. Applied and pushed. Many thanks for the contribution! Cheers, Dejan > > Regards, > John > > >>> Dejan Muhamedagic <dejan [at] suse> 11/23/2011 11:58 下午 >>> > Hi John, > > On Wed, Nov 23, 2011 at 04:28:31AM -0700, John Shi wrote: > > > > Hi Dejan, > > > > I think this feature is gradually changing simple throught we discussed many thimes, > > we just add 2 boolean parmeters in meta-data: autoset_utilization_cpu & autoset_utilization_hv_memory, > > for example by autoset_utilization_cpu, if it's true, the agent will detect the number of cpu cores from OS, > > and put it into the cpu utilization of the resource when the monitor is executed. > > But only on probes. Was that your intention? Again, if the domain > is not available on probe this won't work. > > I'm also attaching a slightly refactored patch, which should aid > in maintenance, in particular if in future we add more > attributes. > > Cheers, > > Dejan > > > Regards, > > John > > > From 6931713ceac046e479172f5ad1a8b704cc0ac26e Mon Sep 17 00:00:00 2001 > > From: John Shi <jshi [at] suse> > > Date: Wed, 23 Nov 2011 19:02:43 +0800 > > Subject: [PATCH] Medium: VirtualDomain: Add a functionality that modifies utilization of resource automatically. > > > > --- > > heartbeat/VirtualDomain | 48 +++++++++++++++++++++++++++++++++++++++++++++++ > > 1 files changed, 48 insertions(+), 0 deletions(-) > > > > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain > > index 0786944..bba0d54 100755 > > --- a/heartbeat/VirtualDomain > > +++ b/heartbeat/VirtualDomain > > @@ -19,9 +19,13 @@ > > # Defaults > > OCF_RESKEY_force_stop_default=0 > > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)" > > +OCF_RESKEY_autoset_utilization_cpu_default="true" > > +OCF_RESKEY_autoset_utilization_hv_memory_default="true" > > > > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}} > > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}} > > +: ${OCF_RESKEY_autoset_utilization_cpu=${OCF_RESKEY_autoset_utilization_cpu_default}} > > +: ${OCF_RESKEY_autoset_utilization_hv_memory=${OCF_RESKEY_autoset_utilization_hv_memory_default}} > > ####################################################################### > > > > ## I'd very much suggest to make this RA use bash, > > @@ -117,6 +121,24 @@ Be sure to set the timeout of these operations to accommodate this delay. > > <content type="string" default="" /> > > </parameter> > > > > +<parameter name="autoset_utilization_cpu" unique="0" required="0"> > > +<longdesc lang="en"> > > +If set true, the agent will detect the number of cpu cores from OS, and put it > > +into the cpu utilization of the resource when the monitor is executed. > > +</longdesc> > > +<shortdesc lang="en">Enable auto setting the cpu utilization of the resource</shortdesc> > > +<content type="boolean" default="true" /> > > +</parameter> > > + > > +<parameter name="autoset_utilization_hv_memory" unique="0" required="0"> > > +<longdesc lang="en"> > > +If set true, the agent will detect the number of *Max memory* from virsh, and put it > > +into the hv_memory utilization of the resource when the monitor is executed. > > +</longdesc> > > +<shortdesc lang="en">Enable auto setting the hv_memory utilization of the resource</shortdesc> > > +<content type="boolean" default="true" /> > > +</parameter> > > + > > </parameters> > > > > <actions> > > @@ -382,6 +404,9 @@ VirtualDomain_Migrate_From() { > > } > > > > VirtualDomain_Monitor() { > > + local dom_cpu dom_mem > > + local uti_cpu uti_mem > > + > > # First, check the domain status. If that returns anything other > > # than $OCF_SUCCESS, something is definitely wrong. > > VirtualDomain_Status > > @@ -404,6 +429,29 @@ VirtualDomain_Monitor() { > > fi > > done > > fi > > + > > + if ocf_is_probe; then > > + if ocf_is_true "$OCF_RESKEY_autoset_utilization_cpu"; then > > + dom_cpu=$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} | awk '/CPU\(s\)/{print $2}') > > + uti_cpu=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g cpu 2>/dev/null) > > + if [ "$dom_cpu" != "$uti_cpu" ]; then > > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p cpu -v $dom_cpu >/dev/null 2>&1; then > > + ocf_log warn "Failed to set cpu of utilization by crm_resource." > > + fi > > + fi > > + fi > > + > > + if ocf_is_true "$OCF_RESKEY_autoset_utilization_hv_memory"; then > > + dom_mem=$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} | awk '/Max memory/{print $3/1024)}') > > + uti_mem=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g hv_memory 2>/dev/null) > > + if [ "$dom_mem" != "$uti_mem" ]; then > > + if ! crm_resource -r $OCF_RESOURCE_INSTANCE -z -p hv_memory -v $dom_mem >/dev/null 2>&1; then > > + ocf_log warn "Failed to set hv_memory of utilization by crm_resource." > > + fi > > + fi > > + fi > > + fi > > + > > return ${rc} > > } > > > > -- > > 1.6.4.2 > > > > > _______________________________________________ > > ha-wg-technical mailing list > > ha-wg-technical [at] lists > > https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical > > From e97e400d727c359d98cccd4cbd4e8fd6b382fb95 Mon Sep 17 00:00:00 2001 > From: John Shi <jshi [at] suse> > Date: Thu, 24 Nov 2011 15:49:37 +0800 > Subject: [PATCH] Medium: VirtualDomain: add a functionality that modifies utilization of resource automatically > > --- > heartbeat/VirtualDomain | 49 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 49 insertions(+), 0 deletions(-) > > diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain > index 0786944..00916c0 100755 > --- a/heartbeat/VirtualDomain > +++ b/heartbeat/VirtualDomain > @@ -19,9 +19,13 @@ > # Defaults > OCF_RESKEY_force_stop_default=0 > OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)" > +OCF_RESKEY_autoset_utilization_cpu_default="true" > +OCF_RESKEY_autoset_utilization_hv_memory_default="true" > > : ${OCF_RESKEY_force_stop=${OCF_RESKEY_force_stop_default}} > : ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}} > +: ${OCF_RESKEY_autoset_utilization_cpu=${OCF_RESKEY_autoset_utilization_cpu_default}} > +: ${OCF_RESKEY_autoset_utilization_hv_memory=${OCF_RESKEY_autoset_utilization_hv_memory_default}} > ####################################################################### > > ## I'd very much suggest to make this RA use bash, > @@ -117,6 +121,24 @@ Be sure to set the timeout of these operations to accommodate this delay. > <content type="string" default="" /> > </parameter> > > +<parameter name="autoset_utilization_cpu" unique="0" required="0"> > +<longdesc lang="en"> > +If set true, the agent will detect the number of domainU's vCPUs from virsh, and put it > +into the cpu utilization of the resource when the monitor is executed. > +</longdesc> > +<shortdesc lang="en">Enable auto setting the cpu utilization of the resource</shortdesc> > +<content type="boolean" default="true" /> > +</parameter> > + > +<parameter name="autoset_utilization_hv_memory" unique="0" required="0"> > +<longdesc lang="en"> > +If set true, the agent will detect the number of *Max memory* from virsh, and put it > +into the hv_memory utilization of the resource when the monitor is executed. > +</longdesc> > +<shortdesc lang="en">Enable auto setting the hv_memory utilization of the resource</shortdesc> > +<content type="boolean" default="true" /> > +</parameter> > + > </parameters> > > <actions> > @@ -133,6 +155,30 @@ Be sure to set the timeout of these operations to accommodate this delay. > EOF > } > > +set_util_attr() { > + local attr=$1 val=$2 > + local cval outp > + > + cval=$(crm_resource -Q -r $OCF_RESOURCE_INSTANCE -z -g $attr 2>/dev/null) > + if [ "$cval" != "$val" ]; then > + outp=`crm_resource -r $OCF_RESOURCE_INSTANCE -z -p $attr -v $val 2>&1` || > + ocf_log warn "crm_resource failed to set utilization attribute $attr: $outp" > + fi > +} > + > +update_utilization() { > + local dom_cpu dom_mem > + > + if ocf_is_true "$OCF_RESKEY_autoset_utilization_cpu"; then > + dom_cpu=$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} | awk '/CPU\(s\)/{print $2}') > + test -n "$dom_cpu" && set_util_attr cpu $dom_cpu > + fi > + if ocf_is_true "$OCF_RESKEY_autoset_utilization_hv_memory"; then > + dom_mem=$(LANG=C virsh $VIRSH_OPTIONS dominfo ${DOMAIN_NAME} | awk '/Max memory/{printf("%d", $3/1024)}') > + test -n "$dom_mem" && set_util_attr hv_memory "$dom_mem" > + fi > +} > + > # Set options to be passed to virsh: > VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet" > > @@ -404,6 +450,9 @@ VirtualDomain_Monitor() { > fi > done > fi > + > + update_utilization > + > return ${rc} > } > > -- > 1.6.4.2 > _______________________________________________ ha-wg-technical mailing list ha-wg-technical [at] lists https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
|