Skip to content

Commit

Permalink
Add logging for unexpected pod eviction errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dewjam committed Mar 1, 2022
1 parent 82ea63b commit 54defc4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/controllers/termination/eviction.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (e *EvictionQueue) Start(ctx context.Context) {
nn := item.(types.NamespacedName)
// Evict pod
if e.evict(ctx, nn) {
logging.FromContext(ctx).Debugf("Evicted pod %s", nn.String())
logging.FromContext(ctx).Debugf("Evicted pod %s", nn)
e.RateLimitingInterface.Forget(nn)
e.Set.Remove(nn)
e.RateLimitingInterface.Done(nn)
Expand All @@ -83,7 +83,7 @@ func (e *EvictionQueue) Start(ctx context.Context) {
// Requeue pod if eviction failed
e.RateLimitingInterface.AddRateLimited(nn)
}
logging.FromContext(ctx).Errorf("EvictionQueue is broken and has shutdown.")
logging.FromContext(ctx).Errorf("EvictionQueue is broken and has shutdown")
}

// evict returns true if successful eviction call, error is returned if not eviction-related error
Expand All @@ -92,17 +92,18 @@ func (e *EvictionQueue) evict(ctx context.Context, nn types.NamespacedName) bool
ObjectMeta: metav1.ObjectMeta{Name: nn.Name, Namespace: nn.Namespace},
})
if errors.IsInternalError(err) { // 500
logging.FromContext(ctx).Errorf("Could not evict pod %s due to PDB misconfiguration error.", nn.String())
logging.FromContext(ctx).Errorf("Could not evict pod %s due to PDB misconfiguration error", nn)
return false
}
if errors.IsTooManyRequests(err) { // 429
logging.FromContext(ctx).Debugf("Did not evict pod %s due to PDB violation.", nn.String())
logging.FromContext(ctx).Errorf("Did not evict pod %s due to PDB violation", nn)
return false
}
if errors.IsNotFound(err) { // 404
return true
}
if err != nil {
logging.FromContext(ctx).Errorf("Could not evict pod %s, %s", nn, err)
return false
}
return true
Expand Down

0 comments on commit 54defc4

Please sign in to comment.