-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
API sometimes can't find networks created via CLI while API is running #11828
Comments
This is expected in the current implementation. I personally think this is a rare use case. To fix this we would have to use inotify which causes problem for rootless users or read the config files everytime you do a network create/ls/rm, etc... |
How are we deciding when to reload the list of available networks now - every time the API endpoints are hit, or less frequent? It's probably inexpensive enough to do it frequently if that will resolve this without inotify. |
We are never reloading once they are loaded. Only networks that are created and removed via api are updated. |
I'm using the CLI to test my API wrapper implementation so I don't have to rely on parts of my code to test other parts. If this would be possible with a flag or something similar, this would be awesome. |
Idea, stat the config dir and store the the mtime, if it changed we reload. I think that should work. |
Implementation Detail: We could add a middleware handler to the necessary API endpoints to reload the list. This could work well with #11828 (comment) Current middleware handlers that we use log trace data, log panics, support X-Reference-Id headers. |
API middleware handler to update memory list of networks if Config.Network.NetworkConfigDir is newer. Fixes containers#11828 Signed-off-by: Jhon Honce <[email protected]>
@jwhonce I would prefer to handle this inside the network interface. There is already logic which loads the networks on the first call. This way we only need to check if the network interface is actually used. |
I'm still wondering how costly a full refresh is; if it's cheap, there's not much reason not to do it every time. |
Well we need to read and unmarshal every config file in the directory so it is definitely costly. Keep in mind that this process is locked. |
The current implementation of the CNI network interface only loads the networks on the first call and saves them in a map. This is done to safe performance and not having to reload all configs every time which will be costly for many networks. The problem with this approach is that if a network is created by another process it will not be picked up by the already running podman process. This is not a problem for the short lived podman commands but it is problematic for the podman service. To make sure we always have the actual networks store the mtime of the config directory. If it changed since the last read we have to read again. Fixes containers#11828 Signed-off-by: Paul Holzinger <[email protected]>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When running the API service, creating a network via CLI sometimes isn't reflected in the API.
Steps to reproduce the issue:
podman system service unix:///home/`whoami`/testing.sock --log-level=debug --time=500
podman network create testns && sleep 5 && curl -v -X DELETE --unix-socket /home/`whoami`/testing.sock http://d/v3.0.0/libpod/networks/testns
Describe the results you received:
{"cause":"network not found","message":"unable to find network with name or ID testns: network not found","response":404}
The network can't be found via API. The list networks endpoint also doesn't return the
testns
network:Describe the results you expected:
The
testns
network get's deletedAdditional information you deem important (e.g. issue happens only occasionally):
I'm writing a library wrapping the API, when running tests against the networks endpoints, most fail. Running each test seperate works for every test. When testing the issue with curl, I could reproduce it every time. Restarting the API allows to see the network with the list endpoint and to delete it via API.
Output of
podman version
:Output of
podman info --debug
: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, using self built latest Github dev version.
Additional environment details (AWS, VirtualBox, physical, etc.):
Windows 10 WSL2, Debian Bullseye
The text was updated successfully, but these errors were encountered: