Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
changluyi committed Aug 25, 2023
1 parent e377ca8 commit 98b78a5
Show file tree
Hide file tree
Showing 100 changed files with 841 additions and 881 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output:
linters:
enable:
- gocritic
#- gofumpt
- gofumpt
- goimports
- misspell
- predeclared
Expand Down
7 changes: 3 additions & 4 deletions cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ func mvCNIConf(configDir, configFile, confName string) error {
}

cniConfPath := filepath.Join(configDir, confName)
return os.WriteFile(cniConfPath, data, 0644)
return os.WriteFile(cniConfPath, data, 0o644)
}

func Retry(attempts int, sleep int, f func(configuration *daemon.Configuration) error, ctrl *daemon.Configuration) (err error) {
func Retry(attempts, sleep int, f func(configuration *daemon.Configuration) error, ctrl *daemon.Configuration) (err error) {
for i := 0; ; i++ {
err = f(ctrl)
if err == nil {
Expand Down Expand Up @@ -178,8 +178,7 @@ func initChassisAnno(cfg *daemon.Configuration) error {
klog.Infof("chassis id changed, old: %s, new: %s", annoChassesName, chassesName)
}
node.Annotations[util.ChassisAnnotation] = chassesName
patchPayloadTemplate :=
`[{
patchPayloadTemplate := `[{
"op": "%s",
"path": "/metadata/annotations",
"value": %s
Expand Down
6 changes: 4 additions & 2 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcdns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions pkg/client/clientset/versioned/typed/kubeovn/v1/vpcdns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/client/informers/externalversions/kubeovn/v1/vpcdns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ type Controller struct {

ovnLegacyClient *ovs.LegacyClient

ovnNbClient ovs.NbClient
ovnSbClient ovs.SbClient
OVNNbClient ovs.NbClient
OVNSbClient ovs.SbClient

// ExternalGatewayType define external gateway type, centralized
ExternalGatewayType string
Expand Down Expand Up @@ -298,7 +298,7 @@ func Run(ctx context.Context, config *Configuration) {
configMapInformer := cmInformerFactory.Core().V1().ConfigMaps()
npInformer := informerFactory.Networking().V1().NetworkPolicies()
switchLBRuleInformer := kubeovnInformerFactory.Kubeovn().V1().SwitchLBRules()
vpcDnsInformer := kubeovnInformerFactory.Kubeovn().V1().VpcDnses()
vpcDNSInformer := kubeovnInformerFactory.Kubeovn().V1().VpcDnses()
ovnEipInformer := kubeovnInformerFactory.Kubeovn().V1().OvnEips()
ovnFipInformer := kubeovnInformerFactory.Kubeovn().V1().OvnFips()
ovnSnatRuleInformer := kubeovnInformerFactory.Kubeovn().V1().OvnSnatRules()
Expand Down Expand Up @@ -489,10 +489,10 @@ func Run(ctx context.Context, config *Configuration) {
}

var err error
if controller.ovnNbClient, err = ovs.NewOvnNbClient(config.OvnNbAddr, config.OvnTimeout); err != nil {
if controller.OVNNbClient, err = ovs.NewOvnNbClient(config.OvnNbAddr, config.OvnTimeout); err != nil {
util.LogFatalAndExit(err, "failed to create ovn nb client")
}
if controller.ovnSbClient, err = ovs.NewOvnSbClient(config.OvnSbAddr, config.OvnTimeout); err != nil {
if controller.OVNSbClient, err = ovs.NewOvnSbClient(config.OvnSbAddr, config.OvnTimeout); err != nil {
util.LogFatalAndExit(err, "failed to create ovn sb client")
}
if config.EnableLb {
Expand All @@ -502,8 +502,8 @@ func Run(ctx context.Context, config *Configuration) {
controller.delSwitchLBRuleQueue = workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "delSwitchLBRule")
controller.UpdateSwitchLBRuleQueue = workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "updateSwitchLBRule")

controller.vpcDNSLister = vpcDnsInformer.Lister()
controller.vpcDNSSynced = vpcDnsInformer.Informer().HasSynced
controller.vpcDNSLister = vpcDNSInformer.Lister()
controller.vpcDNSSynced = vpcDNSInformer.Informer().HasSynced
controller.addOrUpdateVpcDNSQueue = workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "AddOrUpdateVpcDns")
controller.delVpcDNSQueue = workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "DeleteVpcDns")
}
Expand Down Expand Up @@ -744,10 +744,10 @@ func Run(ctx context.Context, config *Configuration) {
util.LogFatalAndExit(err, "failed to add switch lb rule event handler")
}

if _, err = vpcDnsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
if _, err = vpcDNSInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueueAddVpcDNS,
UpdateFunc: controller.enqueueUpdateVpcDNS,
DeleteFunc: controller.enqueueDeleteVpcDns,
DeleteFunc: controller.enqueueDeleteVPCDNS,
}); err != nil {
util.LogFatalAndExit(err, "failed to add vpc dns event handler")
}
Expand All @@ -773,11 +773,11 @@ func Run(ctx context.Context, config *Configuration) {
func (c *Controller) Run(ctx context.Context) {
// The init process can only be placed here if the init process do really affect the normal process of controller, such as Nodes/Pods/Subnets...
// Otherwise, the init process should be placed after all workers have already started working
if err := c.ovnNbClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil {
if err := c.OVNNbClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil {
util.LogFatalAndExit(err, "failed to set NB_Global option ls_dnat_mod_dl_dst")
}

if err := c.ovnNbClient.SetUseCtInvMatch(); err != nil {
if err := c.OVNNbClient.SetUseCtInvMatch(); err != nil {
util.LogFatalAndExit(err, "failed to set NB_Global option use_ct_inv_match to false")
}

Expand Down Expand Up @@ -1004,10 +1004,10 @@ func (c *Controller) startWorkers(ctx context.Context) {
go wait.Until(c.runDelSwitchLBRuleWorker, time.Second, ctx.Done())
go wait.Until(c.runUpdateSwitchLBRuleWorker, time.Second, ctx.Done())

go wait.Until(c.runAddOrUpdateVpcDnsWorker, time.Second, ctx.Done())
go wait.Until(c.runDelVpcDnsWorker, time.Second, ctx.Done())
go wait.Until(c.runAddOrUpdateVPCDNSWorker, time.Second, ctx.Done())
go wait.Until(c.runDelVPCDNSWorker, time.Second, ctx.Done())
go wait.Until(func() {
c.resyncVpcDnsConfig()
c.resyncVpcDNSConfig()
}, 5*time.Second, ctx.Done())
}

Expand Down Expand Up @@ -1131,7 +1131,7 @@ func (c *Controller) startWorkers(ctx context.Context) {

func (c *Controller) allSubnetReady(subnets ...string) (bool, error) {
for _, lsName := range subnets {
exist, err := c.ovnNbClient.LogicalSwitchExists(lsName)
exist, err := c.OVNNbClient.LogicalSwitchExists(lsName)
if err != nil {
return false, fmt.Errorf("check logical switch %s exist: %v", lsName, err)
}
Expand Down Expand Up @@ -1162,7 +1162,7 @@ func (c *Controller) initResourceOnce() {
}

if c.config.EnableLb {
if err := c.initVpcDnsConfig(); err != nil {
if err := c.initVpcDNSConfig(); err != nil {
util.LogFatalAndExit(err, "failed to initialize vpc-dns")
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func newFakeController(t *testing.T) *fakeController {
vpcSynced: alwaysReady,
subnetsLister: sbunetInformer.Lister(),
subnetSynced: alwaysReady,
ovnNbClient: mockOvnClient,
OVNNbClient: mockOvnClient,
syncVirtualPortsQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), ""),
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
// for performance reason delete lb with no backends
if len(backends) != 0 {
klog.V(3).Infof("update vip %s with backends %s to LB %s", vip, backends, lb)
if err = c.ovnNbClient.LoadBalancerAddVip(lb, vip, backends...); err != nil {
if err = c.OVNNbClient.LoadBalancerAddVip(lb, vip, backends...); err != nil {
klog.Errorf("failed to add vip %s with backends %s to LB %s: %v", vip, backends, lb, err)
return err
}
} else {
klog.V(3).Infof("delete vip %s from LB %s", vip, lb)
if err := c.ovnNbClient.LoadBalancerDeleteVip(lb, vip); err != nil {
if err := c.OVNNbClient.LoadBalancerDeleteVip(lb, vip); err != nil {
klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err)
return err
}
klog.V(3).Infof("delete vip %s from old LB %s", vip, lb)
if err := c.ovnNbClient.LoadBalancerDeleteVip(oldLb, vip); err != nil {
if err := c.OVNNbClient.LoadBalancerDeleteVip(oldLb, vip); err != nil {
klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err)
return err
}
Expand Down
Loading

0 comments on commit 98b78a5

Please sign in to comment.