Skip to content

Commit

Permalink
SubnetManager should use the main context
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Buil <mbuil@suse.com>
  • Loading branch information
manuelbuil committed Feb 13, 2024
1 parent f5b88d9 commit 6febb7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
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

0 comments on commit 6febb7e

Please sign in to comment.