Skip to content

Commit 183d5f3

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 183d5f3

File tree

7 files changed

+45
-0
lines changed

7 files changed

+45
-0
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020
source $(dirname $0)/../container-scripts/functions
2121

2222
OVNEncapTos={{.OVNEncapTos}}
23+
OVSLogLevel={{.OVSLogLevel}}
24+
OVNLogLevel={{.OVNLogLevel}}
2325

2426
function configure_ovn_external_ids {
2527
ovs-vsctl set open . external-ids:ovn-encap-tos=${OVNEncapTos}
2628
}
2729

30+
function configure_log_level {
31+
ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.5.ctl vlog/set ${OVSLogLevel}
32+
ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.11.ctl vlog/set ${OVSLogLevel}
33+
ovn-appctl -t /var/run/ovn/ovn-controller.1.ctl vlog/set ${OVNLogLevel}
34+
}
35+
36+
2837
wait_for_ovsdb_server
2938
configure_ovn_external_ids
39+
configure_log_level

0 commit comments

Comments
 (0)