Skip to content

Commit

Permalink
TIL: Pod deletion timestamps include the grace period
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Feb 13, 2025
1 parent 6f0b917 commit 3f0fc86
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion controllers/node_force_drain_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ func (r *NodeForceDrainReconciler) forceDeletePodsOnNode(ctx context.Context, no
if pod.DeletionTimestamp == nil {
continue
}
timeUntilForceDelete := pod.DeletionTimestamp.Sub(r.Clock.Now()) + gracePeriod
// Pod deletion timestamp is in the future and includes the grace period.
podGracePeriod := time.Duration(ptr.Deref(pod.ObjectMeta.DeletionGracePeriodSeconds, 0)) * time.Second
timeUntilForceDelete := pod.DeletionTimestamp.Sub(r.Clock.Now()) - podGracePeriod + gracePeriod
if timeUntilForceDelete > 0 {
if timeUntilNextForceDelete == 0 || timeUntilForceDelete < timeUntilNextForceDelete {
timeUntilNextForceDelete = timeUntilForceDelete
Expand Down

0 comments on commit 3f0fc86

Please sign in to comment.