Skip to content

Commit

Permalink
delete connect to ovsdb for ovn-monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Jan 22, 2021
1 parent eeaf744 commit f1efaa7
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 114 deletions.
24 changes: 4 additions & 20 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -725,18 +725,10 @@ spec:
value: "$ENABLE_SSL"
- name: NODE_IPS
value: $addresses
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: spec.nodeName
resources:
requests:
cpu: 200m
Expand Down Expand Up @@ -1230,18 +1222,10 @@ spec:
value: "$ENABLE_SSL"
- name: NODE_IPS
value: $addresses
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: spec.nodeName
resources:
requests:
cpu: 200m
Expand Down
24 changes: 4 additions & 20 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -763,18 +763,10 @@ spec:
value: "$ENABLE_SSL"
- name: NODE_IPS
value: $addresses
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: spec.nodeName
resources:
requests:
cpu: 200m
Expand Down Expand Up @@ -1267,18 +1259,10 @@ spec:
value: "$ENABLE_SSL"
- name: NODE_IPS
value: $addresses
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: spec.nodeName
resources:
requests:
cpu: 200m
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ require (
sigs.k8s.io/controller-runtime v0.7.0
)

replace k8s.io/client-go => k8s.io/client-go v0.20.1-rc.1
replace (
k8s.io/client-go => k8s.io/client-go v0.20.1-rc.1
github.com/greenpau/ovsdb => github.com/alauda/ovsdb v0.0.0-20210113100339-040cf3e76c28
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4Rq
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/alauda/felix v3.6.6-0.20201207121355-187332daf314+incompatible h1:f8w9fTcjS9/Zdw57Law9JsFxh/sttnBor4TGkWQpSf8=
github.com/alauda/felix v3.6.6-0.20201207121355-187332daf314+incompatible/go.mod h1:NeFJ7/fvKQ8X9styGJvh7sHmZoUprV5ZKzE2Ey82BEA=
github.com/alauda/ovsdb v0.0.0-20210113100339-040cf3e76c28 h1:FW5M3SAwSGBdtTboeV5sI7kEY6zraApSZQxTUfZ7LQY=
github.com/alauda/ovsdb v0.0.0-20210113100339-040cf3e76c28/go.mod h1:dXpg+IAC2yp2IZQlEVmnmEc1rqEmSZzgNfu6+ai38J4=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down
28 changes: 2 additions & 26 deletions pkg/ovnmonitor/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ func NewExporter(cfg *Configuration) *Exporter {
e := Exporter{}
e.Client = ovsdb.NewOvnClient()
e.initParas(cfg)

if err := e.Client.GetSystemID(); err != nil {
klog.Errorf("%s failed to get system id: %s", appName, err)
}

return &e
}

Expand All @@ -68,6 +63,7 @@ func (e *Exporter) initParas(cfg *Configuration) {
e.pollInterval = cfg.PollInterval

e.Client.Timeout = cfg.PollTimeout
e.Client.System.Hostname = os.Getenv("KUBE_NODE_NAME")
e.Client.System.RunDir = cfg.SystemRunDir
e.Client.Database.Vswitch.Name = cfg.DatabaseVswitchName
e.Client.Database.Vswitch.Socket.Remote = cfg.DatabaseVswitchSocketRemote
Expand Down Expand Up @@ -107,12 +103,7 @@ func (e *Exporter) StartConnection() error {
if err := e.Client.Connect(); err != nil {
return err
}

if err := e.Client.GetSystemInfo(); err != nil {
return err
}
klog.Infof("%s: exporter connect successfully", e.Client.System.Hostname)

return nil
}

Expand All @@ -128,11 +119,7 @@ func (e *Exporter) TryClientConnection() {
tryConnectCnt++
klog.Errorf("%s: ovn-monitor failed to reconnect db socket %v times", e.Client.System.Hostname, tryConnectCnt)
} else {
if err := e.Client.GetSystemID(); err != nil {
klog.Errorf("%s failed to get system id: %s", appName, err)
} else {
klog.Infof("%s: ovn-monitor reconnect db successfully", e.Client.System.ID)
}
klog.Infof("%s: ovn-monitor reconnect db successfully", e.Client.System.Hostname)
break
}

Expand All @@ -156,7 +143,6 @@ func (e *Exporter) StartOvnMetrics() {
func (e *Exporter) ovnMetricsUpdate() {
for {
e.exportOvnStatusGauge()
e.exportOvnInfoGauge()
e.exportOvnLogFileSizeGauge()
e.exportOvnDBFileSizeGauge()
e.exportOvnRequestErrorGauge()
Expand Down Expand Up @@ -187,16 +173,6 @@ func (e *Exporter) exportOvnStatusGauge() {
}
}

func (e *Exporter) exportOvnInfoGauge() {
if err := e.Client.GetSystemInfo(); err != nil {
klog.Errorf("Failed to get System Info")
return
}
metricOvnInfo.WithLabelValues(e.Client.System.ID, e.Client.System.RunDir, e.Client.System.Hostname,
e.Client.System.Type, e.Client.System.Version, e.Client.Database.Vswitch.Version,
e.Client.Database.Vswitch.Schema.Version).Set(1)
}

func (e *Exporter) exportOvnLogFileSizeGauge() {
components := []string{
"ovsdb-server-southbound",
Expand Down
17 changes: 0 additions & 17 deletions pkg/ovnmonitor/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ var (
Help: "OVN Health Status. The values are: health(1), unhealth(0).",
})

metricOvnInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: metricNamespace,
Name: "ovn_info",
Help: "This metric provides basic information about OVN. It is always set to 1.",
},
[]string{
"system_id",
"rundir",
"hostname",
"system_type",
"system_version",
"ovs_version",
"db_version",
})

metricRequestErrorNums = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: metricNamespace,
Expand Down Expand Up @@ -466,7 +450,6 @@ var (
func registerOvnMetrics() {
// ovn status metrics
prometheus.MustRegister(metricOvnHealthyStatus)
prometheus.MustRegister(metricOvnInfo)
prometheus.MustRegister(metricRequestErrorNums)
prometheus.MustRegister(metricLogFileSize)
prometheus.MustRegister(metricDBFileSize)
Expand Down
8 changes: 0 additions & 8 deletions pkg/ovnmonitor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ func (e *Exporter) IncrementErrorCounter() {
}

func (e *Exporter) getOvnStatus() (bool, error) {
var err error

if err = e.Client.GetSystemInfo(); err != nil {
klog.Errorf("%s: %v", e.Client.Database.Vswitch.Name, err)
e.IncrementErrorCounter()
return false, err
}

components := []string{
"ovsdb-server-southbound",
"ovsdb-server-northbound",
Expand Down
33 changes: 30 additions & 3 deletions vendor/github.com/greenpau/ovsdb/Makefile

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

1 change: 1 addition & 0 deletions vendor/github.com/greenpau/ovsdb/VERSION

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

3 changes: 3 additions & 0 deletions vendor/github.com/greenpau/ovsdb/go.mod

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

8 changes: 0 additions & 8 deletions vendor/github.com/greenpau/ovsdb/ovn.go

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ github.com/googleapis/gnostic/compiler
github.com/googleapis/gnostic/extensions
github.com/googleapis/gnostic/jsonschema
github.com/googleapis/gnostic/openapiv2
# github.com/greenpau/ovsdb v0.0.0-20181114004433-3582b85e8968
# github.com/greenpau/ovsdb v0.0.0-20181114004433-3582b85e8968 => github.com/alauda/ovsdb v0.0.0-20210113100339-040cf3e76c28
github.com/greenpau/ovsdb
# github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru
Expand Down
12 changes: 2 additions & 10 deletions yamls/ovn-dpdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,10 @@ spec:
value: "false"
- name: NODE_IPS
value: $addresses
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: spec.nodeName
resources:
requests:
cpu: 500m
Expand Down

0 comments on commit f1efaa7

Please sign in to comment.