Skip to content

Commit 6febb7e

Browse files
committed
SubnetManager should use the main context
Signed-off-by: Manuel Buil <[email protected]>
1 parent f5b88d9 commit 6febb7e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

pkg/backend/vxlan/vxlan.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGroup,
146146
// When flannel is restarted, it will get the MAC address from the node annotations to set flannel.1 MAC address
147147
var hwAddr net.HardwareAddr
148148

149-
macStr := be.subnetMgr.GetStoredMacAddress()
149+
macStr := be.subnetMgr.GetStoredMacAddress(ctx)
150150
if macStr != "" {
151151
hwAddr, err = net.ParseMAC(macStr)
152152
if err != nil {

pkg/subnet/etcd/local_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func newLocalManager(r Registry, prevSubnet ip.IP4Net, prevIPv6Subnet ip.IP6Net,
7979
}
8080
}
8181

82-
func (m *LocalManager) GetStoredMacAddress() string {
82+
func (m *LocalManager) GetStoredMacAddress(ctx context.Context) string {
8383
return ""
8484
}
8585

pkg/subnet/kube/kube.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPa
134134
if sm.disableNodeInformer {
135135
log.Infof("Node controller skips sync")
136136
} else {
137-
go sm.Run(context.Background())
137+
go sm.Run(ctx)
138138

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

609609
// GetStoredMacAddress reads MAC address from node annotations when flannel restarts
610-
func (ksm *kubeSubnetManager) GetStoredMacAddress() string {
610+
func (ksm *kubeSubnetManager) GetStoredMacAddress(ctx context.Context) string {
611611
// get mac info from Name func.
612-
node, err := ksm.client.CoreV1().Nodes().Get(context.TODO(), ksm.nodeName, metav1.GetOptions{})
612+
node, err := ksm.client.CoreV1().Nodes().Get(ctx, ksm.nodeName, metav1.GetOptions{})
613613
if err != nil {
614614
log.Errorf("Failed to get node for backend data: %v", err)
615615
return ""

pkg/subnet/subnet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type Manager interface {
123123
WatchLeases(ctx context.Context, receiver chan []lease.LeaseWatchResult) error
124124
CompleteLease(ctx context.Context, lease *lease.Lease, wg *sync.WaitGroup) error
125125

126-
GetStoredMacAddress() string
126+
GetStoredMacAddress(ctx context.Context) string
127127
Name() string
128128
}
129129

0 commit comments

Comments
 (0)