From 7b86628c36a21b822d49ea7dddf4a6da8c2c4105 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 17 Nov 2015 18:08:24 +0500 Subject: [PATCH 1/2] vendor docker-from-scratch-1.9.1-rc1 --- Godeps/Godeps.json | 4 ++-- .../docker-from-scratch/Godeps/Godeps.json | 10 ++++++++ .../rancher/docker-from-scratch/scratch.go | 24 ++++--------------- .../scripts/Dockerfile.build | 2 +- .../docker-from-scratch/scripts/download | 2 +- .../docker-from-scratch/scripts/version | 2 +- .../rancher/docker-from-scratch/util/util.go | 19 +++++++++++++++ .../docker-from-scratch/util/util_test.go | 20 ++++++++++++++++ 8 files changed, 59 insertions(+), 24 deletions(-) mode change 100644 => 100755 Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download create mode 100644 Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util.go create mode 100644 Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util_test.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index ae1a461e..b60ef6b7 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -363,8 +363,8 @@ }, { "ImportPath": "github.com/rancher/docker-from-scratch", - "Comment": "v1.8.2-1-4-ge435c54", - "Rev": "e435c547350adb6b30a64ec1c072f27177b70288" + "Comment": "v1.9.1-rc1", + "Rev": "29561830fcace9eef5dbbfc4008474e5425d34eb" }, { "ImportPath": "github.com/rancher/netconf", diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/Godeps/Godeps.json b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/Godeps/Godeps.json index 0d2ea0a7..d4965ef1 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/Godeps/Godeps.json +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/Godeps/Godeps.json @@ -37,6 +37,16 @@ "ImportPath": "github.com/ryanuber/go-glob", "Rev": "0067a9abd927e50aed5190662702f81231413ae0" }, + { + "ImportPath": "github.com/stretchr/testify/assert", + "Comment": "v1.0-17-g089c718", + "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" + }, + { + "ImportPath": "github.com/stretchr/testify/require", + "Comment": "v1.0-17-g089c718", + "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" + }, { "ImportPath": "github.com/vishvananda/netlink", "Rev": "ea0402b9dbdee2126f48508a441835ddcabc7d1e" diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scratch.go b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scratch.go index 7319dafe..432969ad 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scratch.go +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scratch.go @@ -297,30 +297,16 @@ func setupNetworking(config *Config) error { return nil } -func getValue(index int, args []string) string { - val := args[index] - parts := strings.SplitN(val, "=", 2) - if len(parts) == 1 { - if len(args) > index+1 { - return args[index+1] - } else { - return "" - } - } else { - return parts[2] - } -} - func ParseConfig(config *Config, args ...string) []string { for i, arg := range args { if strings.HasPrefix(arg, "--bip") { - config.BridgeAddress = getValue(i, args) + config.BridgeAddress = util.GetValue(i, args) } else if strings.HasPrefix(arg, "--fixed-cidr") { - config.BridgeAddress = getValue(i, args) + config.BridgeAddress = util.GetValue(i, args) } else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") { - config.BridgeName = getValue(i, args) + config.BridgeName = util.GetValue(i, args) } else if strings.HasPrefix(arg, "--mtu") { - mtu, err := strconv.Atoi(getValue(i, args)) + mtu, err := strconv.Atoi(util.GetValue(i, args)) if err != nil { config.BridgeMtu = mtu } @@ -380,7 +366,7 @@ func touchSockets(args ...string) error { for i, arg := range args { if strings.HasPrefix(arg, "-H") { - val := getValue(i, args) + val := util.GetValue(i, args) if strings.HasPrefix(val, "unix://") { val = val[len("unix://"):] log.Debugf("Creating temp file at %s", val) diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/Dockerfile.build b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/Dockerfile.build index d61c92d5..33d0f52f 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/Dockerfile.build +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/Dockerfile.build @@ -1,4 +1,4 @@ -FROM golang:1.4.2-cross +FROM golang:1.4.3-cross RUN go get github.com/mitchellh/gox RUN go get github.com/tools/godep diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download old mode 100644 new mode 100755 index a686e2b9..6d7d8506 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download @@ -47,7 +47,7 @@ else cp assets/base-files.tar.gz build fi -download ad3618b980105d907aae7bba40ca3ababb7c3d6d https://get.docker.com/builds/Linux/x86_64/docker-1.8.2 +download 9da1e4d4cac3b117bb0cd7da66201fe1fc9953ab https://test.docker.com/builds/Linux/x86_64/docker-1.9.1-rc1 cp assets/docker-* build/docker chmod +x build/docker diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version index 53adb84c..dc30f5bf 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version @@ -1 +1 @@ -1.8.2 +1.9.1-rc1 diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util.go b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util.go new file mode 100644 index 00000000..a64c409b --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util.go @@ -0,0 +1,19 @@ +package util + +import ( + "strings" +) + +func GetValue(index int, args []string) string { + val := args[index] + parts := strings.SplitN(val, "=", 2) + if len(parts) == 1 { + if len(args) > index+1 { + return args[index+1] + } else { + return "" + } + } else { + return parts[1] + } +} diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util_test.go b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util_test.go new file mode 100644 index 00000000..6019361b --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/util/util_test.go @@ -0,0 +1,20 @@ +package util + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNoPanic(t *testing.T) { + assert := require.New(t) + args := []string{"daemon", "--log-opt", "max-size=25m", "--log-opt", "max-file=2", "-s", "overlay", "-G", "docker", "-H", "unix:///var/run/docker.sock", "--userland-proxy=false", "--tlsverify", "--tlscacert=ca.pem", "--tlscert=server-cert.pem", "--tlskey=server-key.pem", "-H=0.0.0.0:2376"} + for i, v := range args { + if v == "-H=0.0.0.0:2376" { + assert.Equal("0.0.0.0:2376", GetValue(i, args)) + } + if v == "-H" { + assert.Equal("unix:///var/run/docker.sock", GetValue(i, args)) + } + } +} From 119b1be0ec391ef15fc92ea6db9a2ad31b97fb3c Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 17 Nov 2015 18:08:37 +0500 Subject: [PATCH 2/2] add docker.tls_args test --- .../assets/test_01/cloud-config.yml | 3 ++- .../rancherostest/test_01_cloud_config.py | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/integration/assets/test_01/cloud-config.yml b/tests/integration/assets/test_01/cloud-config.yml index ed122464..5f4dd988 100644 --- a/tests/integration/assets/test_01/cloud-config.yml +++ b/tests/integration/assets/test_01/cloud-config.yml @@ -10,6 +10,7 @@ rancher: gateway: 10.10.2.2 mtu: 1500 docker: - args: [daemon, --log-opt, max-file=2, --log-opt, max-size=25m, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', -H, 'tcp://0.0.0.0:2375', --userland-proxy=false] + args: [daemon, --log-opt, max-file=2, --log-opt, max-size=25m, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', --userland-proxy=false] + tls_args: [--tlsverify, --tlscacert=/home/rancher/.docker/ca.pem, --tlscert=/home/rancher/.docker/server-cert.pem, --tlskey=/home/rancher/.docker/server-key.pem, '-H=0.0.0.0:2376'] ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt diff --git a/tests/integration/rancherostest/test_01_cloud_config.py b/tests/integration/rancherostest/test_01_cloud_config.py index 22d130da..234b519c 100644 --- a/tests/integration/rancherostest/test_01_cloud_config.py +++ b/tests/integration/rancherostest/test_01_cloud_config.py @@ -53,6 +53,33 @@ def test_docker_args(qemu, cloud_config): assert v.find(expected) != -1 +@pytest.mark.timeout(40) +def test_docker_tls_args(qemu, cloud_config): + assert qemu is not None + u.wait_for_ssh(ssh_command) + + subprocess.check_call( + ssh_command + ['sudo', 'ros', 'tls', 'generate', '-s', '--hostname', '10.10.2.120', '-d', '~/.docker'], + stderr=subprocess.STDOUT, universal_newlines=True) + + subprocess.check_call( + ssh_command + ['sudo', 'ros', 'config', 'set', 'rancher.docker.tls', 'true'], + stderr=subprocess.STDOUT, universal_newlines=True) + + subprocess.check_call( + ssh_command + ['sudo', 'system-docker', 'restart', 'docker'], + stderr=subprocess.STDOUT, universal_newlines=True) + u.wait_for_ssh(ssh_command) + + v = subprocess.check_output( + ssh_command + ['sh', '-c', 'ps -ef | grep docker'], + stderr=subprocess.STDOUT, universal_newlines=True) + + expected = string.join(cloud_config['rancher']['docker']['tls_args']) + + assert v.find(expected) != -1 + + @pytest.mark.timeout(40) def test_rancher_network(qemu, cloud_config): assert qemu is not None