[pve-devel] [PATCH pve-network] fix total removal of zones|vnets|controllers

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Apr 9 08:01:03 CEST 2020


On 3/16/20 9:44 AM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>  PVE/Network/SDN/Controllers.pm | 3 ++-
>  PVE/Network/SDN/Vnets.pm       | 2 +-
>  PVE/Network/SDN/Zones.pm       | 3 ++-
>  3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/Network/SDN/Controllers.pm b/PVE/Network/SDN/Controllers.pm
> index 16c664d..1741c95 100644
> --- a/PVE/Network/SDN/Controllers.pm
> +++ b/PVE/Network/SDN/Controllers.pm
> @@ -33,7 +33,8 @@ sub sdn_controllers_config {
>  
>  sub config {
>      my $config = cfs_read_file("sdn/controllers.cfg.new");
> -    $config = cfs_read_file("sdn/controllers.cfg") if !keys %{$config->{ids}};
> +    $config = cfs_read_file("sdn/controllers.cfg") if !-e "/etc/pve/sdn/controllers.cfg.new";
> +

Why do we prefer always the new one, would it be nicer to always get the
current applied one? And on changes which result in a .new we apply it then
ASAP and rename it (ideally atomic)?

Or what's your current update + .new file rename strategy?

>      return $config;
>  }
>  
> diff --git a/PVE/Network/SDN/Vnets.pm b/PVE/Network/SDN/Vnets.pm
> index 725605b..ca6e1d0 100644
> --- a/PVE/Network/SDN/Vnets.pm
> +++ b/PVE/Network/SDN/Vnets.pm
> @@ -23,7 +23,7 @@ sub sdn_vnets_config {
>  
>  sub config {
>      my $config = cfs_read_file("sdn/vnets.cfg.new");
> -    $config = cfs_read_file("sdn/vnets.cfg") if !keys %{$config->{ids}};
> +    $config = cfs_read_file("sdn/vnets.cfg") if !-e "/etc/pve/sdn/vnets.cfg.new";

If we still want to do this then I'd rather like:

my $config;
if (-e "/etc/pve/sdn/vnets.cfg.new") {
    # always prefer new for <reason>
    $config = cfs_read_file("sdn/vnets.cfg.new");
} else {
    $config = cfs_read_file("sdn/vnets.cfg");
}

>      return $config;
>  }
>  
> diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
> index 17ef507..ae31fea 100644
> --- a/PVE/Network/SDN/Zones.pm
> +++ b/PVE/Network/SDN/Zones.pm
> @@ -39,7 +39,8 @@ sub sdn_zones_config {
>  
>  sub config {
>      my $config = cfs_read_file("sdn/zones.cfg.new");
> -    $config = cfs_read_file("sdn/zones.cfg") if !keys %{$config->{ids}};
> +    $config = cfs_read_file("sdn/zones.cfg") if !-e "/etc/pve/sdn/zones.cfg.new";
> +
>      return $config;
>  }
>  
> 





More information about the pve-devel mailing list