Integrate new structure into docker's native driver
This duplicates some of the Exec code but I think it it worth it because the native driver is more straight forward and does not have the complexity have handling the type issues for now. Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
44636dd863
commit
d6ea76a53e
|
@ -3,11 +3,8 @@
|
||||||
package nsinit
|
package nsinit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/dotcloud/docker/pkg/cgroups"
|
"github.com/dotcloud/docker/pkg/cgroups"
|
||||||
|
@ -160,26 +157,6 @@ func InitializeNetworking(container *libcontainer.Container, nspid int, pipe *Sy
|
||||||
return pipe.SendToChild(context)
|
return pipe.SendToChild(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WritePid writes the namespaced processes pid to pid and it's start time
|
|
||||||
// to the path specified
|
|
||||||
func WritePid(path string, pid int, startTime string) error {
|
|
||||||
err := ioutil.WriteFile(filepath.Join(path, "pid"), []byte(fmt.Sprint(pid)), 0655)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return ioutil.WriteFile(filepath.Join(path, "start"), []byte(startTime), 0655)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeletePid removes the pid and started file from disk when the container's process
|
|
||||||
// dies and the container is cleanly removed
|
|
||||||
func DeletePid(path string) error {
|
|
||||||
err := os.Remove(filepath.Join(path, "pid"))
|
|
||||||
if serr := os.Remove(filepath.Join(path, "start")); err == nil {
|
|
||||||
err = serr
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNamespaceFlags parses the container's Namespaces options to set the correct
|
// GetNamespaceFlags parses the container's Namespaces options to set the correct
|
||||||
// flags on clone, unshare, and setns
|
// flags on clone, unshare, and setns
|
||||||
func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) {
|
func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package nsinit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WritePid writes the namespaced processes pid to pid and it's start time
|
||||||
|
// to the path specified
|
||||||
|
func WritePid(path string, pid int, startTime string) error {
|
||||||
|
err := ioutil.WriteFile(filepath.Join(path, "pid"), []byte(fmt.Sprint(pid)), 0655)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return ioutil.WriteFile(filepath.Join(path, "start"), []byte(startTime), 0655)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePid removes the pid and started file from disk when the container's process
|
||||||
|
// dies and the container is cleanly removed
|
||||||
|
func DeletePid(path string) error {
|
||||||
|
err := os.Remove(filepath.Join(path, "pid"))
|
||||||
|
if serr := os.Remove(filepath.Join(path, "start")); err == nil {
|
||||||
|
err = serr
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
|
@ -3,9 +3,22 @@
|
||||||
package nsinit
|
package nsinit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/dotcloud/docker/pkg/cgroups"
|
||||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Init(container *libcontainer.Container, uncleanRootfs, consolePath string, syncPipe *SyncPipe, args []string) error {
|
||||||
|
return libcontainer.ErrUnsupported
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitializeNetworking(container *libcontainer.Container, nspid int, pipe *SyncPipe) error {
|
||||||
|
return libcontainer.ErrUnsupported
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetupCgroups(container *libcontainer.Container, nspid int) (cgroups.ActiveCgroup, error) {
|
||||||
|
return nil, libcontainer.ErrUnsupported
|
||||||
|
}
|
||||||
|
|
||||||
func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) {
|
func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue