Skip to content

Commit

Permalink
Fix log which causes panic (aws#407)
Browse files Browse the repository at this point in the history
* Fix log which causes panic

* Consistent key name

* consistent naming
  • Loading branch information
GnatorX authored Apr 21, 2024
1 parent 8fe171a commit c80fd41
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/provider/branch/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func timeSinceMs(start time.Time) float64 {
// cache for use in future Create/Delete Requests
func (b *branchENIProvider) InitResource(instance ec2.EC2Instance) error {
nodeName := instance.Name()
log := b.log.WithValues("node name", nodeName)
log := b.log.WithValues("nodeName", nodeName)
trunkENI := trunk.NewTrunkENI(log, instance, b.apiWrapper.EC2API)

// Initialize the Trunk ENI
Expand Down Expand Up @@ -242,7 +242,7 @@ func (b *branchENIProvider) DeleteNode(nodeName string) (ctrl.Result, error) {
trunkENI.DeleteAllBranchENIs()
b.removeTrunkFromCache(nodeName)

b.log.Info("de-initialized resource provider successfully", "node name", nodeName)
b.log.Info("de-initialized resource provider successfully", "nodeName", nodeName)

return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (b *branchENIProvider) ReconcileNode(nodeName string) bool {
log := b.log.WithValues("node", nodeName)
if !isPresent {
// return true to set the node next clean up asap since we don't know why trunk is missing
log.Info("no trunk ENI is pointing to the given node", "NodeName", nodeName)
log.Info("no trunk ENI is pointing to the given node", "nodeName", nodeName)
return true
}
podList, err := b.apiWrapper.PodAPI.ListPods(nodeName)
Expand All @@ -284,7 +284,7 @@ func (b *branchENIProvider) ReconcileNode(nodeName string) bool {
}
foundLeakedENI := trunkENI.Reconcile(podList.Items)

log.Info("completed reconcile node cleanup on branch ENIs", "NodeName", nodeName)
log.Info("completed reconcile node cleanup on branch ENIs", "nodeName", nodeName)

return foundLeakedENI
}
Expand Down Expand Up @@ -344,7 +344,7 @@ func (b *branchENIProvider) CreateAndAnnotateResources(podNamespace string, podN
"Security Groups %v", securityGroups), v1.EventTypeNormal)
}

log := b.log.WithValues("pod namespace", pod.Namespace, "pod name", pod.Name, "node name", pod.Spec.NodeName)
log := b.log.WithValues("pod namespace", pod.Namespace, "pod name", pod.Name, "nodeName", pod.Spec.NodeName)

start := time.Now()
trunkENI, isPresent := b.getTrunkFromCache(pod.Spec.NodeName)
Expand Down Expand Up @@ -406,7 +406,7 @@ func (b *branchENIProvider) DeleteBranchUsedByPods(nodeName string, UID string)
// trunk cache is local map with lock. it shouldn't return not found error if trunk exists
// if the node's trunk is not found, we shouldn't retry
// worst case we rely on node based clean up goroutines to clean branch ENIs up
b.log.Info("failed to find trunk ENI for the node %s", nodeName)
b.log.Info("failed to find trunk ENI for the node", "nodeName", nodeName)
return ctrl.Result{}, nil
}

Expand Down

0 comments on commit c80fd41

Please sign in to comment.