Skip to content

Commit ac3e574

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 only take effect after restarting a pod. Resolves: OSPRH-6429 Signed-off-by: Elvira Garcia <[email protected]>
1 parent 54e2a6b commit ac3e574

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-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).

pkg/ovncontroller/daemonset.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func CreateOVNDaemonSet(
6363
fmt.Sprintf("--certificate=%s", ovn_common.OVNDbCertPath),
6464
fmt.Sprintf("--private-key=%s", ovn_common.OVNDbKeyPath),
6565
fmt.Sprintf("--ca-cert=%s", ovn_common.OVNDbCaCertPath),
66+
fmt.Sprintf("--verbose=%s", instance.Spec.OVNLogLevel),
6667
}...)
6768
}
6869

@@ -238,6 +239,7 @@ func CreateOVSDaemonSet(
238239

239240
envVars := map[string]env.Setter{}
240241
envVars["CONFIG_HASH"] = env.SetValue(configHash)
242+
envVars["OVSLogLevel"] = env.SetValue(instance.Spec.OVSLogLevel)
241243

242244
initContainers := []corev1.Container{
243245
{

templates/ovncontroller/bin/functions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ OVNAvailabilityZones=${OVNAvailabilityZones:-""}
2222
EnableChassisAsGateway=${EnableChassisAsGateway:-true}
2323
PhysicalNetworks=${PhysicalNetworks:-""}
2424
OVNHostName=${OVNHostName:-""}
25+
OVSLogLevel=${OVSLogLevel:-"info"}
2526
DB_FILE=/etc/openvswitch/conf.db
2627

2728
ovs_dir=/var/lib/openvswitch

templates/ovncontroller/bin/start-ovsdb-server.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ ovsdb-server ${DB_FILE} \
2626
--remote=punix:/var/run/openvswitch/db.sock \
2727
--private-key=db:Open_vSwitch,SSL,private_key \
2828
--certificate=db:Open_vSwitch,SSL,certificate \
29+
--verbose=${OVSLogLevel}
2930
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert

templates/ovncontroller/bin/start-vswitchd.sh

Lines changed: 4 additions & 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,
@@ -52,6 +53,9 @@ cleanup_flows_backup
5253
# Now, inform vswitchd that we are done.
5354
ovs-vsctl remove open_vswitch . other_config flow-restore-wait
5455

56+
# Set the log level for ovs-vswitchd
57+
/usr/bin/ovs-appctl vlog/set ${OVSLogLevel}
58+
5559
# This is container command script. Block it from exiting, otherwise k8s will
5660
# restart the container again.
5761
tail -f /var/log/openvswitch/ovs-vswitchd.log

0 commit comments

Comments
 (0)