Commit Graph

824 Commits

Author SHA1 Message Date
Dan Williams
d9c06e99d1 server: don't set CNI config readinessindicatorfile when using ConfigManager
For whatever reason calling os.Stat() on the readiness indicator file
from CmdAdd()/CmdDel() when multus is running in server mode and is
containerized often returns "file not found", which triggers the
polling behavior of GetReadinessIndicatorFile(). This greatly delays
CNI operations that should be pretty quick. Even if an exponential
backoff is used, os.Stat() can still return "file not found"
multiple times, even though the file clearly exists.

But it turns out we don't need to check the readiness file in server
mode when running with MultusConfigFile == "auto". In this mode the
server starts the ConfigManager which (a) waits until the file exists
and (b) fsnotify watches the readiness and (c) exits the daemon
immediately if the file is deleted or moved.

This means we can assume that while the daemon is running and the
server is handling CNI requests that the readiness file exists;
otherwise the daemon would have exited. Thus CmdAdd/CmdDel don't
need to run a lot of possibly failing os.Stat() calls in the CNI
hot paths.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
b0df7dd5e3 server/config: use filepath.Join()
Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
fb4f4aa4c1 server/config: un-export some functions no longer used outside the module
Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
c2add82b93 server/config: fix MonitorPluginConfiguration test
The test was comparing the same configuration to itself, since
nothing in the changed CNI configuration is used in the written
multus configuration.

Instead make sure the updated CNI config contains something
that will be reflected in the written multus configuration,
and while we're there use a more robust way to wait for the
config to be written via gomega.Eventually().

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
8539a476fd server/config: consolidate ConfigManager start and fsnotify watching
Simplify setup by moving the post-creation operations like
GenerateConfig() and PersistMultusConfig() into a new Start() function
that also begins watching the configuration directory. This better
encapsulates the manager functionality in the object.

We can also get rid of the done channel passed to the config
manager and just use the existing WaitGroup to determine when to
exit the daemon main().

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
4ade85669b server/config: simplify ConfigManager creation
A couple of the setup variables for NewManager*() are already in the
multus config that it gets passed, so use those instead of passing
explicitly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:58:19 -05:00
Dan Williams
50c0357467 server: use a shared informer pod cache rather than direct apiserver access
When running in server mode we can use a shared informer to listen for
Pod events from the apiserver, and grab pod info from that cache rather
than doing direct apiserver requests each time.

This reduces apiserver load and retry latency, since multus can poll
the local cache more frequently than it should do direct apiserver
requests.

Oddly static pods don't show up in the informer by the timeout and
require a direct apiserver request. Since static pods are not common
and are typically long-running, it should not be a big issue to
fall back to direct apiserver access for them.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-14 08:57:12 -05:00
Dan Williams
cec1a53cd8 server: simplify server start
Move server start code to a common function that both regular
and test code can use. Also shut down the server from the
testcases.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
1605ffcad5 daemon: remove unused done channel
Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
7c68481e43 vendor: add client-go and more apimachinery modules
We'll need these for the next commit.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
6b8d24c1ef server: make CmdAdd/Del/Check struct member functions
Then we can just use the Server struct kube client and exec rather
than passing them through the function parameters.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
752f28c2bc k8sclient: bump QPS to 50
Multus is a pretty critical piece of infrastructure, so it shouldn't
be subject to the same lower QPS limits as most components are.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
fff8519517 k8sclient: make InClusterK8sClient() call GetK8sClient()
We want the in-cluster client that the multus server uses to use
the same client config (QPS, protobuf, grpc, etc) as the regular
client.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 07:54:41 -05:00
Dan Williams
02ce071abb
github: export and upload e2e test kind logs (#1157)
When things go wrong the logs can help figure out why.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2023-09-13 21:51:58 +09:00
Doug Smith
7ea924b8f1
Merge pull request #1148 from s1061123/fix/1126
Add 'cniConfigDir' to specify config dir
2023-08-31 14:16:37 -04:00
Tomofumi Hayashi
f6afc79b47 Add 'cniConfigDir' to specify config dir
Fix #1126
2023-09-01 03:02:29 +09:00
Doug Smith
3a95111901
Merge pull request #1145 from s1061123/refine-build
Refine build script
2023-08-25 11:06:37 -04:00
Tomofumi Hayashi
4456e91b5c Refine build script 2023-08-24 01:52:15 +09:00
Doug Smith
c5a0002be4
Merge pull request #1142 from s1061123/fix/1130
fix multus config file generation to avoid self-delegation
2023-08-16 10:58:56 -04:00
Tomofumi Hayashi
159f2610c0 fix multus config file generation to avoid self-delegation
Check masterConfigPath file and skip if it is multus generated
files. Fix #1130
2023-08-16 21:00:26 +09:00
Doug Smith
8d8aa80cd5
Merge pull request #1101 from AlinaSecret/fix-race-condition
Fix race conditions in logging package functions and enable race detection in tests
2023-08-11 10:29:11 -04:00
Alina Sudakov
272b3ca8fa Fix race conditions in logging package functions
The logging package contains two functions, SetLogOptions and SetLogFile, that could experience race conditions when multiple goroutines access and modify the logger struct concurrently. 
To address these issues, a copy of the logger struct is now created in each function to eliminate data races.

In addition, the test-go.sh script is updated to include the '-race' flag, enabling race detection during testing. This change helps prevent future race conditions by activating the Go race detector.

Signed-off-by: Alina Sudakov <asudakov@redhat.com>
2023-08-10 13:17:19 +03:00
Tomofumi Hayashi
d5883bdbfa
Fix multus-daemon quit process (#1133) 2023-08-04 01:16:37 +09:00
Doug Smith
46d446f0e5
Merge pull request #1131 from s1061123/thick-readiness
Support readinessIndicator file in thick multus-daemon
2023-08-01 10:11:18 -04:00
Tomofumi Hayashi
41d5d08686 Support readinessIndicator file in thick multus-daemon
This change supports readinessIndicatorfile in multus-daemon and
refines goroutine termination in case of signal with context.
2023-08-01 23:01:17 +09:00
Doug Smith
bf79dc3269
Merge pull request #1127 from s1061123/add-ready-check
This change introduces wait to generate config until API is ready
2023-07-24 09:54:21 -04:00
Tomofumi Hayashi
82324a7795 This change introduces wait to generate config until API is ready 2023-07-24 22:38:08 +09:00
dependabot[bot]
91a82a1264
Bump google.golang.org/grpc from 1.40.0 to 1.53.0 (#1120)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.40.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.40.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 23:37:26 +09:00
Doug Smith
0bc8103654
Merge pull request #1125 from s1061123/refine-options
Refine and fix parameters
2023-07-20 09:39:05 -04:00
Tomofumi Hayashi
fa60329105 Refine and fix parameters
This changes refines parameters in multus thick/thin.
- delete unused parameter, confDir
- add multus-cni-conf-dir
- fix multusConfigPath in non-default params case
2023-07-20 21:22:54 +09:00
Doug Smith
99c4481e08
Merge pull request #1085 from s1061123/fix/fix-sliceindex
Fix potential issue, slice bounds out of range error
2023-06-29 10:07:42 -04:00
Doug Smith
f03765681f
Merge pull request #1095 from s1061123/fix/plugin-without-interface
Fix multus to support CNI plugin which does not create interface
2023-05-18 13:51:56 -04:00
Tomofumi Hayashi
22304806c8 Fix multus to support CNI plugin which does not create interface
This change fixes multus to support CNI plugin which does not
create any interface and return empty result. Some CNI plugin
may do network configuration change only and does not create
any interface and return empty CNI result. Current multus assumes
that CNI config always creates some interfaces hence above CNI
plugin is out of assumption and multus may not work with such
plugins.
2023-05-18 02:40:27 +09:00
Doug Smith
0c37bb043c
Merge pull request #1084 from s1061123/fix/del-noerr
Suppress error message in cmdDel, in thick plugin
2023-05-02 14:54:41 -04:00
Tomofumi Hayashi
da704f8f63 Fix potential issue, slice bounds out of range error 2023-05-03 03:42:33 +09:00
Tomofumi Hayashi
5d64ec3367 Suppress error message in cmdDel, in thick plugin
This fix suppress error message in thick plugin's shim, for
DEL command, to align with CNI spec.

Fix #1080
2023-05-03 03:33:01 +09:00
Tomofumi Hayashi
b05ff2db4e Fix origin github action workflows 2023-05-03 03:32:32 +09:00
Doug Smith
b9acfeb6b7
Adds permanent slack invite (#1083) 2023-04-27 23:07:48 +09:00
Tomofumi Hayashi
77aac95dfc Fix github action 2023-04-15 02:07:39 +09:00
Tomofumi Hayashi
72945e3679
Add missing mutex lock for race condition fix (#1074) 2023-04-15 02:02:44 +09:00
Tomofumi Hayashi
1b01e3e486 Change gopkg.in to v4 for v4 release 2023-04-13 23:36:40 +09:00
Tomofumi Hayashi
fe14c17fe7
Refine dockerfile to use buildx multi-arch image for thin plugin (#1070) 2023-04-13 23:15:00 +09:00
Tomofumi Hayashi
66b0c5c371
Update goreleaser (#1069)
This change update goleleaser action and goreleaser config file
to release multus binaries, including multus-daemon and multus-shim
2023-04-13 22:43:30 +09:00
Tomofumi Hayashi
f3a371358a
Update golang to 1.19 (#1067) 2023-04-13 22:42:32 +09:00
Tomofumi Hayashi
b4bea43f7e
Cleanup code comment (#1068)
This change removes unnecessary comment.
2023-04-13 22:41:14 +09:00
Tomofumi Hayashi
7c22973f9f
Add mutex lock for load confs in GetDefaultNetworks (#1073)
Thick server's chroot mutex is missing in GetDefaultNetworks,
that touch the pod filesystem. This change adds mutex lock there
and prevent race condition.

Fix #1072
2023-04-13 22:40:16 +09:00
Doug Smith
487c6fcec4
Merge pull request #1066 from s1061123/fix/thick-log-options
Refactoring thick daemon config processing
2023-04-10 09:40:00 -04:00
Tomofumi Hayashi
c279938e21 Refactoring thick daemon config processing
to damonset config file, hence command line option parsing is no
longer used. This change removes these parts.

Fix #1058.
2023-04-08 01:34:05 +09:00
Tomofumi Hayashi
855e8bee45
Add workaround patch for okd-builder.Dockerfile build failure (#1063)
Fix #1062
2023-04-07 00:30:11 +09:00
Tomofumi Hayashi
5bce250398
Fix linter warning message (#1057) 2023-04-07 00:20:04 +09:00