Skip to content

Commit

Permalink
T3501: Allow using more than one tuned profile
Browse files Browse the repository at this point in the history
  • Loading branch information
natali-rs1985 committed Nov 4, 2024
1 parent ceb64f3 commit 1aada1a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion interface-definitions/include/version/system-version.xml.i
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- include start from include/version/system-version.xml.i -->
<syntaxVersion component='system' version='27'></syntaxVersion>
<syntaxVersion component='system' version='28'></syntaxVersion>
<!-- include end -->
21 changes: 17 additions & 4 deletions interface-definitions/system_option.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,32 @@
<properties>
<help>Tune system performance</help>
<completionHelp>
<list>throughput latency</list>
<list>network-throughput network-latency powersave virtual-host virtual-guest</list>
</completionHelp>
<valueHelp>
<format>throughput</format>
<format>network-throughput</format>
<description>Tune for maximum network throughput</description>
</valueHelp>
<valueHelp>
<format>latency</format>
<format>network-latency</format>
<description>Tune for low network latency</description>
</valueHelp>
<valueHelp>
<format>powersave</format>
<description>Tune for low power consumption</description>
</valueHelp>
<valueHelp>
<format>virtual-guest</format>
<description>Tune for running inside a virtual guest</description>
</valueHelp>
<valueHelp>
<format>virtual-host</format>
<description>Tune for running KVM guests</description>
</valueHelp>
<constraint>
<regex>(throughput|latency)</regex>
<regex>(network-throughput|network-latency|powersave|virtual-guest|virtual-host)</regex>
</constraint>
<multi/>
</properties>
</leafNode>
<node name="http-client">
Expand Down
2 changes: 1 addition & 1 deletion smoketest/config-tests/dialup-router-wireguard-ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ set system login user vyos authentication encrypted-password '$6$2Ta6TWHd/U$NmrX
set system login user vyos authentication plaintext-password ''
set system name-server '172.16.254.30'
set system option ctrl-alt-delete 'ignore'
set system option performance 'latency'
set system option performance 'network-latency'
set system option reboot-on-panic
set system option startup-beep
set system syslog global facility all level 'debug'
Expand Down
2 changes: 1 addition & 1 deletion smoketest/configs/dialup-router-wireguard-ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ system {
}
option {
ctrl-alt-delete ignore
performance latency
performance network-latency
reboot-on-panic
startup-beep
}
Expand Down
10 changes: 6 additions & 4 deletions smoketest/scripts/cli/test_system_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

base_path = ['system', 'option']


class TestSystemOption(VyOSUnitTestSHIM.TestCase):
def tearDown(self):
self.cli_delete(base_path)
Expand Down Expand Up @@ -59,6 +60,7 @@ def test_reboot_on_panic(self):

def test_performance(self):
tuned_service = 'tuned.service'
path = ['system', 'sysctl', 'parameter']

self.assertFalse(is_systemd_service_active(tuned_service))

Expand All @@ -67,11 +69,11 @@ def test_performance(self):
gc_thresh2 = '262000'
gc_thresh3 = '524000'

self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh1', 'value', gc_thresh1])
self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh2', 'value', gc_thresh2])
self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh3', 'value', gc_thresh3])
self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh1', 'value', gc_thresh1])
self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh2', 'value', gc_thresh2])
self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh3', 'value', gc_thresh3])

self.cli_set(base_path + ['performance', 'throughput'])
self.cli_set(base_path + ['performance', 'network-throughput'])
self.cli_commit()

self.assertTrue(is_systemd_service_active(tuned_service))
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/system_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def apply(options):
# wait until daemon has started before sending configuration
while not is_systemd_service_running('tuned.service'):
sleep(0.250)
cmd('tuned-adm profile network-{performance}'.format(**options))
performance = ' '.join(options['performance'])
cmd(f'tuned-adm profile {performance}')
else:
cmd('systemctl stop tuned.service')

Expand Down
33 changes: 33 additions & 0 deletions src/migration-scripts/system/27-to-28
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023-2024 VyOS maintainers and contributors <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.

# rename 'system option performance' leaf nodes to new names

from vyos.configtree import ConfigTree

base = ['system', 'option', 'performance']

def migrate(config: ConfigTree) -> None:
if not config.exists(base):
return

replace = {
'throughput' : 'network-throughput',
'latency' : 'network-latency'
}

for old_name, new_name in replace.items():
if config.return_value(base) == old_name:
config.set(base, new_name)

0 comments on commit 1aada1a

Please sign in to comment.