[pve-devel] [RFC v2 pve-ha-manager 5/9] TestHardware: add a more deterministic delay possibility

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Dec 15 15:48:06 CET 2015


On Mon, Dec 14, 2015 at 03:29:57PM +0100, Thomas Lamprecht wrote:
> With this patch we can add a command to be executed after the
> current command and some specified delay, e.g. the following
> cmdlist line:
> [ "power nodeX shutdown", "delay 5", "power nodeX on"]
> 
> This works more deterministic as it gets added to the helper
> command list, which gets executed on every loop cycle from the
> node processing loop and thus with a higher frequency,
> whereas time between two comandlist commands can be undefined
> and is mostly bigger. We need this for example to simulate a short
> shutdown - power on cycle.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  src/PVE/HA/Sim/TestHardware.pm | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/HA/Sim/TestHardware.pm b/src/PVE/HA/Sim/TestHardware.pm
> index 5c8a0cd..9bf2936 100644
> --- a/src/PVE/HA/Sim/TestHardware.pm
> +++ b/src/PVE/HA/Sim/TestHardware.pm
> @@ -290,12 +290,19 @@ sub run {
>  		# end sumulation (500 seconds after last command)
>  		return if (($self->{cur_time} - $last_command_time) > 500);
>  	    }
> -
> +	    my $delay_next_commands;
>  	    foreach my $cmd (@$list) {
>  		$last_command_time = $self->{cur_time};
>  
>  		if ($cmd =~ m/^delay\s+(\d+)\s*$/) {
>  		    $next_cmd_at = $self->{cur_time} + $1;
> +		    $delay_next_commands = 1;
> +		} elsif ($delay_next_commands) {
> +		    # after an delay add all following commands, if any, to
> +		    # the helper cmd list, as they need to be executed more
> +		    # deterministic and faster than with the cmdlist possible
> +		    &$add_helper_cmd($self, $next_cmd_at, $cmd);
> +		    $next_cmd_at = $self->{cur_time};

While this goes through @$list it looks like the $delay_next_command
case can be hit several times without incrementing the $next_cmd_at or
$self->{cur_time}, but &$add_helper_cmd() was declared to warn and
discard commands for a timeslot that was already used. See the line:
+ warn "helper cmd at time '$exec_time" already declared";
in patch 3.

Is this an issue? I'm not familiar with the rest of the activities going
on in this part of the code.

>  		} else {
>  		    $self->sim_hardware_cmd($cmd, 'cmdlist');
>  		}
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 



More information about the pve-devel mailing list