282f6af3db
By default, mlockall() is enabled for ovs-vswitchd. This results in locking all of ovs-vswitchd's process memory into physical RAM and prevents paging. This enables network performance but can lead to memory exhaustion in memory-constrained environments. To disable mlockall(), the disable-mlockall charm config option can be set to True. If unset, disable-mlockall charm config will result in disabling mlockall if running in a container. The drop_config.append(OVS_DEFAULT) logic is no longer used as it prevents a rewrite of the config template when charm config is reset. For example, the new behavior results in /etc/default/openvswitch-switch being written with comments only when the corresponding config options are disabled (see template), resulting in openvswitch-switch being restarted. Due to the removal of drop_config.append(OVS_DEFAULT), pause/resume actions need to explicitly remove openswitch-switch to maintain prior behavior for non-DPDK deployments. In other words, pause/resume will not restart openvswitch-switch. Closes-Bug: #1906280 Related-Bug: #1908615 Change-Id: I2e3153e90c7a4a1b7dec7d6df427b33a449f414d
67 lines
1.8 KiB
Python
Executable File
67 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Copyright 2016 Canonical Ltd
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.append('hooks/')
|
|
|
|
from charmhelpers.core.hookenv import action_fail
|
|
from neutron_ovs_utils import (
|
|
pause_unit_helper,
|
|
resume_unit_helper,
|
|
register_configs,
|
|
)
|
|
|
|
|
|
def pause(args):
|
|
"""Pause the neutron-openvswitch services.
|
|
@raises Exception should the service fail to stop.
|
|
"""
|
|
pause_unit_helper(register_configs(),
|
|
exclude_services=['openvswitch-switch'])
|
|
|
|
|
|
def resume(args):
|
|
"""Resume the neutron-openvswitch services.
|
|
@raises Exception should the service fail to start."""
|
|
resume_unit_helper(register_configs(),
|
|
exclude_services=['openvswitch-switch'])
|
|
|
|
|
|
# A dictionary of all the defined actions to callables (which take
|
|
# parsed arguments).
|
|
ACTIONS = {"pause": pause, "resume": resume}
|
|
|
|
|
|
def main(args):
|
|
action_name = os.path.basename(args[0])
|
|
try:
|
|
action = ACTIONS[action_name]
|
|
except KeyError:
|
|
s = "Action {} undefined".format(action_name)
|
|
action_fail(s)
|
|
return s
|
|
else:
|
|
try:
|
|
action(args)
|
|
except Exception as e:
|
|
action_fail("Action {} failed: {}".format(action_name, str(e)))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv))
|