Skip to content

Commit 0577219

Browse files
jjenne-ciscolegaul-ciscopaulo-ciscoxrdgenLawrence Troup (ltroup)
authored
Update following XR 7.9.1 release (#30)
* Add real-time scheduling host check for XRd vRouter. --------- Co-authored-by: Lewis Gaul <legaul@cisco.com> Co-authored-by: pastanle <pastanle@cisco.com> Co-authored-by: xrdgen <xrdgen@cisco.com> Co-authored-by: Lawrence Troup (ltroup) <ltroup@cisco.com> Co-authored-by: Emma Rankin (emmranki) <emmranki@cisco.com> Co-authored-by: lawrencetroup <lawrencetroup@gmail.com>
1 parent 26a43fe commit 0577219

File tree

4 files changed

+194
-10
lines changed

4 files changed

+194
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
## v1 (active)
55

6-
The v1 release supports Cisco IOS-XR release versions 7.7.1 and 7.8.1.
6+
The v1 release supports Cisco IOS-XR release versions from 7.7.1 to 7.9.1.
7+
8+
### v1.1.9 (2023-05-15)
9+
10+
Changes corresponding to the release of XR version 7.9.1.
11+
12+
- Add check to ensure real-time group scheduling is disabled on the host for XRd vRouter.
13+
714

815
### v1.1.8 (2023-03-08)
916

docs/version-compatibility.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
This file documents compatibility between versions of this project with XR releases.
44
In some cases extra arguments will be required to continue using older XR releases, and those cases will be documented here.
55

6-
76
## v1.1
87

9-
Supports XR 7.7.1 and 7.8.1 (the first and most recent released versions of XRd).
8+
Supports all XR versions between 7.7.1 and 7.9.1 (all released versions of XRd).
9+
10+
See the v1.1 section below for compatibility with XR 7.7.1.
11+
12+
13+
### XR 7.8.1
14+
15+
- The real-time scheduling host check can be ignored before XR version 7.9.1.
16+
1017

1118
### XR 7.7.1
1219

@@ -24,6 +31,7 @@ Supports XR 7.7.1 and 7.8.1 (the first and most recent released versions of XRd)
2431
- Does not support running with `--cgroupns=private`.
2532
- Requires `/sys/fs/cgroup/systemd/` to be mounted read-write on the host.
2633
- Does not support cgroups v2.
34+
- The real-time scheduling host check can be ignored before XR version 7.9.1.
2735

2836

2937
## v1.0

scripts/host-check

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,50 @@ def check_linux_security_modules() -> CheckFuncReturn:
635635
return ch_state, "\n".join(msgs)
636636

637637

638+
def check_realtime_group_sched() -> CheckFuncReturn:
639+
"""Check that real-time group scheduling is disabled"""
640+
recommendation = (
641+
"Running with real-time group scheduling enabled is not supported.\n"
642+
"If real-time group scheduling (RT_GROUP_SCHED) is configured in the kernel,\n"
643+
"it is required that this feature is disabled at runtime by adding\n"
644+
"'kernel.sched_rt_runtime_us=-1' to /etc/sysctl.conf or in a dedicated conf\n"
645+
"file under /etc/sysctl.d/.\n"
646+
"For a temporary fix, run:\n"
647+
" sysctl -w kernel.sched_rt_runtime_us=-1"
648+
)
649+
650+
# We've specified a dependency on the Cgroup check, so can assume this will succeed.
651+
cgroup_version = _get_cgroup_version()
652+
653+
if cgroup_version == 1:
654+
rt_runtime_us_path = "/sys/fs/cgroup/cpu/cpu.rt_runtime_us"
655+
else:
656+
rt_runtime_us_path = "/sys/fs/cgroup/cpu.rt_runtime_us"
657+
658+
if os.path.exists(rt_runtime_us_path):
659+
kernel_sched_rt_path = "/proc/sys/kernel/sched_rt_runtime_us"
660+
try:
661+
with open(kernel_sched_rt_path, "r", encoding="utf-8") as f:
662+
val = int(f.read().strip())
663+
if val != -1:
664+
return (
665+
CheckState.FAILED,
666+
f"The kernel parameter kernel.sched_rt_runtime_us is set to {val}\n"
667+
f"but must be disabled by setting it to '-1'.\n"
668+
+ recommendation,
669+
)
670+
else:
671+
return CheckState.SUCCESS, "disabled at runtime"
672+
except Exception:
673+
return (
674+
CheckState.WARNING,
675+
f"Failed to read {kernel_sched_rt_path}, unable to check if\n"
676+
f"real-time group scheduling is disabled.\n" + recommendation,
677+
)
678+
679+
return CheckState.SUCCESS, "disabled in kernel config"
680+
681+
638682
def check_socket_parameters() -> CheckFuncReturn:
639683
"""Check that socket kernel parameters are set high enough"""
640684
required_params = {
@@ -1360,6 +1404,7 @@ VROUTER_CHECKS = [
13601404
Check("Interface kernel driver", check_interface_kernel_driver, []),
13611405
Check("IOMMU", check_iommu, ["Interface kernel driver"]),
13621406
Check("Shared memory pages max size", check_shmem_pages_max_size, []),
1407+
Check("Real-time Group Scheduling", check_realtime_group_sched, []),
13631408
]
13641409

13651410
DOCKER_CHECKS = [

tests/test_host_check.py

Lines changed: 131 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_no_args(self, capsys):
222222
223223
xrd-vrouter checks
224224
-----------------------
225-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
225+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
226226
227227
==================================================================
228228
XR platforms supported: xrd-control-plane, xrd-vrouter
@@ -371,7 +371,7 @@ def test_extra_check_docker(self, capsys):
371371
372372
xrd-vrouter checks
373373
-----------------------
374-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
374+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
375375
376376
==============================
377377
Extra checks
@@ -408,7 +408,7 @@ def test_extra_check_xr_compose(self, capsys):
408408
409409
xrd-vrouter checks
410410
-----------------------
411-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
411+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
412412
413413
==============================
414414
Extra checks
@@ -447,7 +447,7 @@ def test_all_extra_checks(self, capsys):
447447
448448
xrd-vrouter checks
449449
-----------------------
450-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
450+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
451451
452452
==============================
453453
Extra checks
@@ -510,7 +510,7 @@ def test_no_plats_supported(self, capsys):
510510
511511
xrd-vrouter checks
512512
-----------------------
513-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
513+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
514514
515515
==================================================================
516516
!! Host NOT set up correctly for any XR platforms !!
@@ -539,7 +539,7 @@ def test_one_plat_supported(self, capsys):
539539
540540
xrd-vrouter checks
541541
-----------------------
542-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
542+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
543543
544544
==================================================================
545545
XR platforms supported: xrd-control-plane
@@ -569,7 +569,7 @@ def test_extra_check_not_supported(self, capsys):
569569
570570
xrd-vrouter checks
571571
-----------------------
572-
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size
572+
Checks: CPU extensions, RAM, Hugepages, Interface kernel driver, IOMMU, Shared memory pages max size, Real-time Group Scheduling
573573
574574
==============================
575575
Extra checks
@@ -1436,6 +1436,130 @@ def test_both_enabled(self, capsys):
14361436
assert not success
14371437

14381438

1439+
class TestRealtimeGroupSched(_CheckTestBase):
1440+
"""Tests for Real-time Group Scheduling disabled check"""
1441+
1442+
check_group = "xrd-vrouter"
1443+
check_name = "Real-time Group Scheduling"
1444+
files = ["/proc/sys/kernel/sched_rt_runtime_us"]
1445+
1446+
def test_v1_disabled_in_kernel_config(self, capsys):
1447+
"""Test the v1 case where disabled in kernel config"""
1448+
with mock.patch(
1449+
"host_check._get_cgroup_version", return_value=1
1450+
), mock.patch("os.path.exists", return_value=False):
1451+
success, output = self.perform_check(capsys, read_effects=None)
1452+
assert (
1453+
output
1454+
== "PASS -- Real-time Group Scheduling (disabled in kernel config)\n"
1455+
)
1456+
assert success
1457+
1458+
def test_v1_disabled_at_runtime(self, capsys):
1459+
"""Test the v1 case where disabled at runtime"""
1460+
with mock.patch(
1461+
"host_check._get_cgroup_version", return_value=1
1462+
), mock.patch("os.path.exists", return_value=True):
1463+
success, output = self.perform_check(capsys, read_effects="-1")
1464+
assert (
1465+
output
1466+
== "PASS -- Real-time Group Scheduling (disabled at runtime)\n"
1467+
)
1468+
assert success
1469+
1470+
def test_v1_read_error(self, capsys):
1471+
"""Test the limit being too low."""
1472+
with mock.patch(
1473+
"host_check._get_cgroup_version", return_value=1
1474+
), mock.patch("os.path.exists", return_value=True):
1475+
success, output = self.perform_check(
1476+
capsys, read_effects=Exception
1477+
)
1478+
assert output == textwrap.dedent(
1479+
"""\
1480+
WARN -- Real-time Group Scheduling
1481+
Failed to read /proc/sys/kernel/sched_rt_runtime_us, unable to check if
1482+
real-time group scheduling is disabled.
1483+
Running with real-time group scheduling enabled is not supported.
1484+
If real-time group scheduling (RT_GROUP_SCHED) is configured in the kernel,
1485+
it is required that this feature is disabled at runtime by adding
1486+
'kernel.sched_rt_runtime_us=-1' to /etc/sysctl.conf or in a dedicated conf
1487+
file under /etc/sysctl.d/.
1488+
For a temporary fix, run:
1489+
sysctl -w kernel.sched_rt_runtime_us=-1
1490+
"""
1491+
)
1492+
assert not success
1493+
1494+
def test_v1_failure_enabled_at_runtime(self, capsys):
1495+
"""Test the check fails in the v1 case where enabled at runtime"""
1496+
with mock.patch(
1497+
"host_check._get_cgroup_version", return_value=1
1498+
), mock.patch("os.path.exists", return_value=True):
1499+
success, output = self.perform_check(capsys, read_effects="950000")
1500+
assert output == textwrap.dedent(
1501+
"""\
1502+
FAIL -- Real-time Group Scheduling
1503+
The kernel parameter kernel.sched_rt_runtime_us is set to 950000
1504+
but must be disabled by setting it to '-1'.
1505+
Running with real-time group scheduling enabled is not supported.
1506+
If real-time group scheduling (RT_GROUP_SCHED) is configured in the kernel,
1507+
it is required that this feature is disabled at runtime by adding
1508+
'kernel.sched_rt_runtime_us=-1' to /etc/sysctl.conf or in a dedicated conf
1509+
file under /etc/sysctl.d/.
1510+
For a temporary fix, run:
1511+
sysctl -w kernel.sched_rt_runtime_us=-1
1512+
"""
1513+
)
1514+
assert not success
1515+
1516+
def test_v2_disabled_in_kernel_config(self, capsys):
1517+
"""Test the v2 case where disabled in kernel config"""
1518+
with mock.patch(
1519+
"host_check._get_cgroup_version", return_value=2
1520+
), mock.patch("os.path.exists", return_value=False):
1521+
success, output = self.perform_check(capsys, read_effects=None)
1522+
assert (
1523+
output
1524+
== "PASS -- Real-time Group Scheduling (disabled in kernel config)\n"
1525+
)
1526+
assert success
1527+
1528+
def test_v2_disabled_at_runtime(self, capsys):
1529+
"""Test the v2 case where disabled at runtime"""
1530+
with mock.patch(
1531+
"host_check._get_cgroup_version", return_value=2
1532+
), mock.patch("os.path.exists", return_value=True):
1533+
success, output = self.perform_check(capsys, read_effects="-1")
1534+
assert (
1535+
output
1536+
== "PASS -- Real-time Group Scheduling (disabled at runtime)\n"
1537+
)
1538+
assert success
1539+
1540+
def test_v2_failure_enabled_at_runtime(self, capsys):
1541+
"""Test the check fails in the v2 case where enabled at runtime"""
1542+
with mock.patch(
1543+
"host_check._get_cgroup_version", return_value=2
1544+
), mock.patch("os.path.exists", return_value=True):
1545+
success, output = self.perform_check(capsys, read_effects="950000")
1546+
assert output == textwrap.dedent(
1547+
"""\
1548+
FAIL -- Real-time Group Scheduling
1549+
The kernel parameter kernel.sched_rt_runtime_us is set to 950000
1550+
but must be disabled by setting it to '-1'.
1551+
Running with real-time group scheduling enabled is not supported.
1552+
If real-time group scheduling (RT_GROUP_SCHED) is configured in the kernel,
1553+
it is required that this feature is disabled at runtime by adding
1554+
'kernel.sched_rt_runtime_us=-1' to /etc/sysctl.conf or in a dedicated conf
1555+
file under /etc/sysctl.d/.
1556+
For a temporary fix, run:
1557+
sysctl -w kernel.sched_rt_runtime_us=-1
1558+
"""
1559+
)
1560+
assert not success
1561+
1562+
14391563
class TestSocketParameters(_CheckTestBase):
14401564
"""Tests for Socket Kernel Parameters check."""
14411565

0 commit comments

Comments
 (0)