[pve-devel] [Patch V4 2/6] Add config parameter 'source'.

Wolfgang Bumiller w.bumiller at proxmox.com
Wed May 9 12:08:31 CEST 2018


Series seems mostly fine now, two things I missed in my last review, one
in this patch:

On Tue, May 08, 2018 at 03:33:40PM +0200, Wolfgang Link wrote:
> This parameter is useful for restoring the replication status.
> It is also corrected if it is missing or wrong.
> ---
>  PVE/ReplicationConfig.pm | 6 ++++++
>  PVE/ReplicationState.pm  | 5 +++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
> index 51cfe81..b6cd514 100644
> --- a/PVE/ReplicationConfig.pm
> +++ b/PVE/ReplicationConfig.pm
> @@ -79,6 +79,11 @@ my $defaultData = {
>  	    default => '*/15',
>  	    optional => 1,
>  	},
> +	source => {
> +	    description => "Source of the replication.",
> +	    type => 'string', format => 'pve-node',
> +	    optional => 1,
> +	},
>      },
>  };
>  
> @@ -278,6 +283,7 @@ sub options {
>  	rate => { optional => 1 },
>  	schedule => { optional => 1 },
>  	remove_job => { optional => 1 },
> +	source => { optional => 1 },
>      };
>  }
>  
> diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
> index 567535a..0851195 100644
> --- a/PVE/ReplicationState.pm
> +++ b/PVE/ReplicationState.pm
> @@ -285,6 +285,11 @@ sub job_status {
>  
>  	$jobcfg->{next_sync} = $next_sync;
>  
> +	if (!defined($jobcfg->{source}) || $jobcfg->{source} ne $local_node) {
> +	    $jobcfg->{source} = $cfg->{ids}->{$jobid}->{source} = $local_node;
> +	    PVE::ReplicationConfig::write($cfg);

Since we're now potentially modifying the config the whole loop around
this needs to use a lock, otherwise this write above can overwrite
changes happening from others.

> +	}
> +
>  	$jobs->{$jobid} = $jobcfg;
>      }
>  
> -- 
> 2.11.0




More information about the pve-devel mailing list