@@ -394,9 +394,8 @@ func (c *IPAMContext) inInsufficientCidrCoolingPeriod() bool {
394394
395395// New retrieves IP address usage information from Instance MetaData service and Kubelet
396396// then initializes IP address pool data store
397- func New (k8sClient client.Client , withApiServer bool ) (* IPAMContext , error ) {
397+ func New (ctx context. Context , k8sClient client.Client , withApiServer bool ) (* IPAMContext , error ) {
398398 prometheusRegister ()
399- ctx := context .Background ()
400399 c := & IPAMContext {}
401400 c .k8sClient = k8sClient
402401 c .networkClient = networkutils .New ()
@@ -407,7 +406,7 @@ func New(k8sClient client.Client, withApiServer bool) (*IPAMContext, error) {
407406 c .enableIPv4 = isIPv4Enabled ()
408407 c .enableIPv6 = isIPv6Enabled ()
409408 c .disableENIProvisioning = disableENIProvisioning ()
410- client , err := awsutils .New (c .useSubnetDiscovery , c .useCustomNetworking , disableLeakedENICleanup (), c .enableIPv4 , c .enableIPv6 )
409+ client , err := awsutils .New (ctx , c .useSubnetDiscovery , c .useCustomNetworking , disableLeakedENICleanup (), c .enableIPv4 , c .enableIPv6 )
411410 if err != nil {
412411 return nil , errors .Wrap (err , "ipamd: can not initialize with AWS SDK interface" )
413412 }
@@ -446,16 +445,15 @@ func New(k8sClient client.Client, withApiServer bool) (*IPAMContext, error) {
446445 c .myNodeName = os .Getenv (envNodeName )
447446 c .withApiServer = withApiServer
448447
449- if err := c .nodeInit (); err != nil {
448+ if err := c .nodeInit (ctx ); err != nil {
450449 return nil , err
451450 }
452451 return c , nil
453452}
454453
455- func (c * IPAMContext ) nodeInit () error {
454+ func (c * IPAMContext ) nodeInit (ctx context. Context ) error {
456455 prometheusmetrics .IpamdActionsInprogress .WithLabelValues ("nodeInit" ).Add (float64 (1 ))
457456 defer prometheusmetrics .IpamdActionsInprogress .WithLabelValues ("nodeInit" ).Sub (float64 (1 ))
458- ctx := context .TODO ()
459457 log .Debugf ("Start node init" )
460458
461459 if err := c .initENIAndIPLimits (); err != nil {
@@ -582,10 +580,10 @@ func (c *IPAMContext) nodeInit() error {
582580 // Refresh security groups and VPC CIDR blocks in the background
583581 // Ignoring errors since we will retry in 30s
584582 go wait .Forever (func () {
585- c .awsClient .RefreshSGIDs (context . Background () , primaryENIMac , c .dataStoreAccess )
583+ c .awsClient .RefreshSGIDs (ctx , primaryENIMac , c .dataStoreAccess )
586584 // Also refresh custom security groups for secondary subnets
587585 if c .useSubnetDiscovery {
588- c .awsClient .RefreshCustomSGIDs (context . Background () , c .dataStoreAccess )
586+ c .awsClient .RefreshCustomSGIDs (ctx , c .dataStoreAccess )
589587 }
590588 }, 30 * time .Second )
591589 }
@@ -2519,8 +2517,6 @@ func (c *IPAMContext) cleanupExcludedENI(ctx context.Context, eniID string) {
25192517
25202518// checkAndHandleAllENIExclusion checks all existing ENIs (primary and secondary) across all network cards for subnet exclusion
25212519func (c * IPAMContext ) checkAndHandleAllENIExclusion (ctx context.Context ) {
2522- log .Debugf ("checkAndHandleAllENIExclusion: checking all existing ENIs for subnet exclusion" )
2523-
25242520 // Iterate over all datastores (one per network card)
25252521 for _ , ds := range c .dataStoreAccess .DataStores {
25262522 // Get ENI information using the public method
0 commit comments