24689818 Docker cannot remove bridge network 'docker0' from PF table
authorshreya.jain@oracle.com <shreya.jain@oracle.com>
Thu, 27 Oct 2016 14:24:49 -0700
changeset 7173 2a4da482fa74
parent 7172 76f8af48e5e9
child 7174 f9e5b30df91a
24689818 Docker cannot remove bridge network 'docker0' from PF table
components/docker/patches/0001-Solaris-v1.10.3.patch
--- a/components/docker/patches/0001-Solaris-v1.10.3.patch	Thu Oct 27 14:15:11 2016 -0700
+++ b/components/docker/patches/0001-Solaris-v1.10.3.patch	Thu Oct 27 14:24:49 2016 -0700
@@ -1,16 +1,6 @@
-In-house patch which contains a full port of the v1.10.3 Docker
-Engine for Solaris. This is being integrated as the first
-version of Docker on Solaris, targeting release with Solaris 12.
-
-While work is ongoing upstream in the public project, and
-most if not all of that code will be integrated upstream, that
-work will not be done in time to target a Solaris 12 release.
-This version is the first in hopefully many, and this patch
-will be deprecated in future release integrations. 
-
-From 1a691306db9dfd0ddddf351cc203eeb58fc916ff Mon Sep 17 00:00:00 2001
-From: Jesse Butler <[email protected]>
-Date: Mon, 17 Oct 2016 19:20:35 -0700
+From 38fc08be66c3ef8174633da9ad61f70532e79e5d Mon Sep 17 00:00:00 2001
+From: Shreya Jain <[email protected]>
+Date: Thu, 27 Oct 2016 11:23:16 -0700
 Subject: [PATCH] Solaris-v1.10.3
 
 ---
@@ -43,7 +33,7 @@
  daemon/execdriver/driver_solaris.go                |   76 ++
  daemon/execdriver/driver_unix.go                   |    2 +-
  .../execdriver/execdrivers/execdrivers_solaris.go  |   13 +
- daemon/execdriver/zones/driver.go                  |  745 ++++++++++++++
+ daemon/execdriver/zones/driver.go                  |  767 ++++++++++++++
  daemon/execdriver/zones/driver_unsupported.go      |   12 +
  .../execdriver/zones/driver_unsupported_nocgo.go   |   13 +
  daemon/graphdriver/driver_solaris.go               |    8 +
@@ -61,7 +51,7 @@
  daemon/list_unix.go                                |    2 +-
  daemon/network.go                                  |    7 +
  daemon/selinux_unsupported.go                      |    8 +
- daemon/start.go                                    |   65 ++
+ daemon/start.go                                    |   16 +
  daemon/stats_collector_solaris.go                  |  537 ++++++++++
  daemon/stats_collector_unix.go                     |    2 +-
  daemon/stats_solaris.go                            |   84 ++
@@ -207,7 +197,7 @@
  vendor/src/gopkg.in/fsnotify.v1/fsnotify.go        |    2 +-
  volume/local/local_unix.go                         |    2 +-
  volume/store/store_unix.go                         |    2 +-
- 193 files changed, 9163 insertions(+), 1241 deletions(-)
+ 193 files changed, 9136 insertions(+), 1241 deletions(-)
  create mode 100644 Dockerfile.solaris
  create mode 100644 container/container_solaris.go
  create mode 100644 container/state_solaris.go
@@ -3302,10 +3292,10 @@
 +}
 diff --git a/daemon/execdriver/zones/driver.go b/daemon/execdriver/zones/driver.go
 new file mode 100644
-index 0000000..4a65eca
+index 0000000..d23b95b
 --- /dev/null
 +++ b/daemon/execdriver/zones/driver.go
-@@ -0,0 +1,745 @@
+@@ -0,0 +1,767 @@
 +// +build solaris,cgo
 +
 +package zones
@@ -3411,6 +3401,7 @@
 +	DUMMY_PID           = 0
 +	EXEC_PATH           = "/system/volatile"
 +	LX_DOCKER_INIT_PATH = "/usr/lib/brand/lx/lx_docker_init"
++	SVCCFG              = "/usr/sbin/svccfg"
 +)
 +
 +// We don't yet have libcontainer.Factory support, so just whack it together here
@@ -3868,6 +3859,27 @@
 +			logrus.Errorf("failed to delete container %v: %v", c.Name, err)
 +		}
 +	}()
++
++	ProfilesPath := filepath.Join(filepath.Dir(filepath.Dir(c.Rootfs)), "/.svc_bundle")
++	if err = os.Mkdir(ProfilesPath, 0700); err != nil {
++		return execdriver.ExitStatus{ExitCode: -1}, err
++	}
++
++	PathDnsXml := filepath.Join(ProfilesPath, "/dns_client.xml")
++	PathNSSwitchXml := filepath.Join(ProfilesPath, "/ns_switch.xml")
++
++	err = exec.Command(SVCCFG, "extract", "dns/client", ">", PathDnsXml).Run()
++	if err != nil {
++		logrus.Errorf("Error exporting dns/client: %v", err)
++		return execdriver.ExitStatus{ExitCode: -1}, err
++	}
++
++	err = exec.Command(SVCCFG, "extract", "name-service/switch", ">", PathNSSwitchXml).Run()
++	if err != nil {
++		logrus.Errorf("Error exporting name-service/switch: %v", err)
++		return execdriver.ExitStatus{ExitCode: -1}, err
++	}
++
 +	cmd := exec.Command(RUNZ, "run", c.Name, filepath.Dir(filepath.Dir(c.Rootfs)))
 +	cmd.Dir = filepath.Dir(filepath.Dir(c.Rootfs))
 +	cmd.Stdout = pipes.Stdout
@@ -4576,21 +4588,19 @@
 +	return nil, nil
 +}
 diff --git a/daemon/start.go b/daemon/start.go
-index 418dace..9d5e6cb 100644
+index 418dace..50b1cc1 100644
 --- a/daemon/start.go
 +++ b/daemon/start.go
-@@ -1,7 +1,10 @@
+@@ -1,6 +1,8 @@
  package daemon
  
  import (
 +	"errors"
 +	"os"
  	"runtime"
-+	"os/exec"
  
  	"github.com/Sirupsen/logrus"
- 	"github.com/docker/docker/container"
-@@ -10,6 +13,8 @@ import (
+@@ -10,6 +12,8 @@ import (
  	containertypes "github.com/docker/engine-api/types/container"
  )
  
@@ -4599,7 +4609,7 @@
  // ContainerStart starts a container.
  func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.HostConfig) error {
  	container, err := daemon.GetContainer(name)
-@@ -142,6 +147,24 @@ func (daemon *Daemon) containerStart(container *container.Container) (err error)
+@@ -142,6 +146,18 @@ func (daemon *Daemon) containerStart(container *container.Container) (err error)
  	mounts = append(mounts, container.TmpfsMounts()...)
  
  	container.Command.Mounts = mounts
@@ -4615,61 +4625,9 @@
 +		container.Command.ContOS = img.Os
 +	}
 +
-+	if container.Command.ContOS == "solaris" {
-+		if err := daemon.injectHostConfig(container); err != nil {
-+			return err
-+	}
-+
-+	}
  	if err := daemon.waitForStart(container); err != nil {
  		return err
  	}
-@@ -170,3 +193,45 @@ func (daemon *Daemon) Cleanup(container *container.Container) {
- 		logrus.Warnf("%s cleanup: Failed to umount volumes: %v", container.ID, err)
- 	}
- }
-+
-+// injectHostConfig() should be abstracted away.
-+// This patch will only be running Solaris, hence it's harmless.
-+func (daemon *Daemon) injectHostConfig(container *container.Container) error {
-+	pathdnsXml := container.Root + "/dns_client.xml"
-+	pathnsswitchXml := container.Root + "/ns_switch.xml"
-+	repodb := container.BaseFS + "/etc/svc/repository.db"
-+
-+	// We want to ensure we are accessing the SMF repository of the host,
-+	// so we clear SVCCFG_REPOSITORY.
-+	os.Unsetenv("SVCCFG_REPOSITORY")
-+
-+	err := exec.Command(SVCCFG, "extract", "dns/client", ">", pathdnsXml).Run()
-+	if err != nil {
-+		logrus.Errorf("Error exporting dns/client: %v", err)
-+		return err
-+	}
-+
-+	err = exec.Command(SVCCFG, "extract", "name-service/switch", ">", pathnsswitchXml).Run()
-+	if err != nil {
-+		logrus.Errorf("Error exporting name-service/switch: %v", err)
-+		return err
-+	}
-+
-+	os.Setenv("SVCCFG_REPOSITORY", repodb)
-+
-+	err = exec.Command(SVCCFG, "apply", pathdnsXml).Run()
-+	if err != nil {
-+		logrus.Errorf("Error applying dns/client: %v", err)
-+	}
-+
-+	err = exec.Command(SVCCFG, "apply", pathnsswitchXml).Run()
-+	if err != nil {
-+		logrus.Errorf("Error applying name-service/switch: %v", err)
-+	}
-+
-+	os.Remove(pathdnsXml)
-+	os.Remove(pathnsswitchXml)
-+	os.Unsetenv("SVCCFG_REPOSITORY")
-+
-+	return err
-+}
 diff --git a/daemon/stats_collector_solaris.go b/daemon/stats_collector_solaris.go
 new file mode 100644
 index 0000000..4d4b4a0
@@ -9435,7 +9393,7 @@
 +}
 diff --git a/vendor/src/github.com/docker/libnetwork/drivers/solaris/bridge/bridge.go b/vendor/src/github.com/docker/libnetwork/drivers/solaris/bridge/bridge.go
 new file mode 100644
-index 0000000..12c8b69
+index 0000000..344997d
 --- /dev/null
 +++ b/vendor/src/github.com/docker/libnetwork/drivers/solaris/bridge/bridge.go
 @@ -0,0 +1,1076 @@
@@ -9860,7 +9818,7 @@
 +		fmt.Println("dladm delete-etherstub failed")
 +	}
 +	err = exec.Command("/usr/sbin/pfctl", "-a", table_anchor, "-t", tableName, "-T", "delete", gwIP).Run()
-+	if err != nil {
++	if err != nil && logErr {
 +		fmt.Printf("cannot remove bridge network '%s' from PF table\n", bridgeName)
 +	}
 +}