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

nodehandler: register node-id restore as hive lifecycle hook #25497

Merged
merged 1 commit into from May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions daemon/cmd/daemon.go
Expand Up @@ -743,10 +743,6 @@ func newDaemon(ctx context.Context, cleaner *daemonCleanup, params *daemonParams
log.WithField(logfields.Ingress, restoredIngressIPs).Info("Restored ingress IPs")
}

// Now that BPF maps are opened, we can restore node IDs to the node
// manager.
d.datapath.Node().RestoreNodeIDs()

// Read the service IDs of existing services from the BPF map and
// reserve them. This must be done *before* connecting to the
// Kubernetes apiserver and serving the API to ensure service IDs are
Expand Down
11 changes: 10 additions & 1 deletion pkg/datapath/cells.go
Expand Up @@ -92,7 +92,16 @@ func newDatapath(params datapathParams) types.Datapath {
return nil
}})

return linuxdatapath.NewDatapath(datapathConfig, iptablesManager, params.WgAgent)
datapath := linuxdatapath.NewDatapath(datapathConfig, iptablesManager, params.WgAgent)

params.LC.Append(hive.Hook{
OnStart: func(hive.HookContext) error {
datapath.Node().RestoreNodeIDs()
Copy link
Member Author

Choose a reason for hiding this comment

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

note: RestoreNodeIDs will implicitly enforce opening the BPF map if it's not already opened - which is the case with this move because the OnStart lifecycle hook will be executed before the initialization of the BPF map in the daemon init.

see https://github.com/cilium/cilium/blob/main/pkg/ebpf/map.go#L177-L181

anyway - i'll come up with an additional PR which will refactor the node map to be provided as hive cell after this one got merged. This will make this dependency visible and correct the initialization order.

return nil
},
})

return datapath
}

type datapathParams struct {
Expand Down