mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #82145 from shivi28/fix-controller-nodeipam-ipam-cidrset
nodeipam-controller:fix static check failures
This commit is contained in:
commit
75cd65ae0e
@ -11,7 +11,6 @@ pkg/controller/disruption
|
|||||||
pkg/controller/garbagecollector
|
pkg/controller/garbagecollector
|
||||||
pkg/controller/namespace/deletion
|
pkg/controller/namespace/deletion
|
||||||
pkg/controller/nodeipam
|
pkg/controller/nodeipam
|
||||||
pkg/controller/nodeipam/ipam/cidrset
|
|
||||||
pkg/controller/podautoscaler
|
pkg/controller/podautoscaler
|
||||||
pkg/controller/podgc
|
pkg/controller/podgc
|
||||||
pkg/controller/replicaset
|
pkg/controller/replicaset
|
||||||
|
@ -700,34 +700,39 @@ func TestCIDRSetv6(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
_, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr)
|
t.Run(tc.description, func(t *testing.T) {
|
||||||
a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize)
|
_, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr)
|
||||||
if err != nil {
|
a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize)
|
||||||
if tc.expectErr {
|
if gotErr := err != nil; gotErr != tc.expectErr {
|
||||||
continue
|
t.Fatalf("NewCIDRSet(%v, %v) = %v, %v; gotErr = %t, want %t", clusterCIDR, tc.subNetMaskSize, a, err, gotErr, tc.expectErr)
|
||||||
}
|
}
|
||||||
t.Fatalf("Error allocating CIDRSet for %v", tc.description)
|
if a == nil {
|
||||||
}
|
return
|
||||||
|
|
||||||
p, err := a.AllocateNext()
|
|
||||||
if err == nil && tc.expectErr {
|
|
||||||
t.Errorf("expected error but got none for %v", tc.description)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err != nil && !tc.expectErr {
|
|
||||||
t.Errorf("unexpected error: %v for %v", err, tc.description)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !tc.expectErr {
|
|
||||||
if p.String() != tc.expectedCIDR {
|
|
||||||
t.Fatalf("unexpected allocated cidr: %s for %v", p.String(), tc.description)
|
|
||||||
}
|
}
|
||||||
}
|
p, err := a.AllocateNext()
|
||||||
p2, err := a.AllocateNext()
|
if err == nil && tc.expectErr {
|
||||||
if !tc.expectErr {
|
t.Errorf("a.AllocateNext() = nil, want error")
|
||||||
if p2.String() != tc.expectedCIDR2 {
|
|
||||||
t.Fatalf("unexpected allocated cidr: %s for %v", p2.String(), tc.description)
|
|
||||||
}
|
}
|
||||||
}
|
if err != nil && !tc.expectErr {
|
||||||
|
t.Errorf("a.AllocateNext() = %+v, want no error", err)
|
||||||
|
}
|
||||||
|
if !tc.expectErr {
|
||||||
|
if p != nil && p.String() != tc.expectedCIDR {
|
||||||
|
t.Fatalf("a.AllocateNext() got %+v, want %+v", p.String(), tc.expectedCIDR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p2, err := a.AllocateNext()
|
||||||
|
if err == nil && tc.expectErr {
|
||||||
|
t.Errorf("a.AllocateNext() = nil, want error")
|
||||||
|
}
|
||||||
|
if err != nil && !tc.expectErr {
|
||||||
|
t.Errorf("a.AllocateNext() = %+v, want no error", err)
|
||||||
|
}
|
||||||
|
if !tc.expectErr {
|
||||||
|
if p2 != nil && p2.String() != tc.expectedCIDR2 {
|
||||||
|
t.Fatalf("a.AllocateNext() got %+v, want %+v", p2.String(), tc.expectedCIDR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user