Skip to content

Commit 9120379

Browse files
committed
fix ut
Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com>
1 parent 245f9f9 commit 9120379

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

pkg/controller/vpc_nat_gateway.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1
852852
annotations = maps.Clone(oldSts.Annotations)
853853
}
854854

855-
externalNadNamespace, externalNadName := c.getExternalSubnetNad(gw)
855+
externalNadNamespace, externalNadName, err := c.getExternalSubnetNad(gw)
856+
if err != nil {
857+
klog.Errorf("failed to get gw external subnet nad: %v", err)
858+
return nil, err
859+
}
856860

857861
eth0SubnetProvider, err := c.GetSubnetProvider(gw.Spec.Subnet)
858862
if err != nil {

pkg/controller/vpc_nat_gateway_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ func TestGetExternalSubnetNad(t *testing.T) {
185185
expectedName: "ovn-vpc-external-network",
186186
expectError: false,
187187
},
188+
{
189+
name: "empty provider (fallback to subnet name)",
190+
gw: &kubeovnv1.VpcNatGateway{
191+
ObjectMeta: metav1.ObjectMeta{Name: "test-gw"},
192+
Spec: kubeovnv1.VpcNatGatewaySpec{ExternalSubnets: []string{"my-external-subnet"}},
193+
},
194+
subnets: []*kubeovnv1.Subnet{
195+
{
196+
ObjectMeta: metav1.ObjectMeta{Name: "my-external-subnet"},
197+
Spec: kubeovnv1.SubnetSpec{Provider: ""},
198+
},
199+
},
200+
podNamespace: "kube-system",
201+
expectedNamespace: "kube-system",
202+
expectedName: "my-external-subnet",
203+
expectError: false,
204+
},
188205
{
189206
name: "empty ExternalSubnets (use default)",
190207
gw: &kubeovnv1.VpcNatGateway{

0 commit comments

Comments
 (0)