Skip to content

Conversation

mhofstetter
Copy link
Member

@mhofstetter mhofstetter commented May 8, 2025

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 that
can 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

@mhofstetter mhofstetter added kind/bug This is a bug in the Cilium logic. release-note/misc This PR makes changes that have no direct user impact. labels May 8, 2025
@mhofstetter mhofstetter requested a review from joamaki May 8, 2025 14:32
@mhofstetter mhofstetter marked this pull request as ready for review May 8, 2025 14:32
@mhofstetter mhofstetter requested a review from a team as a code owner May 8, 2025 14:32
@mhofstetter mhofstetter marked this pull request as draft May 8, 2025 15:14
@mhofstetter mhofstetter force-pushed the pr/mhofstetter/fix-apihandler-panic branch from 49d853f to b96f96d Compare May 8, 2025 15:33
@mhofstetter mhofstetter changed the title api: wait with api server initialization until legacy daemon init finished api: wait with api server start until legacy daemon init finished May 8, 2025
@mhofstetter mhofstetter marked this pull request as ready for review May 8, 2025 15:37
@mhofstetter mhofstetter requested a review from a team as a code owner May 8, 2025 15:37
@mhofstetter mhofstetter removed the request for review from a team May 8, 2025 15:38
@mhofstetter mhofstetter marked this pull request as draft May 8, 2025 16:14
@mhofstetter mhofstetter force-pushed the pr/mhofstetter/fix-apihandler-panic branch from b96f96d to aa2b4fa Compare May 8, 2025 17:01
@mhofstetter
Copy link
Member Author

/test

@mhofstetter mhofstetter marked this pull request as ready for review May 8, 2025 17:21
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 9, 2025
@mhofstetter mhofstetter removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 9, 2025
Currently, the API server start no longer waits until the legacy
daemon initialization finished. 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 no possible to
depend on the Daemon promise directly. Therefore, this commit also
introduces a new struct `legacy.DaemonInitialization` that
can be used to depend on the daemon initialization.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
@mhofstetter mhofstetter force-pushed the pr/mhofstetter/fix-apihandler-panic branch from aa2b4fa to c3baa76 Compare May 9, 2025 12:07
@mhofstetter
Copy link
Member Author

/test

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 9, 2025
@joamaki joamaki added this pull request to the merge queue May 9, 2025
Merged via the queue into cilium:main with commit bb27973 May 9, 2025
66 checks passed
@mhofstetter mhofstetter deleted the pr/mhofstetter/fix-apihandler-panic branch May 9, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: Cilium API handler panicked in node.GetNodeAddressing()
2 participants