Skip to content

Commit

Permalink
Merge pull request #2576 from Icarus9913/feat/wk/crd-vlan-remove
Browse files Browse the repository at this point in the history
remove crd subnet/ippool deprecated property vlan default value
  • Loading branch information
cyclinder committed Nov 8, 2023
2 parents 288bd86 + aa1037c commit 0f94b2b
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ spec:
subnet:
type: string
vlan:
default: 0
description: 'DEPRECATED: Vlan is deprecated.'
format: int64
maximum: 4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ spec:
subnet:
type: string
vlan:
default: 0
description: 'DEPRECATED: Vlan is deprecated.'
format: int64
maximum: 4094
Expand Down
5 changes: 0 additions & 5 deletions pkg/ippoolmanager/ippool_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() {
ipVersion := constant.IPv4
allocatedIP := "172.18.40.40/24"
gateway := "172.18.40.1"
vlan := int64(0)

ip, ipNet, err := net.ParseCIDR(allocatedIP)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -351,7 +350,6 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() {
ipPoolT.Spec.Subnet = ipNet.String()
ipPoolT.Spec.IPs = append(ipPoolT.Spec.IPs, ip.String())
ipPoolT.Spec.Gateway = pointer.String(gateway)
ipPoolT.Spec.Vlan = pointer.Int64(vlan)

err = fakeClient.Create(ctx, ipPoolT)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -365,7 +363,6 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() {
Expect(*res.Address).To(Equal(allocatedIP))
Expect(res.IPPool).To(Equal(ipPoolT.Name))
Expect(res.Gateway).To(Equal(gateway))
Expect(res.Vlan).To(Equal(vlan))
})

It("allocate IP address with kubevirt vm pod", func() {
Expand All @@ -386,7 +383,6 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() {
ipPoolT.Spec.Subnet = ipNet.String()
ipPoolT.Spec.IPs = append(ipPoolT.Spec.IPs, ip.String())
ipPoolT.Spec.Gateway = pointer.String(gateway)
ipPoolT.Spec.Vlan = pointer.Int64(vlan)

err = fakeClient.Create(ctx, ipPoolT)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -431,7 +427,6 @@ var _ = Describe("IPPoolManager", Label("ippool_manager_test"), func() {
ipPoolT.Spec.Subnet = ipNet.String()
ipPoolT.Spec.IPs = append(ipPoolT.Spec.IPs, ip.String())
ipPoolT.Spec.Gateway = pointer.String(gateway)
ipPoolT.Spec.Vlan = pointer.Int64(vlan)

key, err := cache.MetaNamespaceKeyFunc(podT)
Expect(err).NotTo(HaveOccurred())
Expand Down
6 changes: 0 additions & 6 deletions pkg/ippoolmanager/ippool_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
)

subnetT.Spec.Gateway = pointer.String("172.18.50.0")
subnetT.Spec.Vlan = pointer.Int64(50)
subnetT.Spec.Routes = []spiderpoolv2beta1.Route{
{
Dst: "0.0.0.0/0",
Expand All @@ -565,7 +564,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
Expect(v).To(Equal(subnetName))

Expect(ipPoolT.Spec.Gateway).To(Equal(subnetT.Spec.Gateway))
Expect(ipPoolT.Spec.Vlan).To(Equal(subnetT.Spec.Vlan))
Expect(ipPoolT.Spec.Routes).To(Equal(subnetT.Spec.Routes))
})
})
Expand Down Expand Up @@ -1317,7 +1315,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
)
ipPoolT.Spec.ExcludeIPs = append(ipPoolT.Spec.ExcludeIPs, "172.18.40.10")
ipPoolT.Spec.Gateway = pointer.String("172.18.40.1")
ipPoolT.Spec.Vlan = pointer.Int64(0)
ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes,
spiderpoolv2beta1.Route{
Dst: "192.168.40.0/24",
Expand Down Expand Up @@ -1359,7 +1356,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
)
ipPoolT.Spec.ExcludeIPs = append(ipPoolT.Spec.ExcludeIPs, "abcd:1234::a")
ipPoolT.Spec.Gateway = pointer.String("abcd:1234::1")
ipPoolT.Spec.Vlan = pointer.Int64(0)
ipPoolT.Spec.Routes = append(ipPoolT.Spec.Routes,
spiderpoolv2beta1.Route{
Dst: "fd00:40::/120",
Expand Down Expand Up @@ -2095,7 +2091,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
ipPoolT.Spec.IPVersion = pointer.Int64(constant.IPv4)
ipPoolT.Spec.Subnet = "172.18.40.0/24"
ipPoolT.Spec.IPs = append(ipPoolT.Spec.IPs, "172.18.40.2-172.18.40.3")
ipPoolT.Spec.Vlan = pointer.Int64(0)

newIPPoolT := ipPoolT.DeepCopy()
newIPPoolT.Spec.IPs = append(newIPPoolT.Spec.IPs, "172.18.40.10")
Expand Down Expand Up @@ -2134,7 +2129,6 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
ipPoolT.Spec.IPVersion = pointer.Int64(constant.IPv6)
ipPoolT.Spec.Subnet = "abcd:1234::/120"
ipPoolT.Spec.IPs = append(ipPoolT.Spec.IPs, "abcd:1234::2-abcd:1234::3")
ipPoolT.Spec.Vlan = pointer.Int64(0)

newIPPoolT := ipPoolT.DeepCopy()
newIPPoolT.Spec.IPs = append(newIPPoolT.Spec.IPs, "abcd:1234::a")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type IPPoolSpec struct {
Gateway *string `json:"gateway,omitempty"`

// DEPRECATED: Vlan is deprecated.
// +kubebuilder:default=0
// +kubebuilder:validation:Maximum=4094
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type SubnetSpec struct {
Gateway *string `json:"gateway,omitempty"`

// DEPRECATED: Vlan is deprecated.
// +kubebuilder:default=0
// +kubebuilder:validation:Maximum=4094
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Optional
Expand Down
8 changes: 4 additions & 4 deletions pkg/subnetmanager/subnet_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpo
Name: applicationinformers.AutoPoolName(podController.Name, autoPoolProperty.IPVersion, autoPoolProperty.IfName, podController.UID),
},
Spec: spiderpoolv2beta1.IPPoolSpec{
IPVersion: pointer.Int64(autoPoolProperty.IPVersion),
Subnet: subnet.Spec.Subnet,
Gateway: subnet.Spec.Gateway,
Vlan: subnet.Spec.Vlan,
IPVersion: pointer.Int64(autoPoolProperty.IPVersion),
Subnet: subnet.Spec.Subnet,
Gateway: subnet.Spec.Gateway,
//Vlan: subnet.Spec.Vlan,
Routes: subnet.Spec.Routes,
PodAffinity: ippoolmanager.NewAutoPoolPodAffinity(podController),
},
Expand Down
4 changes: 0 additions & 4 deletions pkg/subnetmanager/subnet_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() {
)
subnetT.Spec.ExcludeIPs = append(subnetT.Spec.ExcludeIPs, "172.18.40.10")
subnetT.Spec.Gateway = pointer.String("172.18.40.1")
subnetT.Spec.Vlan = pointer.Int64(0)
subnetT.Spec.Routes = append(subnetT.Spec.Routes,
spiderpoolv2beta1.Route{
Dst: "192.168.40.0/24",
Expand All @@ -884,7 +883,6 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() {
)
subnetT.Spec.ExcludeIPs = append(subnetT.Spec.ExcludeIPs, "abcd:1234::a")
subnetT.Spec.Gateway = pointer.String("abcd:1234::1")
subnetT.Spec.Vlan = pointer.Int64(0)
subnetT.Spec.Routes = append(subnetT.Spec.Routes,
spiderpoolv2beta1.Route{
Dst: "fd00:40::/120",
Expand Down Expand Up @@ -1445,7 +1443,6 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() {
subnetT.Spec.IPVersion = pointer.Int64(constant.IPv4)
subnetT.Spec.Subnet = "172.18.40.0/24"
subnetT.Spec.IPs = append(subnetT.Spec.IPs, "172.18.40.2-172.18.40.3")
subnetT.Spec.Vlan = pointer.Int64(0)

newSubnetT := subnetT.DeepCopy()
newSubnetT.Spec.IPs = append(newSubnetT.Spec.IPs, "172.18.40.10")
Expand All @@ -1467,7 +1464,6 @@ var _ = Describe("SubnetWebhook", Label("subnet_webhook_test"), func() {
subnetT.Spec.IPVersion = pointer.Int64(constant.IPv6)
subnetT.Spec.Subnet = "abcd:1234::/120"
subnetT.Spec.IPs = append(subnetT.Spec.IPs, "abcd:1234::2-abcd:1234::3")
subnetT.Spec.Vlan = pointer.Int64(0)

newSubnetT := subnetT.DeepCopy()
newSubnetT.Spec.IPs = append(newSubnetT.Spec.IPs, "abcd:1234::a")
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func GenIPConfigResult(allocateIP net.IP, nic string, ipPool *spiderpoolv2beta1.
IPPool: ipPool.Name,
Nic: &nic,
Version: ipPool.Spec.IPVersion,
Vlan: *ipPool.Spec.Vlan,
//Vlan: *ipPool.Spec.Vlan,
}
}

Expand Down
6 changes: 0 additions & 6 deletions test/e2e/annotation/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,9 @@ var _ = Describe("test annotation", Label("annotation"), func() {
var (
v4PoolName, v6PoolName string
iPv4PoolObj, iPv6PoolObj *spiderpool.SpiderIPPool
ipv4vlan, ipv6vlan = new(types.Vlan), new(types.Vlan)
err error
ipNum int = 2
)
// Different VLAN for ipv4 and ipv6 Pool
*ipv4vlan = 10
*ipv6vlan = 20

// The case relies on a Dual-stack
if !frame.Info.IpV6Enabled || !frame.Info.IpV4Enabled {
Expand All @@ -211,7 +207,6 @@ var _ = Describe("test annotation", Label("annotation"), func() {

// Create IPv4Pool and IPv6Pool
v4PoolName, iPv4PoolObj = common.GenerateExampleIpv4poolObject(ipNum)
iPv4PoolObj.Spec.Vlan = ipv4vlan
GinkgoWriter.Printf("try to create ipv4pool: %v \n", v4PoolName)
if frame.Info.SpiderSubnetEnabled {
ctx, cancel := context.WithTimeout(context.Background(), common.PodStartTimeout)
Expand All @@ -223,7 +218,6 @@ var _ = Describe("test annotation", Label("annotation"), func() {
Expect(err).NotTo(HaveOccurred(), "failed to create ipv4pool %v \n", v4PoolName)

v6PoolName, iPv6PoolObj = common.GenerateExampleIpv6poolObject(ipNum)
iPv6PoolObj.Spec.Vlan = ipv6vlan
GinkgoWriter.Printf("try to create ipv6pool: %v \n", v6PoolName)
if frame.Info.SpiderSubnetEnabled {
ctx, cancel := context.WithTimeout(context.Background(), common.PodStartTimeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
v4PoolName, v4PoolObj = common.GenerateExampleIpv4poolObject(1)
v4PoolObj.Spec.Subnet = spiderPoolIPv4SubnetVlan200.Spec.Subnet
v4PoolObj.Spec.Gateway = spiderPoolIPv4SubnetVlan200.Spec.Gateway
v4PoolObj.Spec.Vlan = spiderPoolIPv4SubnetVlan200.Spec.Vlan

// Do not use the gateway address as the conflicting ip, and the use case will remove the IP address in the subsequent steps.
// If the gateway address is removed, it will affect the connectivity of other use cases.
Expand Down Expand Up @@ -558,7 +557,6 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
v6PoolName, v6PoolObj = common.GenerateExampleIpv6poolObject(1)
v6PoolObj.Spec.Subnet = spiderPoolIPv6SubnetVlan200.Spec.Subnet
v6PoolObj.Spec.Gateway = spiderPoolIPv6SubnetVlan200.Spec.Gateway
v6PoolObj.Spec.Vlan = spiderPoolIPv6SubnetVlan200.Spec.Vlan
// Do not use the gateway address as the conflicting ip, and the use case will remove the IP address in the subsequent steps.
// If the gateway address is removed, it will affect the connectivity of other use cases.
var v6RandNum int
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/ifacer/ifacer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {
defer cancel()
if frame.Info.IpV4Enabled {
v4PoolName, iPv4PoolObj = common.GenerateExampleIpv4poolObject(1)
iPv4PoolObj.Spec.Vlan = pointer.Int64(int64(vlanInterface))
if frame.Info.SpiderSubnetEnabled {
v4SubnetName, v4SubnetObject = common.GenerateExampleV4SubnetObject(frame, len(frame.Info.KindNodeList))
Expect(v4SubnetObject).NotTo(BeNil())
Expand All @@ -54,7 +53,6 @@ var _ = Describe("test ifacer", Label("ifacer"), func() {

if frame.Info.IpV6Enabled {
v6PoolName, iPv6PoolObj = common.GenerateExampleIpv6poolObject(len(frame.Info.KindNodeList))
iPv6PoolObj.Spec.Vlan = pointer.Int64(int64(vlanInterface))
if frame.Info.SpiderSubnetEnabled {
v6SubnetName, v6SubnetObject = common.GenerateExampleV6SubnetObject(frame, len(frame.Info.KindNodeList))
Expect(v6SubnetObject).NotTo(BeNil())
Expand Down
15 changes: 0 additions & 15 deletions test/e2e/subnet/subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {

It("valid fields succeed to create subnet. ", Label("I00001", "I00002", "I00005"), func() {
var v4Ipversion, v6Ipversion = new(types.IPVersion), new(types.IPVersion)
var ipv4Vlan, ipv6Vlan = new(types.Vlan), new(types.Vlan)
var v4Object, v6Object *spiderpool.SpiderSubnet
var v4RouteValue, v6RouteValue []spiderpool.Route

Expand All @@ -519,17 +518,13 @@ var _ = Describe("test subnet", Label("subnet"), func() {
subnetAnno := types.AnnoSubnetItem{}
if frame.Info.IpV4Enabled {
*v4Ipversion = int64(4)
if i, err := strconv.Atoi(common.GenerateRandomNumber(4094)); err != nil {
*ipv4Vlan = int64(i)
}
subnetAnno.IPv4 = []string{v4SubnetName}
v4RouteValue = []spiderpool.Route{
{
Dst: v4Dst,
Gw: ipv4Gw,
},
}
v4SubnetObject.Spec.Vlan = ipv4Vlan
v4SubnetObject.Spec.Routes = v4RouteValue
v4SubnetObject.Spec.Gateway = &ipv4Gw
GinkgoWriter.Printf("Specify routes, gateways, etc. and then create subnets %v \n", v4SubnetName)
Expand All @@ -538,25 +533,20 @@ var _ = Describe("test subnet", Label("subnet"), func() {
v4Object, err = common.GetSubnetByName(frame, v4SubnetName)
Expect(err).NotTo(HaveOccurred())
Expect(v4Object.Spec.IPVersion).To(Equal(v4Ipversion))
Expect(v4Object.Spec.Vlan).To(Equal(ipv4Vlan))
Expect(v4Object.Spec.Routes[0].Dst).To(Equal(v4Dst))
Expect(v4Object.Spec.Routes[0].Gw).To(Equal(ipv4Gw))
Expect(v4Object.Spec.Gateway).To(Equal(&ipv4Gw))
}

if frame.Info.IpV6Enabled {
*v6Ipversion = int64(6)
if i, err := strconv.Atoi(common.GenerateRandomNumber(4094)); err != nil {
*ipv6Vlan = int64(i)
}
subnetAnno.IPv6 = []string{v6SubnetName}
v6RouteValue = []spiderpool.Route{
{
Dst: v6Dst,
Gw: ipv6Gw,
},
}
v6SubnetObject.Spec.Vlan = ipv6Vlan
v6SubnetObject.Spec.Routes = v6RouteValue
v6SubnetObject.Spec.Gateway = &ipv6Gw
GinkgoWriter.Printf("Specify routes, gateways, etc. and then create subnets %v \n", v6SubnetName)
Expand All @@ -565,7 +555,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {
v6Object, err = common.GetSubnetByName(frame, v6SubnetName)
Expect(err).NotTo(HaveOccurred())
Expect(v6Object.Spec.IPVersion).To(Equal(v6Ipversion))
Expect(v6Object.Spec.Vlan).To(Equal(ipv6Vlan))
Expect(v6Object.Spec.Routes[0].Dst).To(Equal(v6Dst))
Expect(v6Object.Spec.Routes[0].Gw).To(Equal(ipv6Gw))
Expect(v6Object.Spec.Gateway).To(Equal(&ipv6Gw))
Expand Down Expand Up @@ -595,7 +584,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {
v4poolList, err := common.GetIppoolsInSubnet(frame, v4SubnetName)
Expect(err).NotTo(HaveOccurred())
for _, pool := range v4poolList.Items {
Expect(pool.Spec.Vlan).To(Equal(ipv4Vlan))
Expect(pool.Spec.Routes[0].Dst).To(Equal(v4Dst))
Expect(pool.Spec.Routes[0].Gw).To(Equal(ipv4Gw))
Expect(pool.Spec.Gateway).To(Equal(&ipv4Gw))
Expand Down Expand Up @@ -674,7 +662,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {
GinkgoWriter.Println("Older pools are not affected.")
for _, pool := range v4poolList.Items {
if pool.Name != v4PoolName {
Expect(pool.Spec.Vlan).To(Equal(ipv4Vlan))
Expect(pool.Spec.Routes[0].Dst).To(Equal(v4Dst))
Expect(pool.Spec.Routes[0].Gw).To(Equal(ipv4Gw))
Expect(pool.Spec.Gateway).To(Equal(&ipv4Gw))
Expand All @@ -691,7 +678,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {
v6poolList, err := common.GetIppoolsInSubnet(frame, v6SubnetName)
Expect(err).NotTo(HaveOccurred())
for _, pool := range v6poolList.Items {
Expect(pool.Spec.Vlan).To(Equal(ipv6Vlan))
Expect(pool.Spec.Routes[0].Dst).To(Equal(v6Dst))
Expect(pool.Spec.Routes[0].Gw).To(Equal(ipv6Gw))
Expect(pool.Spec.Gateway).To(Equal(&ipv6Gw))
Expand Down Expand Up @@ -770,7 +756,6 @@ var _ = Describe("test subnet", Label("subnet"), func() {
GinkgoWriter.Println("Older pools are not affected.")
for _, pool := range v6poolList.Items {
if pool.Name != v6PoolName {
Expect(pool.Spec.Vlan).To(Equal(ipv6Vlan))
Expect(pool.Spec.Routes[0].Dst).To(Equal(v6Dst))
Expect(pool.Spec.Routes[0].Gw).To(Equal(ipv6Gw))
Expect(pool.Spec.Gateway).To(Equal(&ipv6Gw))
Expand Down

0 comments on commit 0f94b2b

Please sign in to comment.