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

Ensure ovnkube-controller does not go remote->local #3735

Merged
merged 1 commit into from
Jul 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ func (cm *networkControllerManager) Start(ctx context.Context) error {
if err1 != nil {
return false, nil
}

if config.Default.Zone != zone {
err1 = fmt.Errorf("config zone %s different from NBDB zone %s", config.Default.Zone, zone)
return false, nil
Expand All @@ -326,6 +325,36 @@ func (cm *networkControllerManager) Start(ctx context.Context) error {
}
klog.Infof("NBDB zone sync took: %s", time.Since(start))

err = cm.watchFactory.Start()
if err != nil {
return err
}

// Wait for one node to have the zone we want to manage, otherwise there is no point in configuring NBDB.
// Really this covers a use case where a node is going from local -> remote, but has not yet annotated itself.
// In this case ovnkube-controller on this remote node will treat the node as remote, and then once the annotation
// appears will convert it to local, which may or may not clean up DB resources correctly.
klog.Infof("Waiting up to %s for a node to have %q zone", maxTimeout, config.Default.Zone)
start = time.Now()
err = wait.PollUntilContextTimeout(ctx, 250*time.Millisecond, maxTimeout, true, func(ctx context.Context) (bool, error) {
nodes, err := cm.watchFactory.GetNodes()
if err != nil {
klog.Errorf("Unable to get nodes from informer while waiting for node zone sync")
return false, nil
}
for _, node := range nodes {
if util.GetNodeZone(node) == config.Default.Zone {
return true, nil
}
}
return false, nil
})
if err != nil {
return fmt.Errorf("failed to start default network controller - while waiting for any node to have zone: %q, error: %v",
config.Default.Zone, err)
}
klog.Infof("Waiting for node in zone sync took: %s", time.Since(start))

cm.configureMetrics(cm.stopChan)

err = cm.configureSCTPSupport()
Expand All @@ -348,11 +377,6 @@ func (cm *networkControllerManager) Start(ctx context.Context) error {
}
cm.podRecorder.Run(cm.sbClient, cm.stopChan)

err = cm.watchFactory.Start()
if err != nil {
return err
}

err = cm.initDefaultNetworkController()
if err != nil {
return fmt.Errorf("failed to init default network controller: %v", err)
Expand Down