Skip to content

Commit 79a131e

Browse files
committed
Set logging level in ovn-controller
OVNLogLevel affects ovncontroller logs and OVSLogLevel affects ovs-vswitchd and ovsdb-server. Both OVNLogLevel and OVSLogLevel can take values from the vlog range: off, emer, err, warn, info, or dbg See ovs-appctl(8) for a definition of each log level. The change of the log level will be modified from the config pod and not on the pod itself to avoid restarting ovn-controller and ovn-controller-ovs pods. Resolves: OSPRH-6429 Signed-off-by: Elvira Garcia <[email protected]>
1 parent 54e2a6b commit 79a131e

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

api/bases/ovn.openstack.org_ovncontrollers.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,20 @@ spec:
147147
description: Image used for the ovn-controller container (will be
148148
set to environmental default if empty)
149149
type: string
150+
ovnLogLevel:
151+
default: info
152+
description: OVNLogLevel - Set log level off, emer, err, warn, info,
153+
or dbg. Default is info.
154+
type: string
150155
ovsContainerImage:
151156
description: Image used for the ovsdb-server and ovs-vswitchd containers
152157
(will be set to environmental default if empty)
153158
type: string
159+
ovsLogLevel:
160+
default: info
161+
description: OVSLogLevel - Set log level off, emer, err, warn, info,
162+
or dbg. Default is info.
163+
type: string
154164
resources:
155165
description: |-
156166
Resources - Compute Resources required by this service (Limits/Requests).

api/v1beta1/ovncontroller_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ type OVNControllerSpecCore struct {
9494
// If specified the IP address of this network is used as the OVNEncapIP.
9595
NetworkAttachment string `json:"networkAttachment"`
9696

97+
// +kubebuilder:validation:Optional
98+
// +kubebuilder:default=info
99+
// OVNLogLevel - Set log level off, emer, err, warn, info, or dbg. Default is info.
100+
OVNLogLevel string `json:"ovnLogLevel,omitempty"`
101+
102+
// +kubebuilder:validation:Optional
103+
// +kubebuilder:default=info
104+
// OVSLogLevel - Set log level off, emer, err, warn, info, or dbg. Default is info.
105+
OVSLogLevel string `json:"ovsLogLevel,omitempty"`
106+
97107
// +kubebuilder:validation:Optional
98108
// +operator-sdk:csv:customresourcedefinitions:type=spec
99109
// TLS - Parameters related to TLS

config/crd/bases/ovn.openstack.org_ovncontrollers.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,20 @@ spec:
147147
description: Image used for the ovn-controller container (will be
148148
set to environmental default if empty)
149149
type: string
150+
ovnLogLevel:
151+
default: info
152+
description: OVNLogLevel - Set log level off, emer, err, warn, info,
153+
or dbg. Default is info.
154+
type: string
150155
ovsContainerImage:
151156
description: Image used for the ovsdb-server and ovs-vswitchd containers
152157
(will be set to environmental default if empty)
153158
type: string
159+
ovsLogLevel:
160+
default: info
161+
description: OVSLogLevel - Set log level off, emer, err, warn, info,
162+
or dbg. Default is info.
163+
type: string
154164
resources:
155165
description: |-
156166
Resources - Compute Resources required by this service (Limits/Requests).

controllers/ovncontroller_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ func (r *OVNControllerReconciler) generateServiceConfigMaps(
943943
// Add additional ConfigMap for extra configuration scripts
944944
extraScriptsTemplateParameters := make(map[string]any)
945945
extraScriptsTemplateParameters["OVNEncapTos"] = instance.Spec.ExternalIDS.OvnEncapTos
946+
extraScriptsTemplateParameters["OVSLogLevel"] = instance.Spec.OVSLogLevel
947+
extraScriptsTemplateParameters["OVNLogLevel"] = instance.Spec.OVNLogLevel
946948

947949
extraCms := []util.Template{
948950
{

pkg/ovncontroller/configjob.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func ConfigJob(
6464
envVars["OVNAvailabilityZones"] = env.SetValue(strings.Join(instance.Spec.ExternalIDS.OvnAvailabilityZones, ":"))
6565
envVars["PhysicalNetworks"] = env.SetValue(getPhysicalNetworks(instance))
6666
envVars["OVNHostName"] = env.DownwardAPI("spec.nodeName")
67+
envVars["OVNLogLevel"] = env.SetValue(instance.Spec.OVNLogLevel)
68+
envVars["OVSLogLevel"] = env.SetValue(instance.Spec.OVSLogLevel)
6769

6870
for _, ovnPod := range ovnPods.Items {
6971
commands := []string{

templates/ovncontroller/bin/start-vswitchd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# under the License.
1616

1717
source $(dirname $0)/functions
18+
1819
wait_for_ovsdb_server
1920

2021
# The order - first wait for db server, then set -ex - is important. Otherwise,

templates/ovncontroller/config/configure-ovn.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,30 @@
1515
# under the License.
1616

1717
# This script configures ovn-encap-tos setting in OVS external-ids
18-
# It is only used when ovn-encap-tos is explicitly set to a non-default value
18+
# It is used when ovn-encap-tos is explicitly set to a non-default value or
19+
# when OVN or OVS log level values change.
1920

2021
source $(dirname $0)/../container-scripts/functions
2122

2223
OVNEncapTos={{.OVNEncapTos}}
24+
OVSLogLevel={{.OVSLogLevel}}
25+
OVNLogLevel={{.OVNLogLevel}}
2326

2427
function configure_ovn_external_ids {
2528
ovs-vsctl set open . external-ids:ovn-encap-tos=${OVNEncapTos}
2629
}
2730

31+
function configure_log_level {
32+
for svc in ovsdb-server ovs-vswitchd; do
33+
ctl_path=$(find /var/run/openvswitch/ -maxdepth 1 -name "${svc}.*.ctl")
34+
ovs-appctl -t ${ctl_path} vlog/set ${OVSLogLevel}
35+
done
36+
37+
ctl_path=$(find /var/run/ovn/ -maxdepth 1 -name "ovn-controller.*.ctl")
38+
ovn-appctl -t "$ctl_path" vlog/set ${OVNLogLevel}
39+
}
40+
41+
2842
wait_for_ovsdb_server
2943
configure_ovn_external_ids
44+
configure_log_level

0 commit comments

Comments
 (0)