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

SubnetManager should use the main context #1867

Merged
merged 1 commit into from
Feb 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/backend/vxlan/vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGroup,
// When flannel is restarted, it will get the MAC address from the node annotations to set flannel.1 MAC address
var hwAddr net.HardwareAddr

macStr := be.subnetMgr.GetStoredMacAddress()
macStr := be.subnetMgr.GetStoredMacAddress(ctx)
if macStr != "" {
hwAddr, err = net.ParseMAC(macStr)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/subnet/etcd/local_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newLocalManager(r Registry, prevSubnet ip.IP4Net, prevIPv6Subnet ip.IP6Net,
}
}

func (m *LocalManager) GetStoredMacAddress() string {
func (m *LocalManager) GetStoredMacAddress(ctx context.Context) string {
return ""
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPa
if sm.disableNodeInformer {
log.Infof("Node controller skips sync")
} else {
go sm.Run(context.Background())
go sm.Run(ctx)

log.Infof("Waiting %s for node controller to sync", nodeControllerSyncTimeout)
err = wait.Poll(time.Second, nodeControllerSyncTimeout, func() (bool, error) {
Expand Down Expand Up @@ -607,9 +607,9 @@ func (m *kubeSubnetManager) HandleSubnetFile(path string, config *subnet.Config,
}

// GetStoredMacAddress reads MAC address from node annotations when flannel restarts
func (ksm *kubeSubnetManager) GetStoredMacAddress() string {
func (ksm *kubeSubnetManager) GetStoredMacAddress(ctx context.Context) string {
// get mac info from Name func.
node, err := ksm.client.CoreV1().Nodes().Get(context.TODO(), ksm.nodeName, metav1.GetOptions{})
node, err := ksm.client.CoreV1().Nodes().Get(ctx, ksm.nodeName, metav1.GetOptions{})
if err != nil {
log.Errorf("Failed to get node for backend data: %v", err)
return ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type Manager interface {
WatchLeases(ctx context.Context, receiver chan []lease.LeaseWatchResult) error
CompleteLease(ctx context.Context, lease *lease.Lease, wg *sync.WaitGroup) error

GetStoredMacAddress() string
GetStoredMacAddress(ctx context.Context) string
Name() string
}

Expand Down
Loading