flannel-io / flannel

flannel is a network fabric for containers, designed for Kubernetes
Apache License 2.0
8.61k stars 2.87k forks source link

SubnetManager should use the main context #1867

Closed manuelbuil closed 4 months ago

manuelbuil commented 4 months ago

Description

For some unknown reason, subnetManager was using a different context than the main one, thus the cancel() method to clean up flannel resources will never work in this case.

This PR fixes that and subnetManager will use the main context

Todos

Release Note

None required
thomasferrandiz commented 4 months ago

I just noticed that this context is wrong as well: https://github.com/flannel-io/flannel/blob/f5b88d962d963cafac1ef91293608645597643cd/pkg/subnet/kube/kube.go#L612

Context.TODO is only for dev

manuelbuil commented 4 months ago

I just noticed that this context is wrong as well:

https://github.com/flannel-io/flannel/blob/f5b88d962d963cafac1ef91293608645597643cd/pkg/subnet/kube/kube.go#L612

Context.TODO is only for dev

Should it be Context.Background? I wonder if we could do something to pipe the main context

thomasferrandiz commented 4 months ago

I think we can get the main context because GetStoredMacAddress is called in RegisterNetwork where it is available.

manuelbuil commented 4 months ago

I think we can get the main context because GetStoredMacAddress is called in RegisterNetwork where it is available.

done!