Merge pull request #47075 from janetkuo/ds-history-patch
Automatic merge from submit-queue Change what is stored in DaemonSet history `.data` **What this PR does / why we need it**: In DaemonSet history `.data`, store a strategic merge patch that can be applied to restore a DaemonSet. Only PodSpecTemplate is saved. This will become consistent with the data stored in StatefulSet history. Before this fix, a serialized pod template is stored in `.data`; however, seriazlized pod template isn't a `runtime.RawExtension`, and caused problems when controllers try to patch the history's controller ref. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47008 **Special notes for your reviewer**: @kubernetes/sig-apps-bugs @erictune @kow3ns @kargakis @lukaszo @mengqiy **Release note**: ```release-note NONE ```
This commit is contained in:
@@ -268,7 +268,7 @@ var _ = framework.KubeDescribe("Daemon set [Serial]", func() {
|
||||
// Check history and labels
|
||||
ds, err = c.Extensions().DaemonSets(ns).Get(ds.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
first := curHistory(listDaemonHistories(c, ns, label), &ds.Spec.Template)
|
||||
first := curHistory(listDaemonHistories(c, ns, label), ds)
|
||||
firstHash := ds.Labels[extensions.DefaultDaemonSetUniqueLabelKey]
|
||||
Expect(first.Labels[extensions.DefaultDaemonSetUniqueLabelKey]).To(Equal(firstHash))
|
||||
Expect(first.Revision).To(Equal(int64(1)))
|
||||
@@ -295,7 +295,7 @@ var _ = framework.KubeDescribe("Daemon set [Serial]", func() {
|
||||
// Check history and labels
|
||||
ds, err = c.Extensions().DaemonSets(ns).Get(ds.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
cur := curHistory(listDaemonHistories(c, ns, label), &ds.Spec.Template)
|
||||
cur := curHistory(listDaemonHistories(c, ns, label), ds)
|
||||
curHash := ds.Labels[extensions.DefaultDaemonSetUniqueLabelKey]
|
||||
Expect(cur.Labels[extensions.DefaultDaemonSetUniqueLabelKey]).To(Equal(curHash))
|
||||
Expect(cur.Revision).To(Equal(int64(2)))
|
||||
@@ -325,7 +325,7 @@ var _ = framework.KubeDescribe("Daemon set [Serial]", func() {
|
||||
// Check history and labels
|
||||
ds, err = c.Extensions().DaemonSets(ns).Get(ds.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
cur := curHistory(listDaemonHistories(c, ns, label), &ds.Spec.Template)
|
||||
cur := curHistory(listDaemonHistories(c, ns, label), ds)
|
||||
hash := ds.Labels[extensions.DefaultDaemonSetUniqueLabelKey]
|
||||
Expect(cur.Labels[extensions.DefaultDaemonSetUniqueLabelKey]).To(Equal(hash))
|
||||
Expect(cur.Revision).To(Equal(int64(1)))
|
||||
@@ -353,7 +353,7 @@ var _ = framework.KubeDescribe("Daemon set [Serial]", func() {
|
||||
// Check history and labels
|
||||
ds, err = c.Extensions().DaemonSets(ns).Get(ds.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
cur = curHistory(listDaemonHistories(c, ns, label), &ds.Spec.Template)
|
||||
cur = curHistory(listDaemonHistories(c, ns, label), ds)
|
||||
hash = ds.Labels[extensions.DefaultDaemonSetUniqueLabelKey]
|
||||
Expect(cur.Labels[extensions.DefaultDaemonSetUniqueLabelKey]).To(Equal(hash))
|
||||
Expect(cur.Revision).To(Equal(int64(2)))
|
||||
@@ -760,14 +760,14 @@ func listDaemonHistories(c clientset.Interface, ns string, label map[string]stri
|
||||
return historyList
|
||||
}
|
||||
|
||||
func curHistory(historyList *apps.ControllerRevisionList, template *v1.PodTemplateSpec) *apps.ControllerRevision {
|
||||
func curHistory(historyList *apps.ControllerRevisionList, ds *extensions.DaemonSet) *apps.ControllerRevision {
|
||||
var curHistory *apps.ControllerRevision
|
||||
foundCurHistories := 0
|
||||
for i := range historyList.Items {
|
||||
history := &historyList.Items[i]
|
||||
// Every history should have the hash label
|
||||
Expect(len(history.Labels[extensions.DefaultDaemonSetUniqueLabelKey])).To(BeNumerically(">", 0))
|
||||
match, err := daemon.Match(template, history)
|
||||
match, err := daemon.Match(ds, history)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if match {
|
||||
curHistory = history
|
||||
|
Reference in New Issue
Block a user