Skip to content

Commit 632224a

Browse files
authored
Update Kube-OVN v1.13.13 and enable db healthcheck (#1047)
This PR updates Kube-OVN to the latest version and also includes fix kubeovn/kube-ovn#5294 Ref kubeovn/kube-ovn#5125 (comment) Signed-off-by: Andrei Kvapil <[email protected]>
2 parents e8d11e6 + 9733de3 commit 632224a

5 files changed

Lines changed: 219 additions & 5 deletions

File tree

‎packages/system/kubeovn/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ update:
1515
patch --no-backup-if-mismatch -p4 < patches/mtu.diff
1616
version=$$(awk '$$1 == "version:" {print $$2}' charts/kube-ovn/Chart.yaml) && \
1717
sed -i "s/ARG VERSION=.*/ARG VERSION=$${version}/" images/kubeovn/Dockerfile
18+
sed -i "s/ARG TAG=.*/ARG TAG=$${version}/" images/kubeovn/Dockerfile
1819

1920
image:
2021
docker buildx build images/kubeovn \

‎packages/system/kubeovn/charts/kube-ovn/Chart.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: v1.13.11
18+
version: v1.13.13
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "1.13.11"
24+
appVersion: "1.13.13"
2525

2626
kubeVersion: ">= 1.23.0-0"

‎packages/system/kubeovn/charts/kube-ovn/values.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ global:
1010
repository: kube-ovn
1111
dpdkRepository: kube-ovn-dpdk
1212
vpcRepository: vpc-nat-gateway
13-
tag: v1.13.11
13+
tag: v1.13.13
1414
support_arm: true
1515
thirdparty: true
1616

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
ARG VERSION=v1.13.11
2-
FROM kubeovn/kube-ovn:${VERSION}
1+
# syntax = docker/dockerfile:experimental
2+
ARG VERSION=v1.13.13
3+
ARG BASE_TAG=$VERSION
4+
5+
FROM golang:1.23-bookworm as builder
6+
7+
ARG TAG=v1.13.13
8+
RUN git clone --branch ${TAG} --depth 1 https://github.com/kubeovn/kube-ovn /source
9+
10+
WORKDIR /source
11+
12+
COPY patches /patches
13+
RUN git apply /patches/*.diff
14+
RUN make build-go
15+
16+
WORKDIR /source/dist/images
17+
18+
# imported from https://github.com/kubeovn/kube-ovn/blob/master/dist/images/Dockerfile
19+
FROM kubeovn/kube-ovn-base:$BASE_TAG AS setcap
20+
21+
COPY --from=builder /source/dist/images/*.sh /kube-ovn/
22+
COPY --from=builder /source/dist/images/kubectl-ko /kube-ovn/kubectl-ko
23+
COPY --from=builder /source/dist/images/01-kube-ovn.conflist /kube-ovn/01-kube-ovn.conflist
24+
25+
COPY --from=builder /source/dist/images/kube-ovn /kube-ovn/kube-ovn
26+
COPY --from=builder /source/dist/images/kube-ovn-cmd /kube-ovn/kube-ovn-cmd
27+
COPY --from=builder /source/dist/images/kube-ovn-daemon /kube-ovn/kube-ovn-daemon
28+
COPY --from=builder /source/dist/images/kube-ovn-controller /kube-ovn/kube-ovn-controller
29+
RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-monitor && \
30+
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-speaker && \
31+
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-webhook && \
32+
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-leader-checker && \
33+
ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-ic-controller && \
34+
ln -s /kube-ovn/kube-ovn-controller /kube-ovn/kube-ovn-pinger && \
35+
setcap CAP_NET_BIND_SERVICE+eip /kube-ovn/kube-ovn-cmd && \
36+
setcap CAP_NET_RAW,CAP_NET_BIND_SERVICE+eip /kube-ovn/kube-ovn-controller && \
37+
setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE,CAP_SYS_ADMIN+eip /kube-ovn/kube-ovn-daemon
38+
39+
FROM kubeovn/kube-ovn-base:$BASE_TAG
40+
41+
COPY --chmod=0644 --from=builder /source/dist/images/logrotate/* /etc/logrotate.d/
42+
COPY --from=builder /source/dist/images/grace_stop_ovn_controller /usr/share/ovn/scripts/grace_stop_ovn_controller
43+
44+
COPY --from=setcap /kube-ovn /kube-ovn
45+
RUN /kube-ovn/iptables-wrapper-installer.sh --no-sanity-check
46+
47+
WORKDIR /kube-ovn
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
diff --git a/mocks/pkg/ovs/interface.go b/mocks/pkg/ovs/interface.go
2+
index e9c472bee..59076f9ed 100644
3+
--- a/mocks/pkg/ovs/interface.go
4+
+++ b/mocks/pkg/ovs/interface.go
5+
@@ -10,6 +10,7 @@
6+
package ovs
7+
8+
import (
9+
+ context "context"
10+
reflect "reflect"
11+
12+
v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
13+
@@ -3322,6 +3323,20 @@ func (mr *MockNbClientMockRecorder) DeleteSecurityGroup(sgName any) *gomock.Call
14+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSecurityGroup", reflect.TypeOf((*MockNbClient)(nil).DeleteSecurityGroup), sgName)
15+
}
16+
17+
+// Echo mocks base method.
18+
+func (m *MockNbClient) Echo(arg0 context.Context) error {
19+
+ m.ctrl.T.Helper()
20+
+ ret := m.ctrl.Call(m, "Echo", arg0)
21+
+ ret0, _ := ret[0].(error)
22+
+ return ret0
23+
+}
24+
+
25+
+// Echo indicates an expected call of Echo.
26+
+func (mr *MockNbClientMockRecorder) Echo(arg0 any) *gomock.Call {
27+
+ mr.mock.ctrl.T.Helper()
28+
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Echo", reflect.TypeOf((*MockNbClient)(nil).Echo), arg0)
29+
+}
30+
+
31+
// EnablePortLayer2forward mocks base method.
32+
func (m *MockNbClient) EnablePortLayer2forward(lspName string) error {
33+
m.ctrl.T.Helper()
34+
@@ -4770,6 +4785,20 @@ func (mr *MockSbClientMockRecorder) GetAllChassisByHost(nodeName any) *gomock.Ca
35+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllChassisByHost", reflect.TypeOf((*MockSbClient)(nil).GetAllChassisByHost), nodeName)
36+
}
37+
38+
+// Echo mocks base method.
39+
+func (m *MockSbClient) Echo(arg0 context.Context) error {
40+
+ m.ctrl.T.Helper()
41+
+ ret := m.ctrl.Call(m, "Echo", arg0)
42+
+ ret0, _ := ret[0].(error)
43+
+ return ret0
44+
+}
45+
+
46+
+// Echo indicates an expected call of Echo.
47+
+func (mr *MockSbClientMockRecorder) Echo(arg0 any) *gomock.Call {
48+
+ mr.mock.ctrl.T.Helper()
49+
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Echo", reflect.TypeOf((*MockSbClient)(nil).Echo), arg0)
50+
+}
51+
+
52+
// GetChassis mocks base method.
53+
func (m *MockSbClient) GetChassis(chassisName string, ignoreNotFound bool) (*ovnsb.Chassis, error) {
54+
m.ctrl.T.Helper()
55+
@@ -4915,6 +4944,20 @@ func (m *MockCommon) EXPECT() *MockCommonMockRecorder {
56+
return m.recorder
57+
}
58+
59+
+// Echo mocks base method.
60+
+func (m *MockCommon) Echo(arg0 context.Context) error {
61+
+ m.ctrl.T.Helper()
62+
+ ret := m.ctrl.Call(m, "Echo", arg0)
63+
+ ret0, _ := ret[0].(error)
64+
+ return ret0
65+
+}
66+
+
67+
+// Echo indicates an expected call of Echo.
68+
+func (mr *MockCommonMockRecorder) Echo(arg0 any) *gomock.Call {
69+
+ mr.mock.ctrl.T.Helper()
70+
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Echo", reflect.TypeOf((*MockCommon)(nil).Echo), arg0)
71+
+}
72+
+
73+
// GetEntityInfo mocks base method.
74+
func (m *MockCommon) GetEntityInfo(entity any) error {
75+
m.ctrl.T.Helper()
76+
diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go
77+
index cb594a4c8..a2a88eb06 100644
78+
--- a/pkg/controller/controller.go
79+
+++ b/pkg/controller/controller.go
80+
@@ -268,6 +268,9 @@ type Controller struct {
81+
cmInformerFactory kubeinformers.SharedInformerFactory
82+
kubeovnInformerFactory kubeovninformer.SharedInformerFactory
83+
anpInformerFactory anpinformer.SharedInformerFactory
84+
+
85+
+ // Database health check
86+
+ dbFailureCount int
87+
}
88+
89+
func newTypedRateLimitingQueue[T comparable](name string, rateLimiter workqueue.TypedRateLimiter[T]) workqueue.TypedRateLimitingInterface[T] {
90+
@@ -944,6 +947,48 @@ func (c *Controller) Run(ctx context.Context) {
91+
klog.Info("Shutting down workers")
92+
}
93+
94+
+func (c *Controller) dbStatus() {
95+
+ const maxFailures = 5
96+
+
97+
+ done := make(chan error, 2)
98+
+ go func() {
99+
+ done <- c.OVNNbClient.Echo(context.Background())
100+
+ }()
101+
+ go func() {
102+
+ done <- c.OVNSbClient.Echo(context.Background())
103+
+ }()
104+
+
105+
+ resultsReceived := 0
106+
+ timeout := time.After(time.Duration(c.config.OvnTimeout) * time.Second)
107+
+
108+
+ for resultsReceived < 2 {
109+
+ select {
110+
+ case err := <-done:
111+
+ resultsReceived++
112+
+ if err != nil {
113+
+ c.dbFailureCount++
114+
+ klog.Errorf("OVN database echo failed (%d/%d): %v", c.dbFailureCount, maxFailures, err)
115+
+ if c.dbFailureCount >= maxFailures {
116+
+ util.LogFatalAndExit(err, "OVN database connection failed after %d attempts", maxFailures)
117+
+ }
118+
+ return
119+
+ }
120+
+ case <-timeout:
121+
+ c.dbFailureCount++
122+
+ klog.Errorf("OVN database echo timeout (%d/%d) after %ds", c.dbFailureCount, maxFailures, c.config.OvnTimeout)
123+
+ if c.dbFailureCount >= maxFailures {
124+
+ util.LogFatalAndExit(nil, "OVN database connection timeout after %d attempts", maxFailures)
125+
+ }
126+
+ return
127+
+ }
128+
+ }
129+
+
130+
+ if c.dbFailureCount > 0 {
131+
+ klog.Infof("OVN database connection recovered after %d failures", c.dbFailureCount)
132+
+ c.dbFailureCount = 0
133+
+ }
134+
+}
135+
+
136+
func (c *Controller) shutdown() {
137+
utilruntime.HandleCrash()
138+
139+
@@ -1277,6 +1322,8 @@ func (c *Controller) startWorkers(ctx context.Context) {
140+
if c.config.EnableLiveMigrationOptimize {
141+
go wait.Until(runWorker("add/update vmiMigration ", c.addOrUpdateVMIMigrationQueue, c.handleAddOrUpdateVMIMigration), 50*time.Millisecond, ctx.Done())
142+
}
143+
+
144+
+ go wait.Until(c.dbStatus, 15*time.Second, ctx.Done())
145+
}
146+
147+
func (c *Controller) allSubnetReady(subnets ...string) (bool, error) {
148+
diff --git a/pkg/ovs/interface.go b/pkg/ovs/interface.go
149+
index df6907c4d..5e70dd6c7 100644
150+
--- a/pkg/ovs/interface.go
151+
+++ b/pkg/ovs/interface.go
152+
@@ -1,6 +1,8 @@
153+
package ovs
154+
155+
import (
156+
+ "context"
157+
+
158+
netv1 "k8s.io/api/networking/v1"
159+
160+
"github.com/ovn-org/libovsdb/ovsdb"
161+
@@ -235,6 +237,7 @@ type SbClient interface {
162+
}
163+
164+
type Common interface {
165+
+ Echo(context.Context) error
166+
Transact(method string, operations []ovsdb.Operation) error
167+
GetEntityInfo(entity interface{}) error
168+
}

0 commit comments

Comments
 (0)