mirror of
https://github.com/clearlinux/rkt.git
synced 2026-09-06 13:51:45 +00:00
networking: podRoot -> rktRoot
rktRoot is misleading as the directory is really the root of a specific pod. Also add a TODO note that this is currently only ever set to cwd (i.e. "."), and hence necessitates relative paths.
This commit is contained in:
@@ -60,7 +60,7 @@ func (e *podEnv) pluginPaths() []string {
|
||||
// try 3rd-party path first
|
||||
return []string{
|
||||
UserNetPluginsPath,
|
||||
filepath.Join(common.Stage1RootfsPath(e.rktRoot), BuiltinNetPluginsPath),
|
||||
filepath.Join(common.Stage1RootfsPath(e.podRoot), BuiltinNetPluginsPath),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -49,13 +49,14 @@ type Networking struct {
|
||||
nets []activeNet
|
||||
}
|
||||
|
||||
// Setup creates a new networking namespace and executes network
|
||||
// plugins to setup private networking. It returns in the new pod
|
||||
// namespace
|
||||
func Setup(rktRoot string, podID types.UUID, fps []ForwardedPort) (*Networking, error) {
|
||||
// Setup creates a new networking namespace and executes network plugins to
|
||||
// setup private networking. It returns in the new pod namespace
|
||||
func Setup(podRoot string, podID types.UUID, fps []ForwardedPort) (*Networking, error) {
|
||||
// TODO(jonboulle): currently podRoot is _always_ ".", and behaviour in other
|
||||
// circumstances is untested. This should be cleaned up.
|
||||
n := Networking{
|
||||
podEnv: podEnv{
|
||||
rktRoot: rktRoot,
|
||||
podRoot: podRoot,
|
||||
podID: podID,
|
||||
},
|
||||
}
|
||||
@@ -101,11 +102,11 @@ func Setup(rktRoot string, podID types.UUID, fps []ForwardedPort) (*Networking,
|
||||
|
||||
// Load creates the Networking object from saved state.
|
||||
// Assumes the current netns is that of the host.
|
||||
func Load(rktRoot string, podID *types.UUID) (*Networking, error) {
|
||||
func Load(podRoot string, podID *types.UUID) (*Networking, error) {
|
||||
// the current directory is pod root
|
||||
pdirfd, err := syscall.Open(rktRoot, syscall.O_RDONLY|syscall.O_DIRECTORY, 0)
|
||||
pdirfd, err := syscall.Open(podRoot, syscall.O_RDONLY|syscall.O_DIRECTORY, 0)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to open pod root directory (%v): %v", rktRoot, err)
|
||||
return nil, fmt.Errorf("Failed to open pod root directory (%v): %v", podRoot, err)
|
||||
}
|
||||
defer syscall.Close(pdirfd)
|
||||
|
||||
@@ -139,7 +140,7 @@ func Load(rktRoot string, podID *types.UUID) (*Networking, error) {
|
||||
|
||||
return &Networking{
|
||||
podEnv: podEnv{
|
||||
rktRoot: rktRoot,
|
||||
podRoot: podRoot,
|
||||
podID: *podID,
|
||||
},
|
||||
hostNS: hostNS,
|
||||
@@ -164,8 +165,7 @@ func (n *Networking) GetDefaultHostIP() net.IP {
|
||||
// Teardown cleans up a produced Networking object.
|
||||
func (n *Networking) Teardown() {
|
||||
// Teardown everything in reverse order of setup.
|
||||
// This should be indempotent -- be tolerant of
|
||||
// missing stuff
|
||||
// This should be idempotent -- be tolerant of missing stuff
|
||||
|
||||
if err := n.enterHostNS(); err != nil {
|
||||
log.Printf("Error switching to host netns: %v", err)
|
||||
@@ -217,7 +217,7 @@ func (e *Networking) Save() error {
|
||||
nis = append(nis, *n.runtime)
|
||||
}
|
||||
|
||||
return netinfo.Save(e.rktRoot, nis)
|
||||
return netinfo.Save(e.podRoot, nis)
|
||||
}
|
||||
|
||||
func newNetNS() (hostNS, childNS *os.File, err error) {
|
||||
|
||||
@@ -45,7 +45,7 @@ const (
|
||||
// describing the environment in which the pod
|
||||
// is running in
|
||||
type podEnv struct {
|
||||
rktRoot string
|
||||
podRoot string
|
||||
podID types.UUID
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (e *podEnv) loadNets() ([]activeNet, error) {
|
||||
}
|
||||
|
||||
if !netExists(nets, "default") {
|
||||
defPath := path.Join(common.Stage1RootfsPath(e.rktRoot), DefaultNetPath)
|
||||
defPath := path.Join(common.Stage1RootfsPath(e.podRoot), DefaultNetPath)
|
||||
n, err := loadNet(defPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -76,11 +76,11 @@ func (e *podEnv) loadNets() ([]activeNet, error) {
|
||||
}
|
||||
|
||||
func (e *podEnv) podNSPath() string {
|
||||
return filepath.Join(e.rktRoot, "netns")
|
||||
return filepath.Join(e.podRoot, "netns")
|
||||
}
|
||||
|
||||
func (e *podEnv) netDir() string {
|
||||
return filepath.Join(e.rktRoot, "net")
|
||||
return filepath.Join(e.podRoot, "net")
|
||||
}
|
||||
|
||||
func (e *podEnv) setupNets(nets []activeNet) error {
|
||||
|
||||
Reference in New Issue
Block a user