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

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Dec 16 07:34:42 CET 2015



On 12/15/2015 03:48 PM, Wolfgang Bumiller wrote:
> 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.

Good catch, I intended to delay only the next command directly but also 
had the idea
that the helpers could execute more commands at a time, the ideas mixed 
a bit and
thus the buggy code here. As this patch has no use anymore (talked with 
Dietmar)
I won't send new versions, but thanks! :)

>
>>   		} 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