diff --git a/pkg/aliyun/client/ecs_options.go b/pkg/aliyun/client/ecs_options.go index 2714172a..92fd3b60 100644 --- a/pkg/aliyun/client/ecs_options.go +++ b/pkg/aliyun/client/ecs_options.go @@ -58,11 +58,11 @@ func (c *CreateNetworkInterfaceOptions) ApplyCreateNetworkInterface(options *Cre if c.NetworkInterfaceOptions.SecurityGroupIDs != nil { options.NetworkInterfaceOptions.SecurityGroupIDs = c.NetworkInterfaceOptions.SecurityGroupIDs } - if c.NetworkInterfaceOptions.IPCount > 1 { + if c.NetworkInterfaceOptions.IPCount >= 1 { options.NetworkInterfaceOptions.IPCount = c.NetworkInterfaceOptions.IPCount } - if c.NetworkInterfaceOptions.IPv6Count > 1 { + if c.NetworkInterfaceOptions.IPv6Count >= 1 { options.NetworkInterfaceOptions.IPv6Count = c.NetworkInterfaceOptions.IPv6Count } if c.NetworkInterfaceOptions.Tags != nil { diff --git a/pkg/aliyun/client/ecs_options_test.go b/pkg/aliyun/client/ecs_options_test.go index f5ab2f71..487b2171 100644 --- a/pkg/aliyun/client/ecs_options_test.go +++ b/pkg/aliyun/client/ecs_options_test.go @@ -3,6 +3,7 @@ package client import ( "testing" + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/util/wait" ) @@ -56,6 +57,8 @@ func TestCreateNetworkInterfaceOptions_Finish(t *testing.T) { assert.Equal(t, niOptions.ResourceGroupID, req.ResourceGroupId) assert.Equal(t, eniDescription, req.Description) assert.Equal(t, "mockToken", req.ClientToken) + assert.Equal(t, requests.NewInteger(1), req.SecondaryPrivateIpAddressCount) + assert.Equal(t, requests.NewInteger(1), req.Ipv6AddressCount) assert.NotNil(t, c.Backoff) // Cleanup @@ -87,6 +90,7 @@ func TestCreateNetworkInterfaceOptions_ApplyCreateNetworkInterface(t *testing.T) Trunk: true, ERDMA: true, IPCount: 2, + IPv6Count: 1, }, }, args: args{ @@ -102,7 +106,7 @@ func TestCreateNetworkInterfaceOptions_ApplyCreateNetworkInterface(t *testing.T) SecurityGroupIDs: []string{"sg-xxxxxx"}, ResourceGroupID: "rg-xxxxxx", IPCount: 2, - IPv6Count: 0, + IPv6Count: 1, Tags: map[string]string{"key1": "value1", "key2": "value2"}, InstanceID: "", InstanceType: "",