We cannot compare network with Expect().To(Equal()), the internal
time.Time is not equal after parsing from file. There is some internal
field offset that can be different but the date is still the same. Other
tests have the same problem and to circumvent this we use EqualNetwork()
there. Do the same here.
Fixes#1335
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
With progress on netavark-dhcp-proxy, we can begin to macvlan with dhcp
back into the fold for netavark.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Commit 4bf13f4b29 caused a regression, previously the lockfile
package create the config directory. Now this is no longer the case
so we have to create it explicitly.
Note that netavark already did this so no change is needed there.
This was reported by the RHEL QE team.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Should speed up app startup time a little since the compile
happens for all users of the library. Compile only on use.
[NO NEW TESTS NEEDED]
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
The default /etc/containers/networks location might not be writeable,
while this breaks podman network create it does not need to break all
podman commands since the lock is created on libpod initialization.
ref https://github.com/containers/common/pull/1270
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
I want to switch podman over to only using strings for the netns path.
So we no longer pass this interface around. Buildah doesn't use this so
we only need to fix it in Podman. I have a WIP PR[1] for that.
[1] https://github.com/containers/podman/pull/16756
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
New features in netavark/aardvark allows users to update network dns
servers and all the containers attached to those networks uses updated
resolvers.
Following PR adds support in `libnetwork` to support
* Add support for higher level `NetworkUpdate` API
* Add support for `Update` exec call which can invoke netavark with a
new update option added here: https://github.com/containers/netavark/pull/503
Signed-off-by: Aditya R <arajan@redhat.com>
When creating macvlan or ipvlan network configs with the none ipam
driver we would always cause a segfault because of a nil pointer
dereference.
Add a test for both to prevent a regression.
Fixescontainers/podman#16620
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
For now, only add IgnoreIfExists flag.
Having this flag is very useful when using scripts or systemd unit files
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
libnetwork must allow to pass network_dns_servers so aardvark and
netavark can consume it and enabled network scoped dns.
Feature implemented at netavark and aardvark end
* Netavark: https://github.com/containers/netavark/pull/497
Signed-off-by: Aditya R <arajan@redhat.com>
All the gruntwork is done by Netavark, so all that's needed it to
know the key exists and verify that it parses as a uint.
Signed-off-by: Matthew Heon <mheon@redhat.com>
This is not supported in netavark so we should set to false by default
to make sure podman inspect will show the correct info.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Netavark now accets `dns_servers` for each container which allows
containers to use custom DNS servers as resolvers instead of falling
back to host's resolver.
Following field allows callers to libnetwork to pass newly added field
to `netavark` and `aarvark-dns`
Actual feature implemented
* https://github.com/containers/aardvark-dns/pull/240
* https://github.com/containers/netavark/pull/452
[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
Signed-off-by: Aditya R <arajan@redhat.com>
Both MAC and IP addresses are strings when serialized to JSON or
deserialized from JSON. By default swagger will show a byte array which
is wrong so we have to manually overwrite these fields.
Required for https://github.com/containers/podman/issues/13342
However we still have to update our swagger version to at least 0.30 in
podman to make it work.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
We are using CNI for systems that have run podman system reset, if
storage is setup with additional stores. This change will ignore
additional store images and will use netarvark on clean systems.
[NO NEW TESTS NEEDED]
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2124887
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
When the configuration directory is on a read-only filesystem,
there's no risk of concurrency issues as there's no possibility
of changing anything. As such, while it prevents the use of our
default lock location, it also removes any need for a lock at
all.
Making the lock entirely optional is a lot of code, so instead of
doing that let's just put it in our temporary files directory,
where it can't hurt anything.
Signed-off-by: Matthew Heon <mheon@redhat.com>
there was some eerily similar code in c/common and in podman for
creating filter functions for various types. Move some of it here
and add support for the label!= filter in libnetwork only. Libimage already supports it.
after this merges, will file a PR with the fix for containers within podman as well
see containers/podman#14182
Signed-off-by: Charlie Doern <cdoern@redhat.com>
`github.com/pkg/errors` is deprecated since quite some time so we now
use the native error wrapping for more idiomatic golang.
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit allows using aardvark with an alternate port as per
implementation in containers/netavark#323
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Even when a custom nameserver is set by the caller they may wish to
still keep the original nameserver too. This is needed by podman/buildah
when they only want to add the slirp4netns dns ip at the beginning for
example.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
both buildah and podman currently use a slightly different resolvconf lib,
to prevent duplication and having to fix bugs twice they should both use
this new package instead.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This only gets the libnetwork part to build - I have not tried to
get the rest of netavark to build on FreeBSD.
Signed-off-by: Doug Rabson <dfr@rabson.org>
unparam and exportloopref already work without changes.
For revive I had to silence many naming issues. I decided to silence them
instead of changing the name because I didn't want to break any code.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
machine.IsPodmanMachine replaces MachineEnabled
machine.MachineHostType informs the type unknown, qemu, wsl, etc
machine.IsGvProxyBased used to make specific determinations re gvproxy
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Add helper function to convert the base_hosts_file config value to a
actual path. It is important to use securejoin to make sure that
containers cannot point to a file on the hosts via a symlink.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Set the ip for the host.containers.internal entry in the containers /etc/hosts
file. This can be set to "none" to disable adding this entry. By default it
will automatically choose the host ip.
Also add a function to get the correct host.containers.internal ip. This
should be used by podman and buildah and then passed to the New()
function.
Ref https://github.com/containers/podman/issues/13224
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
base_hosts_file can be used to overwrite the default base host file
/etc/hosts which is used to copy hosts entries from this file into the
containers /etc/hosts file. As special value "image" can be used to copy
the entries from the image hosts file or "none" to not use a base file
at all. IF the value is empty we should use /etc/hosts as default.
Ref https://github.com/containers/podman/issues/13277
Ref https://github.com/containers/podman/issues/13748
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Add a new libnetwork/etchosts package to manage reading/writing hosts files.
This package exports four functions New(), Add(), AddIfExists() and Remove().
See the godoc comments on the functions.
Both podman and buildah should use this functions to make sure files are
generated identical.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Those were added by commit 39a8401bf, but are apparently no longer
needed.
Reported-by: Paul Holzinger <pholzing@redhat.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This one:
libnetwork/netavark/ipam_test.go:45:22: Error return value is not checked (errcheck)
networkInterface = libpodNet.(*netavarkNetwork)
^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>