[pve-devel] [PATCH cluster v3 4/7] corosync: transform config to allow easier access

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 20 14:24:30 CEST 2017


On 09/20/2017 02:06 PM, Wolfgang Bumiller wrote:
> On Mon, Sep 18, 2017 at 10:32:55AM +0200, Thomas Lamprecht wrote:
>> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
>> ---
>>
>> changes v2 -> v3:
>>   * use map instead of foreach in transform helpers
>>   * rename those helper to conciser names
>>
>>   data/PVE/Corosync.pm | 51 +++++++++++++++++++++++----------------------------
>>   1 file changed, 23 insertions(+), 28 deletions(-)
>>
>> diff --git a/data/PVE/Corosync.pm b/data/PVE/Corosync.pm
>> index eaa5e39..9041d87 100644
>> --- a/data/PVE/Corosync.pm
>> +++ b/data/PVE/Corosync.pm
>> @@ -70,6 +70,15 @@ sub parse_conf {
>>   	$section->{$key} = $value;
>>       }
>>   
>> +    # make working with the config way easier
>> +    my $array_to_hash = sub {
>> +	my ($section_array, $key_id) = @_;
>> +	return { map { $_->{$key_id} => $_ } @$section_array };
>> +    };
>> +    my ($totem, $nodelist) = $conf->{main}->@{"totem", "nodelist"};
>> +    $nodelist->{node} = &$array_to_hash($nodelist->{node}, 'name');
> 
> At this point we should probably copy ring0_addr into name if name is
> not set. We can then also drop the name||ring0_addr cases from patch 3.
> Otherwise this errors out and results in an empty node list in the
> corosync config and a broken cluster if your cluster is old enough ;-)


Yes true, did not noticed it as the commit which ensures that name is set
got into the repo a few days after PVE 4.0 released (12.10.2015) and I nuked
my test cluster from that time a few months ago...
Thanks for noticing, I'll fix it.




More information about the pve-devel mailing list