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

podman is overwriting user's CNI_ARGS to the CNI plugin #4398

Closed
space88man opened this issue Oct 31, 2019 · 17 comments
Closed

podman is overwriting user's CNI_ARGS to the CNI plugin #4398

space88man opened this issue Oct 31, 2019 · 17 comments
Assignees
Labels
do-not-close 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. stale-issue

Comments

@space88man
Copy link

space88man commented Oct 31, 2019

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

/kind bug

Description

podman seems to be overwriting the user supplied CNI_ARGS so some settings are not transmitted to the CNI plugin.

When dumping the environment of a plugin I see

CNI_ARGS='IgnoreUnknown=1;K8S_POD_NAMESPACE=abcd_3;K8S_POD_NAME=abcd_3;K8S_POD_INFRA_CONTAINER_ID=4c7f1903383a9552973ba2deb5ceb2e8b65ab1e06309c8af948b217724718bc3'

instead of the value provided.

When using a user network (pre existing bridge) , the CNI_ARGS environment variable doesn't assign a static IP address. This affects both host-local and static plugins.

Steps to reproduce the issue:

  1. Create a user network: this is an existing (libvirt) bridge on the host, so omit masq gateway iptables settings
# /etc/cni/net.d/85-network-125.conflist
{
    "cniVersion": "0.4.0",
    "name": "network-125",
    "plugins": [
        {
            "type": "bridge",
            "bridge": "vmbr0",
            "ipam": {
                "type": "host-local",
                "routes": [
                    {
                        "dst": "0.0.0.0/0"
                    }
                ],
                "ranges": [
                    [
                        {
                            "subnet": "192.168.125.0/24"
                        }
                    ]
                ]
            }
        }
    ]
}
  1. Create container with static IP address
[root@amadeus ~]# CNI_ARGS=ip=192.168.125.123 podman run  --rm --network network-125  -it  --dns 192.168.125.1   centos:8
[root@5ddaa9f68d57 /]# ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
3: eth0@if66: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default  link-netnsid 0
    inet 192.168.125.17/24 brd 192.168.125.255 scope global eth0
       valid_lft forever preferred_lft forever

Describe the results you received:
The IP address is randomly assigned by host-local IPAM. CNI_ARGS is not respected by plugin.

Describe the results you expected:
Static IP address assignment from CNI_ARGS environment variable.

Additional information you deem important (e.g. issue happens only occasionally):
Try with and without network prefix; lowercase and all caps.

Output of podman version:

1.6.2-1

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

podman-1.6.2-2.fc31.x86_64
containernetworking-plugins-0.8.2-2.1.dev.git485be65.fc31.x86_64

Additional environment details (AWS, VirtualBox, physical, etc.):

  1. Fedora 31
  2. The bridge is configured by and shared with libvirtd, so omitted most of the configuration of CNI
@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 31, 2019
@space88man
Copy link
Author

IPAM static is also not working with CNI_ARGS.

Configure a minimal static network

{
    "cniVersion": "0.4.0",
    "name": "static",
    "plugins": [
        {
            "type": "bridge",
            "bridge": "vmbr0",
            "ipam": {
                "type": "static",
                "routes": [
                    {
                        "dst": "0.0.0.0/0"
                    }
                ],
                "addresses": [
                    {"address": "192.168.125.123/24", "gateway": "192.168.125.1"}
                ],
                "dns": {
                     "nameservers": ["192.168.125.1"]
                 }
            }
        }
    ]
}

Try changing the IP address: CNI_ARGS="IP=192.168.125.200;GATEWAY=192.168.125.1" podman run ... — this does not work. Only the IP 192.168.125.123 from the configuration file is used.

The addresses array is supposed to be optional. However if it is omitted and an IP address is attempted with CNI_ARGS

INFO[0000] About to add CNI network testing (type=bridge) 
ERRO[0000] Error adding network: IPAM plugin returned missing IP config 
ERRO[0000] Error while adding pod to CNI network "testing": IPAM plugin returned missing IP config 

@space88man space88man changed the title Cannot assign static IP with CNI_ARGS and IPAM host-local Cannot assign static IP with CNI_ARGS and IPAMs host-local or static Oct 31, 2019
@space88man
Copy link
Author

space88man commented Oct 31, 2019

The user's CNI_ARGS seems to be replaced by podman with

CNI_ARGS='IgnoreUnknown=1;K8S_POD_NAMESPACE=abcd_3;K8S_POD_NAME=bright_curie;K8S_POD_INFRA_CONTAINER_ID=342853d0e227a2f5cbc0bcfd6642983217c3b848e31ab2d2a0245f2ef2edcaae'

@space88man
Copy link
Author

space88man commented Oct 31, 2019

The following hack restores the "correct" behaviour:

mv  /usr/libexec/cni/static  /usr/libexec/cni/static.real
cat > /usr/libexec/cni/static  <<EOF
#! /bin/bash
CNI_ARGS="$CNI_ARGS;$CNI_EXTRA_ARGS"
exec /usr/libexec/cni/static.real
EOF
chmod +x /usr/libexec/cni/static

Then

# this actually works as it adds the users' CNI_ARGS back to the
# podman overwritten ones!
CNI_EXTRA_ARGS="IP=192.168.125.200/24;GATEWAY=192.168.125.1" \
    podman run --network static ...

This works (!).

@space88man space88man changed the title Cannot assign static IP with CNI_ARGS and IPAMs host-local or static podman is overwriting users's CNI_ARGS to the plugn Oct 31, 2019
@space88man space88man changed the title podman is overwriting users's CNI_ARGS to the plugn podman is overwriting user's CNI_ARGS to the plugn Oct 31, 2019
@space88man space88man changed the title podman is overwriting user's CNI_ARGS to the plugn podman is overwriting user's CNI_ARGS to the CNI plugin Oct 31, 2019
@rhatdan
Copy link
Member

rhatdan commented Oct 31, 2019

@baude @mheon Can we extend the ARGS rather then truncating them?
@space88man Any change you would want to open a PR?

@mheon
Copy link
Member

mheon commented Oct 31, 2019

This is all in OCICNI - we don't touch any of it in Libpod land

@rhatdan
Copy link
Member

rhatdan commented Oct 31, 2019

@dcbw FYI

@space88man
Copy link
Author

@rhatdan happy to PR - where is the "upstream" is it pkg/ocicni here or the separate project https://github.com/cri-o/ocicni. (Ref: cri-o/ocicni#37 (comment) "Consider moving this project into CRI-O")

@mheon
Copy link
Member

mheon commented Nov 1, 2019

@space88man The upstream is github.com/cri-o/ocicni

@github-actions
Copy link

github-actions bot commented Dec 2, 2019

This issue had no activity for 30 days. In the absence of activity or the "do-not-close" label, the issue will be automatically closed within 7 days.

@rhatdan
Copy link
Member

rhatdan commented Dec 2, 2019

I think this is still an issue.

@vrothberg
Copy link
Member

Still an issue.

@rhatdan
Copy link
Member

rhatdan commented Feb 18, 2020

Is this our issue or CNI?

@vrothberg
Copy link
Member

CNI -> cri-o/ocicni#65

@space88man
Copy link
Author

space88man commented Feb 20, 2020

@rhatdan cri-o/ocicni#70 PTAL, does this work for podman?
Since the real issue is with ocicni, I guess you should close this issue. Thanks.

@rhatdan
Copy link
Member

rhatdan commented Feb 21, 2020

I will let @mheon and @baude answer that question.

@baude
Copy link
Member

baude commented Feb 21, 2020

we w ould just need to know to vendor in when it is merged

@rhatdan
Copy link
Member

rhatdan commented Jun 9, 2020

This Issue is like the never ending story...

@baude baude closed this as completed Sep 2, 2020
@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 Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
do-not-close 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. stale-issue
Projects
None yet
Development

No branches or pull requests

6 participants