diff --git a/cmd/spiderpool-agent/cmd/config.go b/cmd/spiderpool-agent/cmd/config.go index ca1d758ac2..3e07a0765f 100644 --- a/cmd/spiderpool-agent/cmd/config.go +++ b/cmd/spiderpool-agent/cmd/config.go @@ -91,17 +91,13 @@ type Config struct { MultusClusterNetwork string // configmap - IpamUnixSocketPath string `yaml:"ipamUnixSocketPath"` - EnableIPv4 bool `yaml:"enableIPv4"` - EnableIPv6 bool `yaml:"enableIPv6"` - EnableStatefulSet bool `yaml:"enableStatefulSet"` - EnableKubevirtStaticIP bool `yaml:"enableKubevirtStaticIP"` - EnableSpiderSubnet bool `yaml:"enableSpiderSubnet"` - ClusterDefaultIPv4IPPool []string `yaml:"clusterDefaultIPv4IPPool"` - ClusterDefaultIPv6IPPool []string `yaml:"clusterDefaultIPv6IPPool"` - ClusterDefaultIPv4Subnet []string `yaml:"clusterDefaultIPv4Subnet"` - ClusterDefaultIPv6Subnet []string `yaml:"clusterDefaultIPv6Subnet"` - ClusterSubnetDefaultFlexibleIPNum int `yaml:"clusterSubnetDefaultFlexibleIPNumber"` + IpamUnixSocketPath string `yaml:"ipamUnixSocketPath"` + EnableIPv4 bool `yaml:"enableIPv4"` + EnableIPv6 bool `yaml:"enableIPv6"` + EnableStatefulSet bool `yaml:"enableStatefulSet"` + EnableKubevirtStaticIP bool `yaml:"enableKubevirtStaticIP"` + EnableSpiderSubnet bool `yaml:"enableSpiderSubnet"` + ClusterSubnetDefaultFlexibleIPNum int `yaml:"clusterSubnetDefaultFlexibleIPNumber"` } type AgentContext struct { diff --git a/cmd/spiderpool-agent/cmd/daemon.go b/cmd/spiderpool-agent/cmd/daemon.go index 46cbcb5cc7..5fd801568c 100644 --- a/cmd/spiderpool-agent/cmd/daemon.go +++ b/cmd/spiderpool-agent/cmd/daemon.go @@ -132,15 +132,13 @@ func DaemonMain() { logger.Info("Begin to initialize IPAM") ipamConfig := ipam.IPAMConfig{ - EnableIPv4: agentContext.Cfg.EnableIPv4, - EnableIPv6: agentContext.Cfg.EnableIPv6, - ClusterDefaultIPv4IPPool: agentContext.Cfg.ClusterDefaultIPv4IPPool, - ClusterDefaultIPv6IPPool: agentContext.Cfg.ClusterDefaultIPv6IPPool, - EnableSpiderSubnet: agentContext.Cfg.EnableSpiderSubnet, - EnableStatefulSet: agentContext.Cfg.EnableStatefulSet, - EnableKubevirtStaticIP: agentContext.Cfg.EnableKubevirtStaticIP, - OperationRetries: agentContext.Cfg.WaitSubnetPoolMaxRetries, - OperationGapDuration: time.Duration(agentContext.Cfg.WaitSubnetPoolTime) * time.Second, + EnableIPv4: agentContext.Cfg.EnableIPv4, + EnableIPv6: agentContext.Cfg.EnableIPv6, + EnableSpiderSubnet: agentContext.Cfg.EnableSpiderSubnet, + EnableStatefulSet: agentContext.Cfg.EnableStatefulSet, + EnableKubevirtStaticIP: agentContext.Cfg.EnableKubevirtStaticIP, + OperationRetries: agentContext.Cfg.WaitSubnetPoolMaxRetries, + OperationGapDuration: time.Duration(agentContext.Cfg.WaitSubnetPoolTime) * time.Second, } if len(agentContext.Cfg.MultusClusterNetwork) != 0 { ipamConfig.MultusClusterNetwork = pointer.String(agentContext.Cfg.MultusClusterNetwork) diff --git a/pkg/ipam/config.go b/pkg/ipam/config.go index fa97ac3fb8..e550d1e8ec 100644 --- a/pkg/ipam/config.go +++ b/pkg/ipam/config.go @@ -15,10 +15,8 @@ import ( ) type IPAMConfig struct { - EnableIPv4 bool - EnableIPv6 bool - ClusterDefaultIPv4IPPool []string - ClusterDefaultIPv6IPPool []string + EnableIPv4 bool + EnableIPv6 bool EnableSpiderSubnet bool EnableStatefulSet bool diff --git a/test/e2e/common/spiderpool.go b/test/e2e/common/spiderpool.go index c9681cc628..b1690b9dc1 100644 --- a/test/e2e/common/spiderpool.go +++ b/test/e2e/common/spiderpool.go @@ -19,12 +19,10 @@ import ( . "github.com/onsi/gomega" frame "github.com/spidernet-io/e2eframework/framework" "github.com/spidernet-io/e2eframework/tools" - "github.com/spidernet-io/spiderpool/cmd/spiderpool-agent/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" ip "github.com/spidernet-io/spiderpool/pkg/ip" "github.com/spidernet-io/spiderpool/pkg/types" - "gopkg.in/yaml.v3" corev1 "k8s.io/api/core/v1" api_errors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -310,39 +308,6 @@ func CheckPodIpRecordInIppool(f *frame.Framework, v4IppoolNameList, v6IppoolName } } -func GetClusterDefaultIppool(f *frame.Framework) (v4IppoolList, v6IppoolList []string, e error) { - if f == nil { - return nil, nil, errors.New("wrong input") - } - - configMap, e := f.GetConfigmap(SpiderPoolConfigmapName, SpiderPoolConfigmapNameSpace) - if e != nil { - return nil, nil, e - } - GinkgoWriter.Printf("configmap: %+v \n", configMap.Data) - - data, ok := configMap.Data["conf.yml"] - if !ok || len(data) == 0 { - return nil, nil, errors.New("failed to find cluster default ippool") - } - - conf := cmd.Config{} - if err := yaml.Unmarshal([]byte(data), &conf); nil != err { - GinkgoWriter.Printf("failed to decode yaml config: %v \n", data) - return nil, nil, errors.New("failed to find cluster default ippool") - } - GinkgoWriter.Printf("yaml config: %v \n", conf) - - if conf.EnableIPv4 && len(conf.ClusterDefaultIPv4IPPool) == 0 { - return nil, nil, errors.New("IPv4 IPPool is not specified when IPv4 is enabled") - } - if conf.EnableIPv6 && len(conf.ClusterDefaultIPv6IPPool) == 0 { - return nil, nil, errors.New("IPv6 IPPool is not specified when IPv6 is enabled") - } - - return conf.ClusterDefaultIPv4IPPool, conf.ClusterDefaultIPv6IPPool, nil -} - func GetNamespaceDefaultIppool(f *frame.Framework, namespace string) (v4IppoolList, v6IppoolList []string, e error) { ns, err := f.GetNamespace(namespace) if err != nil { diff --git a/test/e2e/common/spidersubnet.go b/test/e2e/common/spidersubnet.go index f1339d69a4..1386535a5d 100644 --- a/test/e2e/common/spidersubnet.go +++ b/test/e2e/common/spidersubnet.go @@ -11,11 +11,9 @@ import ( "time" . "github.com/onsi/gomega" - "github.com/spidernet-io/spiderpool/cmd/spiderpool-agent/cmd" "github.com/spidernet-io/spiderpool/pkg/constant" "github.com/spidernet-io/spiderpool/pkg/lock" "github.com/spidernet-io/spiderpool/pkg/utils/convert" - "gopkg.in/yaml.v3" ip "github.com/spidernet-io/spiderpool/pkg/ip" spiderpool "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1" @@ -445,39 +443,6 @@ OUTER_FOR: return subnetNameList, nil } -func GetClusterDefaultSubnet(f *frame.Framework) (v4SubnetList, v6SubnetList []string, e error) { - if f == nil { - return nil, nil, errors.New("wrong input") - } - - configMap, e := f.GetConfigmap(SpiderPoolConfigmapName, SpiderPoolConfigmapNameSpace) - if e != nil { - return nil, nil, e - } - GinkgoWriter.Printf("configmap: %+v \n", configMap.Data) - - data, ok := configMap.Data["conf.yml"] - if !ok || len(data) == 0 { - return nil, nil, errors.New("failed to find cluster default subnet") - } - - conf := cmd.Config{} - if err := yaml.Unmarshal([]byte(data), &conf); nil != err { - GinkgoWriter.Printf("failed to decode yaml config: %v \n", data) - return nil, nil, errors.New("failed to find cluster default subnet") - } - GinkgoWriter.Printf("yaml config: %v \n", conf) - - if conf.EnableIPv4 && len(conf.ClusterDefaultIPv4Subnet) != 0 { - v4SubnetList = conf.ClusterDefaultIPv4Subnet - } - if conf.EnableIPv6 && len(conf.ClusterDefaultIPv6Subnet) != 0 { - v6SubnetList = conf.ClusterDefaultIPv6Subnet - } - - return v4SubnetList, v6SubnetList, nil -} - func GetAllSubnet(f *frame.Framework, opts ...client.ListOption) (*spiderpool.SpiderSubnetList, error) { if f == nil { return nil, errors.New("wrong input") diff --git a/test/e2e/subnet/subnet_test.go b/test/e2e/subnet/subnet_test.go index 52c78f04d5..11da49e748 100644 --- a/test/e2e/subnet/subnet_test.go +++ b/test/e2e/subnet/subnet_test.go @@ -1324,7 +1324,8 @@ var _ = Describe("test subnet", Label("subnet"), func() { // Get the default subnet // and verify that the default subnet functions properly By("get cluster default subnet") - ClusterDefaultV4SubnetList, ClusterDefaultV6SubnetList, err = common.GetClusterDefaultSubnet(frame) + // TODO(ty-dc), Default subnet to be determined for now + // ClusterDefaultV4SubnetList, ClusterDefaultV6SubnetList, err = common.GetClusterDefaultSubnet(frame) Expect(err).NotTo(HaveOccurred()) if frame.Info.IpV4Enabled && len(ClusterDefaultV4SubnetList) == 0 { Skip("v4 Default Subnet function is not enabled")