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.
Regards,
John
>>> Dejan Muhamedagic <dejan@suse.de> 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@suse.com>
> 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@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/ha-wg-technical