Merge pull request #39157 from lukaszo/ds-generation
Automatic merge from submit-queue DaemonSet ObservedGeneration Extracting ObserverdGeneration part from #31693. It also implements #7328 for DaemonSets. cc @kargakis
This commit is contained in:
@@ -540,7 +540,8 @@ func storeDaemonSetStatus(dsClient unversionedextensions.DaemonSetInterface, ds
|
||||
if int(ds.Status.DesiredNumberScheduled) == desiredNumberScheduled &&
|
||||
int(ds.Status.CurrentNumberScheduled) == currentNumberScheduled &&
|
||||
int(ds.Status.NumberMisscheduled) == numberMisscheduled &&
|
||||
int(ds.Status.NumberReady) == numberReady {
|
||||
int(ds.Status.NumberReady) == numberReady &&
|
||||
ds.Status.ObservedGeneration >= ds.Generation {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -553,6 +554,7 @@ func storeDaemonSetStatus(dsClient unversionedextensions.DaemonSetInterface, ds
|
||||
|
||||
var updateErr, getErr error
|
||||
for i := 0; i < StatusUpdateRetries; i++ {
|
||||
toUpdate.Status.ObservedGeneration = ds.Generation
|
||||
toUpdate.Status.DesiredNumberScheduled = int32(desiredNumberScheduled)
|
||||
toUpdate.Status.CurrentNumberScheduled = int32(currentNumberScheduled)
|
||||
toUpdate.Status.NumberMisscheduled = int32(numberMisscheduled)
|
||||
|
@@ -609,3 +609,28 @@ func TestNumberReadyStatus(t *testing.T) {
|
||||
t.Errorf("Wrong daemon %s status: %v", updated.Name, updated.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservedGeneration(t *testing.T) {
|
||||
daemon := newDaemonSet("foo")
|
||||
daemon.Generation = 1
|
||||
manager, podControl, clientset := newTestController()
|
||||
var updated *extensions.DaemonSet
|
||||
clientset.PrependReactor("update", "daemonsets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||
if action.GetSubresource() != "status" {
|
||||
return false, nil, nil
|
||||
}
|
||||
if u, ok := action.(core.UpdateAction); ok {
|
||||
updated = u.GetObject().(*extensions.DaemonSet)
|
||||
}
|
||||
return false, nil, nil
|
||||
})
|
||||
|
||||
addNodes(manager.nodeStore.Store, 0, 1, simpleNodeLabel)
|
||||
addPods(manager.podStore.Indexer, "node-0", simpleDaemonSetLabel, 1)
|
||||
manager.dsStore.Add(daemon)
|
||||
|
||||
syncAndValidateDaemonSets(t, manager, daemon, podControl, 0, 0)
|
||||
if updated.Status.ObservedGeneration != daemon.Generation {
|
||||
t.Errorf("Wrong ObservedGeneration for daemon %s in status. Expected %d, got %d", updated.Name, daemon.Generation, updated.Status.ObservedGeneration)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user