summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_top_linux.go4
-rw-r--r--libpod/events/config.go4
-rw-r--r--libpod/networking_linux.go25
-rw-r--r--libpod/pod_top_linux.go5
4 files changed, 18 insertions, 20 deletions
diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go
index d6d4c6084..161367d75 100644
--- a/libpod/container_top_linux.go
+++ b/libpod/container_top_linux.go
@@ -80,8 +80,8 @@ func (c *Container) Top(descriptors []string) ([]string, error) {
func (c *Container) GetContainerPidInformation(descriptors []string) ([]string, error) {
pid := strconv.Itoa(c.state.PID)
// TODO: psgo returns a [][]string to give users the ability to apply
- // filters on the data. We need to change the API here and the
- // varlink API to return a [][]string if we want to make use of
+ // filters on the data. We need to change the API here
+ // to return a [][]string if we want to make use of
// filtering.
opts := psgo.JoinNamespaceOpts{FillMappings: rootless.IsRootless()}
diff --git a/libpod/events/config.go b/libpod/events/config.go
index af09a65ae..fc1457289 100644
--- a/libpod/events/config.go
+++ b/libpod/events/config.go
@@ -95,10 +95,6 @@ type Type string
type Status string
const (
- // If you add or subtract any values to the following lists, make sure you also update
- // the switch statements below and the enums for EventType or EventStatus in the
- // varlink description file.
-
// Container - event is related to containers
Container Type = "container"
// Image - event is related to images
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 4e7ffaf81..15e470c80 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -1047,21 +1047,25 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
return err
}
+ if err := c.runtime.state.NetworkDisconnect(c, netName); err != nil {
+ return err
+ }
+
+ c.newNetworkEvent(events.NetworkDisconnect, netName)
if c.state.State != define.ContainerStateRunning {
- return errors.Wrapf(define.ErrCtrStateInvalid, "cannot disconnect container %s from networks as it is not running", nameOrID)
+ return nil
}
+
if c.state.NetNS == nil {
return errors.Wrapf(define.ErrNoNetwork, "unable to disconnect %s from %s", nameOrID, netName)
}
+
podConfig := c.runtime.getPodNetwork(c.ID(), c.Name(), c.state.NetNS.Path(), []string{netName}, c.config.PortMappings, nil, nil, c.state.NetInterfaceDescriptions)
if err := c.runtime.netPlugin.TearDownPod(podConfig); err != nil {
return err
}
- if err := c.runtime.state.NetworkDisconnect(c, netName); err != nil {
- return err
- }
- // update network status
+ // update network status if container is not running
networkStatus := c.state.NetworkStatus
// clip out the index of the network
tmpNetworkStatus := make([]*cnitypes.Result, len(networkStatus)-1)
@@ -1071,7 +1075,6 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
}
}
c.state.NetworkStatus = tmpNetworkStatus
- c.newNetworkEvent(events.NetworkDisconnect, netName)
return c.save()
}
@@ -1096,15 +1099,16 @@ func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) e
return err
}
+ if err := c.runtime.state.NetworkConnect(c, netName, aliases); err != nil {
+ return err
+ }
+ c.newNetworkEvent(events.NetworkConnect, netName)
if c.state.State != define.ContainerStateRunning {
- return errors.Wrapf(define.ErrCtrStateInvalid, "cannot connect container %s to networks as it is not running", nameOrID)
+ return nil
}
if c.state.NetNS == nil {
return errors.Wrapf(define.ErrNoNetwork, "unable to connect %s to %s", nameOrID, netName)
}
- if err := c.runtime.state.NetworkConnect(c, netName, aliases); err != nil {
- return err
- }
ctrNetworks, _, err := c.networks()
if err != nil {
@@ -1159,7 +1163,6 @@ func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) e
networkStatus[index] = networkResults[0]
c.state.NetworkStatus = networkStatus
}
- c.newNetworkEvent(events.NetworkConnect, netName)
return c.save()
}
diff --git a/libpod/pod_top_linux.go b/libpod/pod_top_linux.go
index 15ba02389..0e42c62df 100644
--- a/libpod/pod_top_linux.go
+++ b/libpod/pod_top_linux.go
@@ -53,9 +53,8 @@ func (p *Pod) GetPodPidInformation(descriptors []string) ([]string, error) {
}
// TODO: psgo returns a [][]string to give users the ability to apply
- // filters on the data. We need to change the API here and the
- // varlink API to return a [][]string if we want to make use of
- // filtering.
+ // filters on the data. We need to change the API here to return
+ // a [][]string if we want to make use of filtering.
opts := psgo.JoinNamespaceOpts{FillMappings: rootless.IsRootless()}
output, err := psgo.JoinNamespaceAndProcessInfoByPidsWithOptions(pids, psgoDescriptors, &opts)
if err != nil {