// rollingUpdate identifies the set of old pods to delete, or additional pods to create on nodes, // remaining within the constraints imposed by the update strategy. func (dsc *DaemonSetsController) rollingUpdate(ctx context.Context, ds *apps.DaemonSet, nodeList []*v1.Node, hash string) error { … } // findUpdatedPodsOnNode looks at non-deleted pods on a given node and returns true if there // is at most one of each old and new pods, or false if there are multiples. We can skip // processing the particular node in those scenarios and let the manage loop prune the // excess pods for our next time around. func findUpdatedPodsOnNode(ds *apps.DaemonSet, podsOnNode []*v1.Pod, hash string) (newPod, oldPod *v1.Pod, ok bool) { … } // constructHistory finds all histories controlled by the given DaemonSet, and // update current history revision number, or create current history if need to. // It also deduplicates current history, and adds missing unique labels to existing histories. func (dsc *DaemonSetsController) constructHistory(ctx context.Context, ds *apps.DaemonSet) (cur *apps.ControllerRevision, old []*apps.ControllerRevision, err error) { … } func (dsc *DaemonSetsController) cleanupHistory(ctx context.Context, ds *apps.DaemonSet, old []*apps.ControllerRevision) error { … } // maxRevision returns the max revision number of the given list of histories func maxRevision(histories []*apps.ControllerRevision) int64 { … } func (dsc *DaemonSetsController) dedupCurHistories(ctx context.Context, ds *apps.DaemonSet, curHistories []*apps.ControllerRevision) (*apps.ControllerRevision, error) { … } // controlledHistories returns all ControllerRevisions controlled by the given DaemonSet. // This also reconciles ControllerRef by adopting/orphaning. // Note that returned histories are pointers to objects in the cache. // If you want to modify one, you need to deep-copy it first. func (dsc *DaemonSetsController) controlledHistories(ctx context.Context, ds *apps.DaemonSet) ([]*apps.ControllerRevision, error) { … } // Match check if the given DaemonSet's template matches the template stored in the given history. func Match(ds *apps.DaemonSet, history *apps.ControllerRevision) (bool, error) { … } // getPatch returns a strategic merge patch that can be applied to restore a Daemonset to a // previous version. If the returned error is nil the patch is valid. The current state that we save is just the // PodSpecTemplate. We can modify this later to encompass more state (or less) and remain compatible with previously // recorded patches. func getPatch(ds *apps.DaemonSet) ([]byte, error) { … } func (dsc *DaemonSetsController) snapshot(ctx context.Context, ds *apps.DaemonSet, revision int64) (*apps.ControllerRevision, error) { … } // updatedDesiredNodeCounts calculates the true number of allowed surge, unavailable or desired scheduled pods and // updates the nodeToDaemonPods array to include an empty array for every node that is not scheduled. func (dsc *DaemonSetsController) updatedDesiredNodeCounts(ctx context.Context, ds *apps.DaemonSet, nodeList []*v1.Node, nodeToDaemonPods map[string][]*v1.Pod) (int, int, int, error) { … } type historiesByRevision … func (h historiesByRevision) Len() int { … } func (h historiesByRevision) Swap(i, j int) { … } func (h historiesByRevision) Less(i, j int) bool { … }