
dejan at suse
Nov 8, 2011, 9:07 AM
Views: 2230
Permalink
|
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 [at] suse> > 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 [at] lists https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical
|