Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start podman container with static IP address on macvlan network #10283

Closed
vikas-goel opened this issue May 9, 2021 · 5 comments · Fixed by #10408
Closed

Cannot start podman container with static IP address on macvlan network #10283

vikas-goel opened this issue May 9, 2021 · 5 comments · Fixed by #10408
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@vikas-goel
Copy link
Contributor

vikas-goel commented May 9, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

When macvlan network is created, the type attribute remains set to dhcp. As a result running a container with --ip option fails. After manually replacing dhcp to host-local in the network configuration file, the container can start.

Steps to reproduce the issue:

  1. Create a macvlan network
    podman network create --driver macvlan --subnet 192.168.1.0/24 --gateway 192.168.1.254 -o parent=ens192 ens192

  2. Check the network configuration

# podman network inspect ens192
[
    {
        "cniVersion": "0.4.0",
        "name": "ens192",
        "plugins": [
            {
                "ipam": {
                    "ranges": [
                        [
                            {
                                "gateway": "192.168.1.254",
                                "subnet": "192.168.1.0/24"
                            }
                        ]
                    ],
                    "type": "dhcp"
                },
                "master": "ens192",
                "type": "macvlan"
            }
        ]
    }
]
  1. Run a container with podman run --ip=192.168.1.2 --network=ens192 option

Describe the results you received:

ERRO[0000] Error adding network: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory
ERRO[0000] Error while adding pod to CNI network "ens160": error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory
Error: error configuring network namespace for container fca16ddc9a246288592a910204a57caf1bd835009c9af3327b1c5aafc7051941: error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: no such file or directory
Error: can only create exec sessions on running containers: container state improper

Describe the results you expected:
The macvlan type field should be set to host-local instead of dhcp. The container should start and the IP address should get assigned.

Additional information you deem important (e.g. issue happens only occasionally):
Consistent

Output of podman version:

Version:      3.1.0-dev
API Version:  3.1.0-dev
Go Version:   go1.16.1
Built:        Fri Mar 26 11:32:03 2021
OS/Arch:      linux/amd64

Output of podman info --debug:

# podman info --debug
host:
  arch: amd64
  buildahVersion: 1.19.8
  cgroupManager: systemd
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.26-1.module+el8.4.0+10198+36d1d0e3.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.26, commit: 0a5175681bdd52b99f1f0f442cbba8f8c126a1c9'
  cpus: 8
  distribution:
    distribution: '"rhel"'
    version: "8.4"
  eventLogger: file
  hostname: flex-vm-02.dc2.ros2100.veritas.com
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.18.0-293.el8.x86_64
  linkmode: dynamic
  memFree: 8137920512
  memTotal: 33511845888
  ociRuntime:
    name: runc
    package: runc-1.0.0-70.rc92.module+el8.4.0+10198+36d1d0e3.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.2-dev'
  os: linux
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_NET_RAW,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    selinuxEnabled: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 16910032896
  swapTotal: 16924012544
  uptime: 111h 11m 21.97s (Approximately 4.62 days)
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 5
    paused: 0
    running: 2
    stopped: 3
  graphDriverName: overlay
  graphOptions:
    overlay2.size: 10G
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 3
  runRoot: /run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 3.1.0-dev
  Built: 1616783523
  BuiltTime: Fri Mar 26 11:32:03 2021
  GitCommit: ""
  GoVersion: go1.16.1
  OsArch: linux/amd64
  Version: 3.1.0-dev

Package info (e.g. output of rpm -q podman or apt list podman):

podman-3.1.0-0.13.module_el8.5.0+733+9bb5dffa.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):
Red Hat Enterprise Linux 8.4 Beta
VMware virtual machine

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label May 9, 2021
@vikas-goel
Copy link
Contributor Author

vikas-goel commented May 17, 2021

Should the following line be changed

i := IPAMDHCP{DHCP: "dhcp"}
?

--- a/libpod/network/netconflist.go
+++ b/libpod/network/netconflist.go
@@ -177,7 +177,7 @@ func HasDNSNamePlugin(paths []string) bool {

 // NewMacVLANPlugin creates a macvlanconfig with a given device name
 func NewMacVLANPlugin(device string, gateway net.IP, ipRange *net.IPNet, subnet *net.IPNet, mtu int) (MacVLANConfig, erro
-       i := IPAMDHCP{DHCP: "dhcp"}
+       i := IPAMHostLocalConf{ PluginType: "host-local" }
        if gateway != nil || ipRange != nil || subnet != nil {
                ipam, err := NewIPAMLocalHostRange(subnet, ipRange, gateway)
                if err != nil {

Hi @baude , @Luap99,
Could you check the above suggestion? Is it possible to include the fix in podman-3.2 release?

CC: @mheon, @jwhonce

@vikas-goel
Copy link
Contributor Author

vikas-goel commented May 17, 2021

The default behavior of docker network create --driver macvlan is host-local equivalent.

# docker network create --driver macvlan net1
d36a3dd5d622a8f5ad3457a7085705f1ca254e496ed4c6f0ebf0c1e534f37766
# docker network inspect net1
[
    {
        "Name": "net1",
        "Id": "d36a3dd5d622a8f5ad3457a7085705f1ca254e496ed4c6f0ebf0c1e534f37766",
        "Created": "2021-05-17T15:14:54.218880183-07:00",
        "Scope": "local",
        "Driver": "macvlan",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

Docker has an option --ipam-driver for docker network create command that can be used to alter the type to dhcp.

@Luap99
Copy link
Member

Luap99 commented May 20, 2021

@vikas-goel I opened #10408 to fix this.

Luap99 pushed a commit to Luap99/libpod that referenced this issue May 20, 2021
Creating a macvlan network with the subnet or ipRange option should set
the ipam plugin type to `host-local`. We also have to insert the default
route.

Fixes containers#10283

Signed-off-by: Paul Holzinger <[email protected]>
@vikas-goel
Copy link
Contributor Author

Thank you @Luap99

mheon pushed a commit to mheon/libpod that referenced this issue Jun 3, 2021
Creating a macvlan network with the subnet or ipRange option should set
the ipam plugin type to `host-local`. We also have to insert the default
route.

Fixes containers#10283

Signed-off-by: Paul Holzinger <[email protected]>
@steven-ellis
Copy link

Reference #14352

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Aug 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants