[lxc-devel] [lxd/master] [WIP] Check rsync version to enable specific version
erickeller on Github
lxc-bot at linuxcontainers.org
Mon May 28 20:31:32 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 392 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180528/93f8e5b5/attachment.bin>
-------------- next part --------------
From 953b11b8182713bd5351f64f7bfe43c6d5f66bf3 Mon Sep 17 00:00:00 2001
From: Eric Keller <keller.eric at gmail.com>
Date: Mon, 28 May 2018 22:20:24 +0200
Subject: [PATCH] Check rsync version to enable specific version
The rsync --ignore-missing-args option is only supported up to 3.1.0
---
lxd-p2c/transfer.go | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/lxd-p2c/transfer.go b/lxd-p2c/transfer.go
index b60fe6e67..e7a3375af 100644
--- a/lxd-p2c/transfer.go
+++ b/lxd-p2c/transfer.go
@@ -4,14 +4,17 @@ import (
"fmt"
"io"
"io/ioutil"
+ "log"
"net"
"os"
"os/exec"
+ "regexp"
"strings"
"github.com/gorilla/websocket"
"github.com/pborman/uuid"
+ "github.com/hashicorp/go-version"
"github.com/lxc/lxd/lxd/migration"
"github.com/lxc/lxd/shared"
)
@@ -72,7 +75,19 @@ func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.Read
"--numeric-ids",
"--partial",
"--sparse",
- "--ignore-missing-args",
+ }
+
+ // extract rsync version
+ result, _ := exec.Command("rsync", "--version").Output()
+ re, _ := regexp.Compile(`.* ([0-9]+[.][0-9]+[.][0-9]+) .*`)
+ extractVersion := re.FindStringSubmatch(string(result))
+ rsyncVers, err := version.NewVersion(extractVersion[1])
+ if err != nil {
+ log.Fatal(err)
+ }
+ constraints, _ := version.NewConstraint(">= 3.1.0")
+ if constraints.Check(rsyncVers) {
+ args = append(args, []string{"--ignore-missing-args"}...)
}
if rsyncArgs != "" {
More information about the lxc-devel
mailing list