@@ -689,15 +689,12 @@ func (dsc *ReconcileDaemonSet) syncNodes(ds *appsv1alpha1.DaemonSet, podsToDelet
689
689
690
690
err = dsc .podControl .CreatePods (ds .Namespace , podTemplate , ds , metav1 .NewControllerRef (ds , controllerKind ))
691
691
692
- if err != nil && errors .IsTimeout (err ) {
693
- // Pod is created but its initialization has timed out.
694
- // If the initialization is successful eventually, the
695
- // controller will observe the creation via the informer.
696
- // If the initialization fails, or if the pod keeps
697
- // uninitialized for a long time, the informer will not
698
- // receive any update, and the controller will create a new
699
- // pod when the expectation expires.
700
- return
692
+ if err != nil {
693
+ if errors .HasStatusCause (err , corev1 .NamespaceTerminatingCause ) {
694
+ // If the namespace is being torn down, we can safely ignore
695
+ // this error since all subsequent creations will fail.
696
+ return
697
+ }
701
698
}
702
699
if err != nil {
703
700
klog .V (2 ).Infof ("Failed creation, decrementing expectations for set %q/%q" , ds .Namespace , ds .Name )
@@ -709,12 +706,10 @@ func (dsc *ReconcileDaemonSet) syncNodes(ds *appsv1alpha1.DaemonSet, podsToDelet
709
706
}
710
707
createWait .Wait ()
711
708
// any skipped pods that we never attempted to start shouldn't be expected.
712
- skippedPods := createDiff - batchSize
709
+ skippedPods := createDiff - ( batchSize + pos )
713
710
if errorCount < len (errCh ) && skippedPods > 0 {
714
711
klog .V (2 ).Infof ("Slow-start failure. Skipping creation of %d pods, decrementing expectations for set %q/%q" , skippedPods , ds .Namespace , ds .Name )
715
- for i := 0 ; i < skippedPods ; i ++ {
716
- dsc .expectations .CreationObserved (dsKey )
717
- }
712
+ dsc .expectations .LowerExpectations (dsKey , skippedPods , 0 )
718
713
// The skipped pods will be retried later. The next controller resync will
719
714
// retry the slow start process.
720
715
break
@@ -728,10 +723,12 @@ func (dsc *ReconcileDaemonSet) syncNodes(ds *appsv1alpha1.DaemonSet, podsToDelet
728
723
go func (ix int ) {
729
724
defer deleteWait .Done ()
730
725
if err := dsc .podControl .DeletePod (ds .Namespace , podsToDelete [ix ], ds ); err != nil {
731
- klog .V (2 ).Infof ("Failed deletion, decrementing expectations for set %q/%q" , ds .Namespace , ds .Name )
732
726
dsc .expectations .DeletionObserved (dsKey )
733
- errCh <- err
734
- utilruntime .HandleError (err )
727
+ if ! errors .IsNotFound (err ) {
728
+ klog .V (2 ).Infof ("Failed deletion, decremented expectations for set %q/%q" , ds .Namespace , ds .Name )
729
+ errCh <- err
730
+ utilruntime .HandleError (err )
731
+ }
735
732
}
736
733
}(i )
737
734
}
0 commit comments