ContainerNetNSPath returns the netns path of a container.
(ctx context.Context, c containerd.Container)
| 89 | |
| 90 | // ContainerNetNSPath returns the netns path of a container. |
| 91 | func ContainerNetNSPath(ctx context.Context, c containerd.Container) (string, error) { |
| 92 | task, err := c.Task(ctx, nil) |
| 93 | if err != nil { |
| 94 | return "", err |
| 95 | } |
| 96 | status, err := task.Status(ctx) |
| 97 | if err != nil { |
| 98 | return "", err |
| 99 | } |
| 100 | if status.Status != containerd.Running { |
| 101 | return "", fmt.Errorf("invalid target container: %s, should be running", c.ID()) |
| 102 | } |
| 103 | return fmt.Sprintf("/proc/%d/ns/net", task.Pid()), nil |
| 104 | } |
| 105 | |
| 106 | // UpdateStatusLabel updates the "containerd.io/restart.status" |
| 107 | // label of the container according to the value of restart desired status. |
no outgoing calls
no test coverage detected
searching dependent graphs…