Skip to content

Commit

Permalink
ut: ovn sb suite (#4549)
Browse files Browse the repository at this point in the history
* add ovnSBClient for suite

Signed-off-by: zcq98 <[email protected]>

* add unit test for ovn.go

Signed-off-by: zcq98 <[email protected]>

* add unit test for ovn-sb-chassis.go

Signed-off-by: zcq98 <[email protected]>

* fix in some cases route.src is nil

Signed-off-by: zcq98 <[email protected]>

* use OvsDbConnectMaxRetry to set max retries for connecting ovsdb

Signed-off-by: zcq98 <[email protected]>

* modify the variable names of nbClient and sbClient

Signed-off-by: zcq98 <[email protected]>

* first check for err then check the resource

Signed-off-by: zcq98 <[email protected]>

* add log near error

Signed-off-by: zcq98 <[email protected]>

* fix empty name chassis not deleted

Signed-off-by: zcq98 <[email protected]>

* modify the variable names of nbClient and sbClient

Signed-off-by: zcq98 <[email protected]>

---------

Signed-off-by: zcq98 <[email protected]>
  • Loading branch information
zcq98 authored Sep 27, 2024
1 parent 84203a0 commit 49cba10
Show file tree
Hide file tree
Showing 26 changed files with 2,269 additions and 1,525 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Configuration struct {
OvnSbAddr string
OvnTimeout int
OvsDbConnectTimeout int
OvsDbConnectMaxRetry int
OvsDbInactivityTimeout int
CustCrdRetryMaxDelay int
CustCrdRetryMinDelay int
Expand Down Expand Up @@ -118,6 +119,7 @@ func ParseFlags() (*Configuration, error) {
argOvnSbAddr = pflag.String("ovn-sb-addr", "", "ovn-sb address")
argOvnTimeout = pflag.Int("ovn-timeout", 60, "The seconds to wait ovn command timeout")
argOvsDbConTimeout = pflag.Int("ovsdb-con-timeout", 3, "The seconds to wait ovsdb connect timeout")
argOvsDbConnectMaxRetry = pflag.Int("ovsdb-con-maxretry", 60, "The maximum number of retries for connecting to ovsdb")
argOvsDbInactivityTimeout = pflag.Int("ovsdb-inactivity-timeout", 10, "The seconds to wait ovsdb inactivity check timeout")
argCustCrdRetryMinDelay = pflag.Int("cust-crd-retry-min-delay", 1, "The min delay seconds between custom crd two retries")
argCustCrdRetryMaxDelay = pflag.Int("cust-crd-retry-max-delay", 20, "The max delay seconds between custom crd two retries")
Expand Down Expand Up @@ -209,6 +211,7 @@ func ParseFlags() (*Configuration, error) {
OvnSbAddr: *argOvnSbAddr,
OvnTimeout: *argOvnTimeout,
OvsDbConnectTimeout: *argOvsDbConTimeout,
OvsDbConnectMaxRetry: *argOvsDbConnectMaxRetry,
OvsDbInactivityTimeout: *argOvsDbInactivityTimeout,
CustCrdRetryMinDelay: *argCustCrdRetryMinDelay,
CustCrdRetryMaxDelay: *argCustCrdRetryMaxDelay,
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,17 @@ func Run(ctx context.Context, config *Configuration) {
config.OvnNbAddr,
config.OvnTimeout,
config.OvsDbConnectTimeout,
config.OvsDbInactivityTimeout); err != nil {
config.OvsDbInactivityTimeout,
config.OvsDbConnectMaxRetry,
); err != nil {
util.LogFatalAndExit(err, "failed to create ovn nb client")
}
if controller.OVNSbClient, err = ovs.NewOvnSbClient(
config.OvnSbAddr,
config.OvnTimeout,
config.OvsDbConnectTimeout,
config.OvsDbInactivityTimeout,
config.OvsDbConnectMaxRetry,
); err != nil {
util.LogFatalAndExit(err, "failed to create ovn sb client")
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/ovn_ic_controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Configuration struct {
OvnSbAddr string
OvnTimeout int
OvsDbConnectTimeout int
OvsDbConnectMaxRetry int
OvsDbInactivityTimeout int

NodeSwitch string
Expand All @@ -41,6 +42,7 @@ func ParseFlags() (*Configuration, error) {
argOvnSbAddr = pflag.String("ovn-sb-addr", "", "ovn-sb address")
argOvnTimeout = pflag.Int("ovn-timeout", 60, "")
argOvsDbConTimeout = pflag.Int("ovsdb-con-timeout", 3, "")
argOvsDbConnectMaxRetry = pflag.Int("ovsdb-con-maxretry", 60, "")
argOvsDbInactivityTimeout = pflag.Int("ovsdb-inactivity-timeout", 10, "")

argClusterRouter = pflag.String("cluster-router", util.DefaultVpc, "The router name for cluster router")
Expand Down Expand Up @@ -80,6 +82,7 @@ func ParseFlags() (*Configuration, error) {
OvnSbAddr: *argOvnSbAddr,
OvnTimeout: *argOvnTimeout,
OvsDbConnectTimeout: *argOvsDbConTimeout,
OvsDbConnectMaxRetry: *argOvsDbConnectMaxRetry,
OvsDbInactivityTimeout: *argOvsDbInactivityTimeout,

ClusterRouter: *argClusterRouter,
Expand Down
2 changes: 2 additions & 0 deletions pkg/ovn_ic_controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func NewController(config *Configuration) *Controller {
config.OvnTimeout,
config.OvsDbConnectTimeout,
config.OvsDbInactivityTimeout,
config.OvsDbConnectMaxRetry,
); err != nil {
util.LogFatalAndExit(err, "failed to create ovn nb client")
}
Expand All @@ -100,6 +101,7 @@ func NewController(config *Configuration) *Controller {
config.OvnTimeout,
config.OvsDbConnectTimeout,
config.OvsDbInactivityTimeout,
config.OvsDbConnectMaxRetry,
); err != nil {
util.LogFatalAndExit(err, "failed to create ovn sb client")
}
Expand Down
Loading

0 comments on commit 49cba10

Please sign in to comment.