Skip to content

Commit

Permalink
Get the Docker Engine to build clean on Solaris
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Krishnan <[email protected]>
  • Loading branch information
amitkris committed May 23, 2016
1 parent 91bc4cc commit 86d8758
Show file tree
Hide file tree
Showing 60 changed files with 1,380 additions and 43 deletions.
74 changes: 74 additions & 0 deletions cmd/dockerd/daemon_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// +build solaris

package main

import (
"fmt"
"net"
"os"
"path/filepath"
"syscall"

"github.com/docker/docker/libcontainerd"
"github.com/docker/docker/pkg/system"
)

const defaultDaemonConfigFile = ""

// currentUserIsOwner checks whether the current user is the owner of the given
// file.
func currentUserIsOwner(f string) bool {
if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil {
if int(fileInfo.UID()) == os.Getuid() {
return true
}
}
return false
}

// setDefaultUmask sets the umask to 0022 to avoid problems
// caused by custom umask
func setDefaultUmask() error {
desiredUmask := 0022
syscall.Umask(desiredUmask)
if umask := syscall.Umask(desiredUmask); umask != desiredUmask {
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask)
}

return nil
}

func getDaemonConfDir() string {
return "/etc/docker"
}

// setupConfigReloadTrap configures the USR2 signal to reload the configuration.
func (cli *DaemonCli) setupConfigReloadTrap() {
}

// notifySystem sends a message to the host when the server is ready to be used
func notifySystem() {
}

func (cli *DaemonCli) getPlatformRemoteOptions() []libcontainerd.RemoteOption {
opts := []libcontainerd.RemoteOption{}
return opts
}

// getLibcontainerdRoot gets the root directory for libcontainerd/containerd to
// store their state.
func (cli *DaemonCli) getLibcontainerdRoot() string {
return filepath.Join(cli.Config.ExecRoot, "libcontainerd")
}

func allocateDaemonPort(addr string) error {
return nil
}

// notifyShutdown is called after the daemon shuts down but before the process exits.
func notifyShutdown(err error) {
}

func wrapListeners(proto string, ls []net.Listener) []net.Listener {
return ls
}
2 changes: 1 addition & 1 deletion cmd/dockerd/daemon_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !windows
// +build !windows,!solaris

package main

Expand Down
95 changes: 95 additions & 0 deletions container/container_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// +build solaris

package container

import (
"os"
"path/filepath"

"github.com/docker/docker/volume"
"github.com/docker/engine-api/types/container"
)

// Container holds fields specific to the Solaris implementation. See
// CommonContainer for standard fields common to all containers.
type Container struct {
CommonContainer

// fields below here are platform specific.
HostnamePath string
HostsPath string
ResolvConfPath string
}

// ExitStatus provides exit reasons for a container.
type ExitStatus struct {
// The exit code with which the container exited.
ExitCode int
}

// CreateDaemonEnvironment creates a new environment variable slice for this container.
func (container *Container) CreateDaemonEnvironment(linkedEnv []string) []string {
return nil
}

func appendNetworkMounts(container *Container, volumeMounts []volume.MountPoint) ([]volume.MountPoint, error) {
return volumeMounts, nil
}

// TrySetNetworkMount attempts to set the network mounts given a provided destination and
// the path to use for it; return true if the given destination was a network mount file
func (container *Container) TrySetNetworkMount(destination string, path string) bool {
return true
}

// NetworkMounts returns the list of network mounts.
func (container *Container) NetworkMounts() []Mount {
var mount []Mount
return mount
}

// CopyImagePathContent copies files in destination to the volume.
func (container *Container) CopyImagePathContent(v volume.Volume, destination string) error {
return nil
}

// UnmountIpcMounts unmount Ipc related mounts.
func (container *Container) UnmountIpcMounts(unmount func(pth string) error) {
}

// IpcMounts returns the list of Ipc related mounts.
func (container *Container) IpcMounts() []Mount {
return nil
}

// UpdateContainer updates configuration of a container
func (container *Container) UpdateContainer(hostConfig *container.HostConfig) error {
return nil
}

// UnmountVolumes explicitly unmounts volumes from the container.
func (container *Container) UnmountVolumes(forceSyscall bool, volumeEventLog func(name, action string, attributes map[string]string)) error {
return nil
}

// TmpfsMounts returns the list of tmpfs mounts
func (container *Container) TmpfsMounts() []Mount {
var mounts []Mount
return mounts
}

// cleanResourcePath cleans a resource path and prepares to combine with mnt path
func cleanResourcePath(path string) string {
return filepath.Join(string(os.PathSeparator), path)
}

// BuildHostnameFile writes the container's hostname file.
func (container *Container) BuildHostnameFile() error {
return nil
}

// canMountFS determines if the file system for the container
// can be mounted locally. A no-op on non-Windows platforms
func (container *Container) canMountFS() bool {
return true
}
7 changes: 7 additions & 0 deletions container/state_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package container

// setFromExitStatus is a platform specific helper function to set the state
// based on the ExitStatus structure.
func (s *State) setFromExitStatus(exitStatus *ExitStatus) {
s.ExitCode = exitStatus.ExitCode
}
39 changes: 39 additions & 0 deletions daemon/config_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package daemon

import (
flag "github.com/docker/docker/pkg/mflag"
)

var (
defaultPidFile = "/var/run/docker.pid"
defaultGraph = "/var/lib/docker"
defaultExec = "zones"
)

// Config defines the configuration of a docker daemon.
// These are the configuration settings that you pass
// to the docker daemon when you launch it with say: `docker -d -e lxc`
type Config struct {
CommonConfig

// Fields below here are platform specific.
ExecRoot string `json:"exec-root,omitempty"`
}

// bridgeConfig stores all the bridge driver specific
// configuration.
type bridgeConfig struct {
commonBridgeConfig
}

// InstallFlags adds command-line options to the top-level flag parser for
// the current process.
// Subsequent calls to `flag.Parse` will populate config with values parsed
// from the command-line.
func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) string) {
// First handle install flags which are consistent cross-platform
config.InstallCommonFlags(cmd, usageFn)

// Then platform-specific install flags
config.attachExperimentalFlags(cmd, usageFn)
}
50 changes: 50 additions & 0 deletions daemon/container_operations_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// +build solaris

package daemon

import (
"fmt"

"github.com/docker/docker/container"
networktypes "github.com/docker/engine-api/types/network"
"github.com/docker/libnetwork"
)

func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
return nil, nil
}

// ConnectToNetwork connects a container to a network
func (daemon *Daemon) ConnectToNetwork(container *container.Container, idOrName string, endpointConfig *networktypes.EndpointSettings) error {
return fmt.Errorf("Solaris does not support connecting a running container to a network")
}

// getSize returns real size & virtual size
func (daemon *Daemon) getSize(container *container.Container) (int64, int64) {
return 0, 0
}

// DisconnectFromNetwork disconnects a container from the network
func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, n libnetwork.Network, force bool) error {
return fmt.Errorf("Solaris does not support disconnecting a running container from a network")
}

func (daemon *Daemon) setupIpcDirs(container *container.Container) error {
return nil
}

func (daemon *Daemon) mountVolumes(container *container.Container) error {
return nil
}

func killProcessDirectly(container *container.Container) error {
return nil
}

func detachMounted(path string) error {
return nil
}

func isLinkable(child *container.Container) bool {
return false
}
2 changes: 1 addition & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func NewDaemon(config *Config, registryService *registry.Service, containerdRemo
sysInfo := sysinfo.New(false)
// Check if Devices cgroup is mounted, it is hard requirement for container security,
// on Linux/FreeBSD.
if runtime.GOOS != "windows" && !sysInfo.CgroupDevicesEnabled {
if runtime.GOOS != "windows" && runtime.GOOS != "solaris" && !sysInfo.CgroupDevicesEnabled {
return nil, fmt.Errorf("Devices cgroup isn't mounted")
}

Expand Down
Loading

0 comments on commit 86d8758

Please sign in to comment.