api: wait with api server start until legacy daemon init finished #39441
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the API server start no longer waits until the legacy
daemon initialization finished (introduced with #39357).
This can lead to panics from api handlers
that rely on globals that are initialized by this legacy daemon logic.
(e.g. config handler that relies on node globals (
node.GetNodeAddressing
).Therefore, this commit modifies the configmodify api handler to wait for
the Daemon promise. This way, the start of the api server gets postponed
until IPAM has been initialized.
Note: Unfortunately, due to circular dependencies it's not possible to
depend on the Daemon promise directly. Therefore, this commit also
introduces a new marker interface
legacy.DaemonInitialization
thatcan be used to depend on the daemon initialization.
Note 2: IMO it's better to introduce this new (but hopefully temporary) interface than adjust the
server.Server
template to actually wait on a promise before starting the server. Because this might have other side-effects (e.g. premature unlock of endpoint deletion queue, ...)Note 3: Let's hope that we can delete the
Daemon
struct in the near future - to prevent re-adding state to it. Then it's even more useful to have this "marker" interface for the cases that still need to be able to depend on the legacy daemon init phase.Fixes: #39430
Fixes: #39357