( name string, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, storageDriver docker.StorageDriver, storageDir string, cgroupSubsystems map[string]string, inHostNamespace bool, metadataEnvAllowList []string, metrics container.MetricSet, thinPoolName string, thinPoolWatcher *devicemapper.ThinPoolWatcher, zfsWatcher *zfs.ZfsWatcher, )
| 88 | } |
| 89 | |
| 90 | func newContainerHandler( |
| 91 | name string, |
| 92 | machineInfoFactory info.MachineInfoFactory, |
| 93 | fsInfo fs.FsInfo, |
| 94 | storageDriver docker.StorageDriver, |
| 95 | storageDir string, |
| 96 | cgroupSubsystems map[string]string, |
| 97 | inHostNamespace bool, |
| 98 | metadataEnvAllowList []string, |
| 99 | metrics container.MetricSet, |
| 100 | thinPoolName string, |
| 101 | thinPoolWatcher *devicemapper.ThinPoolWatcher, |
| 102 | zfsWatcher *zfs.ZfsWatcher, |
| 103 | ) (container.ContainerHandler, error) { |
| 104 | // Create the cgroup paths. |
| 105 | cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems, name) |
| 106 | |
| 107 | // Generate the equivalent cgroup manager for this container. |
| 108 | cgroupManager, err := containerlibcontainer.NewCgroupManager(name, cgroupPaths) |
| 109 | if err != nil { |
| 110 | return nil, err |
| 111 | } |
| 112 | |
| 113 | rootFs := "/" |
| 114 | if !inHostNamespace { |
| 115 | rootFs = "/rootfs" |
| 116 | storageDir = path.Join(rootFs, storageDir) |
| 117 | } |
| 118 | |
| 119 | rootless := path.Base(name) == containerBaseName |
| 120 | if rootless { |
| 121 | name, _ = path.Split(name) |
| 122 | } |
| 123 | |
| 124 | id := dockerutil.ContainerNameToId(name) |
| 125 | |
| 126 | // We assume that if Inspect fails then the container is not known to Podman. |
| 127 | ctnr, err := InspectContainer(id) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | |
| 132 | // Obtain the IP address for the container. |
| 133 | var ipAddress string |
| 134 | if ctnr.NetworkSettings != nil && ctnr.HostConfig != nil { |
| 135 | c := ctnr |
| 136 | if ctnr.HostConfig.NetworkMode.IsContainer() { |
| 137 | // If the NetworkMode starts with 'container:' then we need to use the IP address of the container specified. |
| 138 | // This happens in cases such as kubernetes where the containers doesn't have an IP address itself and we need to use the pod's address |
| 139 | containerID := ctnr.HostConfig.NetworkMode.ConnectedContainer() |
| 140 | c, err = InspectContainer(containerID) |
| 141 | if err != nil { |
| 142 | return nil, fmt.Errorf("failed to inspect container %q: %v", containerID, err) |
| 143 | } |
| 144 | } |
| 145 | if nw, ok := c.NetworkSettings.Networks[c.HostConfig.NetworkMode.NetworkName()]; ok { |
| 146 | if nw.IPAddress.IsValid() { |
| 147 | ipAddress = nw.IPAddress.String() |
no test coverage detected
searching dependent graphs…