mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
AllowExpandedDNSConfig if haveSameExpandedDNSConfig(newPod, oldPod)
This commit is contained in:
@@ -1474,6 +1474,365 @@ func TestValidatePodDeletionCostOption(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHaveSameExpandedDNSConfig(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
podSpec *api.PodSpec
|
||||
oldPodSpec *api.PodSpec
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
desc: "nil DNSConfig",
|
||||
podSpec: &api.PodSpec{},
|
||||
oldPodSpec: &api.PodSpec{},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "empty DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "same legacy DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "update legacy DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"baz.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "same expanded DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"7.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"7.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
desc: "update expanded DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"baz.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"7.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "update to legacy DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"baz.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"7.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
desc: "update to expanded DNSConfig",
|
||||
podSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
"baz.expanded.com",
|
||||
"8.expanded.com",
|
||||
"9.expanded.com",
|
||||
"10.expanded.com",
|
||||
"11.expanded.com",
|
||||
"12.expanded.com",
|
||||
"13.expanded.com",
|
||||
"14.expanded.com",
|
||||
"15.expanded.com",
|
||||
"16.expanded.com",
|
||||
"17.expanded.com",
|
||||
"18.expanded.com",
|
||||
"19.expanded.com",
|
||||
"20.expanded.com",
|
||||
"21.expanded.com",
|
||||
"22.expanded.com",
|
||||
"23.expanded.com",
|
||||
"24.expanded.com",
|
||||
"25.expanded.com",
|
||||
"26.expanded.com",
|
||||
"27.expanded.com",
|
||||
"28.expanded.com",
|
||||
"29.expanded.com",
|
||||
"30.expanded.com",
|
||||
"31.expanded.com",
|
||||
"32.expanded.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
oldPodSpec: &api.PodSpec{
|
||||
DNSConfig: &api.PodDNSConfig{
|
||||
Searches: []string{
|
||||
"foo.com",
|
||||
"bar.io",
|
||||
"3.com",
|
||||
"4.com",
|
||||
"5.com",
|
||||
"6.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got := haveSameExpandedDNSConfig(tc.podSpec, tc.oldPodSpec)
|
||||
if tc.want != got {
|
||||
t.Errorf("unexpected diff, want: %v, got: %v", tc.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDropDisabledPodAffinityTermFields(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user