Skip to content
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

Pr/tp/refactor kpr init #32275

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tommyp1ckles
Copy link
Contributor

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

Fixes: #issue-number

<!-- Enter the release note text here if needed or remove this section! -->

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 30, 2024
@@ -104,6 +106,25 @@ func newConfig(in newConfigIn) (Config, error) {
}
}

if in.Config.EnableNodePort {
if in.Config.TunnelingEnabled() && cfg.Protocol() == VXLAN &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: ensure that none of these configs are change elsewhere during init phase.

@tommyp1ckles
Copy link
Contributor Author

/test

This will allow creating a dependency on the initKubeProxyReplacement
performed prior to runtime.

Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
When creating a new daemon with newDaemon, we perform various procedures
to detect kpr config and subsequently override various config options, if
necessary.

Unlike most provided dependencies, newDaemon is created inside hive
lifecycle and exposed as a dependeny inside a promise.

This presents a problem when trying to write new modules that use the
global *option.DaemonConfig. Although this type is exposed to hive via
a Provide(...) call, some fields may change after the daemon has
started so attempting to use the config during the populate phase can
cause incorrect configuration to be used.
Notably fields such as option.Config.EnableNodePort may change at runtime.

Trying to solve this by forcing a dependency on the daemon promise
fails in two ways:

i.  Modules that require a finalized *DaemonConfig while being
  initialized cannot wait for promise.Promise[*Daemon] to resolve
  as this would cause a deadlock waiting for a runtime dependency.

ii. The map group provided using bpf.MapOut[T](...) has dependency on
  daemonPromise (these are synced before the loader dependency).
  So trying to depend on this would cause a Hive dependency cycle.

Most of the kpr config init can be done prior to runtime, as finalizing
configuration and probing seem like possibly reasonable things to do in
the Hive init (i.e. Populate(...)) phase.

This moves all such work out of newDaemon and outside of hives
lifecycle.
As well, the old hive *DaemonConfig provider is replaced with a new
one that does all possible kpr init tasks and only then exports the
config.

This means that any module depending on *option.DaemonConfig will now
be sure that any config values in the config that where overridden by
kpr init will now be finalized at the time of construction - avoiding
races where config is overwritten at runtime later.

Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
The MTU cell relies on option.Config.NodePortEnabled which as
described in commit c2d65fe61a9231ee961097f894466727a2438768 is
prone to a race where the daemon changes this configuration at runtime.

This uses the newly introduced option.(*FinalDaemonConfig) type as a
parameter dependency to prevent such issues with MTU.

Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
Copy link

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant