kubeadm: fix diff order and add test for new default value manifest

This commit is contained in:
Paco Xu 2023-09-10 19:44:20 +08:00
parent 0ee315b94c
commit 912041ce41
2 changed files with 23 additions and 1 deletions

View File

@ -372,7 +372,7 @@ func ManifestFilesAreEqual(path1, path2 string) (bool, error) {
if bytes.Equal(hash1, hash2) {
return true, nil
}
klog.V(4).Infof("Pod manifest files diff:\n%s\n", cmp.Diff(pod1, pod2))
klog.V(4).Infof("Pod manifest files diff:\n%s\n", cmp.Diff(pod2, pod1))
return false, nil
}

View File

@ -652,6 +652,22 @@ spec:
- image: gcr.io/google_containers/etcd-amd64:3.1.11
status: {}
`
invalidWithDefaultFields = `
apiVersion: v1
kind: Pod
metadata:
labels:
tier: control-plane
component: etcd
name: etcd
namespace: kube-system
spec:
containers:
- image: gcr.io/google_containers/etcd-amd64:3.1.11
restartPolicy: "Always"
status: {}
`
validPod2 = `
apiVersion: v1
kind: Pod
@ -749,6 +765,12 @@ func TestManifestFilesAreEqual(t *testing.T) {
expectedResult: false,
expectErr: false,
},
{
description: "manifests are not equal for adding new defaults",
podYamls: []string{validPod, invalidWithDefaultFields},
expectedResult: false,
expectErr: false,
},
{
description: "first manifest doesn't exist",
podYamls: []string{validPod, ""},