[pve-devel] [Patch V4 6/6] Swap source and target in replication config, if VM was stolen.

Wolfgang Bumiller w.bumiller at proxmox.com
Wed May 9 12:10:28 CEST 2018


And here I also missed something in my last review:

On Tue, May 08, 2018 at 03:33:44PM +0200, Wolfgang Link wrote:
> ---
>  PVE/ReplicationState.pm | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
> index 0851195..60e009b 100644
> --- a/PVE/ReplicationState.pm
> +++ b/PVE/ReplicationState.pm
> @@ -254,8 +254,16 @@ sub job_status {
>  
>  	my $target = $jobcfg->{target};
>  	if (!$jobcfg->{remove_job}) {
> -	    # never sync to local node
> -	    next if $target eq $local_node;
> +	    # check if vm was stolen (swapped source target)
> +	    if ($target eq $local_node) {
> +		my $source = $jobcfg->{source};
> +		if (defined($source) && $source ne $target) {
> +		    $jobcfg = PVE::ReplicationConfig::swap_source_target($jobid);

Since we're potentially rewriting the config further down with the new
'source' property added, it's not enough to just replace $jobcfg, but we
also need to update the $cfg->{ids}->{$jobid} since $cfg is what gets
written out in the case where no 'source' property is defined.

> +		} else {
> +		    # never sync to local node
> +		    next;
> +		}
> +	    }
>  
>  	    next if !$get_disabled && $jobcfg->{disable};
>  	}
> -- 
> 2.11.0




More information about the pve-devel mailing list