From b7d0f599e153f2c39cc96af59425c57db3e62ad1 Mon Sep 17 00:00:00 2001 From: Yan Zhu Date: Wed, 17 Apr 2019 10:21:57 +0800 Subject: [PATCH] cleanup unused code --- dist/images/start-cniserver.sh | 2 +- pkg/daemon/config.go | 18 ------------- pkg/daemon/controller.go | 3 --- pkg/ovs/ovn-sbctl.go | 49 ---------------------------------- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 pkg/ovs/ovn-sbctl.go diff --git a/dist/images/start-cniserver.sh b/dist/images/start-cniserver.sh index a25ceb2adae..39c219560fc 100755 --- a/dist/images/start-cniserver.sh +++ b/dist/images/start-cniserver.sh @@ -9,4 +9,4 @@ then rm ${SOCK} fi -./kube-ovn-daemon --ovs-socket=/run/openvswitch/db.sock --bind-socket=${SOCK} --ovn-nb-host=$OVN_NB_SERVICE_HOST --ovn-sb-host=$OVN_SB_SERVICE_HOST $@ \ No newline at end of file +./kube-ovn-daemon --ovs-socket=/run/openvswitch/db.sock --bind-socket=${SOCK} $@ \ No newline at end of file diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index 4f3336471e1..1aef5afeeca 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -18,12 +18,6 @@ type Configuration struct { KubeConfigFile string KubeClient kubernetes.Interface NodeName string - OvnNbHost string - OvnNbPort int - OvnSbHost string - OvnSbPort int - ClusterRouter string - NodeSwitch string ServiceClusterIPRange string } @@ -33,12 +27,6 @@ func ParseFlags() (*Configuration, error) { argBindSocket = pflag.String("bind-socket", "/var/run/cniserver.sock", "The socket daemon bind to.") argOvsSocket = pflag.String("ovs-socket", "", "The socket to local ovs-server") argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.") - argOvnNbHost = pflag.String("ovn-nb-host", "", "") - argOvnNbPort = pflag.Int("ovn-nb-port", 6641, "") - argOvnSbHost = pflag.String("ovn-sb-host", "", "") - argOvnSbPort = pflag.Int("ovn-sb-port", 6642, "") - argClusterRouter = pflag.String("cluster-router", "ovn-cluster", "The router name for cluster router.Default: cluster-router") - argNodeSwitch = pflag.String("node-switch", "join", "The name of node gateway switch which help node to access pod network. Default: join") argServiceClusterIPRange = pflag.String("service-cluster-ip-range", "10.96.0.0/12", "The kubernetes service cluster ip range") ) @@ -68,12 +56,6 @@ func ParseFlags() (*Configuration, error) { OvsSocket: *argOvsSocket, KubeConfigFile: *argKubeConfigFile, NodeName: nodeName, - OvnNbHost: *argOvnNbHost, - OvnNbPort: *argOvnNbPort, - OvnSbHost: *argOvnSbHost, - OvnSbPort: *argOvnSbPort, - ClusterRouter: *argClusterRouter, - NodeSwitch: *argNodeSwitch, ServiceClusterIPRange: *argServiceClusterIPRange, } err := config.initKubeClient() diff --git a/pkg/daemon/controller.go b/pkg/daemon/controller.go index ba84f0f13da..69406b302e4 100644 --- a/pkg/daemon/controller.go +++ b/pkg/daemon/controller.go @@ -37,7 +37,6 @@ type Controller struct { podsSynced cache.InformerSynced podQueue workqueue.RateLimitingInterface - ovnClient *ovs.Client ipSetsMgr *ipsets.IPSets iptablesMgr *iptables.IPTables } @@ -45,7 +44,6 @@ type Controller struct { func NewController(config *Configuration, informerFactory informers.SharedInformerFactory) (*Controller, error) { namespaceInformer := informerFactory.Core().V1().Namespaces() podInformer := informerFactory.Core().V1().Pods() - ovnClient := ovs.NewClient(config.OvnNbHost, config.OvnNbPort, config.OvnSbHost, config.OvnSbPort, "", "", "", "", "") iptablesMgr, err := iptables.New() if err != nil { return nil, err @@ -63,7 +61,6 @@ func NewController(config *Configuration, informerFactory informers.SharedInform podsSynced: podInformer.Informer().HasSynced, podQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "Pod"), - ovnClient: ovnClient, ipSetsMgr: ipsetsMgr, iptablesMgr: iptablesMgr, } diff --git a/pkg/ovs/ovn-sbctl.go b/pkg/ovs/ovn-sbctl.go deleted file mode 100644 index d6f116ccea2..00000000000 --- a/pkg/ovs/ovn-sbctl.go +++ /dev/null @@ -1,49 +0,0 @@ -package ovs - -import ( - "fmt" - "os/exec" - "strings" - "time" - - "k8s.io/klog" -) - -func (c Client) ovnSbCommand(arg ...string) (string, error) { - cmdArgs := []string{fmt.Sprintf("--db=%s", c.OvnSbAddress)} - cmdArgs = append(cmdArgs, arg...) - klog.V(5).Infof("execute %s command %s", OvnSbCtl, strings.Join(cmdArgs, " ")) - - start := time.Now() - raw, err := exec.Command(OvnSbCtl, cmdArgs...).CombinedOutput() - elapsed := float64((time.Since(start)) / time.Millisecond) - klog.Infof("%s command %s in %vms", OvnSbCtl, strings.Join(cmdArgs, " "), elapsed) - if err != nil { - return "", fmt.Errorf("%s, %v", string(raw), err) - } - return trimCommandOutput(raw), nil -} - -func (c Client) GetChassisByHostname(hostname string) (string, error) { - output, err := c.ovnSbCommand("--data=bare", "--no-heading", "--columns=_uuid", - "find", "Chassis", fmt.Sprintf("hostname=%s", hostname)) - if err != nil { - return "", err - } - if output != "" { - return output, nil - } - return "", ErrNotFound -} - -func (c Client) GetLogicalSwitchPortInChassis(chassis string) (string, error) { - output, err := c.ovnSbCommand("--data=bare", "--no-heading", "--columns=logical_port", - "find", "Port_Binding", fmt.Sprintf("chassis=%s", chassis)) - if err != nil { - return "", err - } - if output != "" { - return output, nil - } - return "", ErrNotFound -}