Skip to content

Commit e0911c4

Browse files
committed
Revert "Revert "Merge pull request #5 from ios-xr/dev/ebeaty_al23""
This reverts commit 6de4afa.
1 parent 6de4afa commit e0911c4

File tree

6 files changed

+107
-15
lines changed

6 files changed

+107
-15
lines changed

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You must have Packer installed, see
1313
[the official instructions](https://developer.hashicorp.com/packer/downloads).
1414

1515
The template has a single mandatory argument, `kubernetes_version`, which
16-
is used to control the Amazon EKS optimized Amazon Linux 2 base AMI that
16+
is used to control the Amazon EKS optimized Amazon Linux 2023 base AMI that
1717
is used to generate the image and also as a tag on the produced image.
1818

1919
To build an AMI:
@@ -47,6 +47,11 @@ packer build \
4747
-var 'tags={"mykey": "myvalue", "myotherkey": "myothervalue"}'
4848
```
4949

50+
Note that when building the AMI, the following warnings are expected and can be ignored:
51+
52+
* When building the igb_uio driver, a warning for 'Skipping BTF generation' is expected. This doesn't affect the performance of the built driver.
53+
* When building TuneD, the 'desktop-file-install' action is expected to fail. This doesn't affect the installation of the tuned service.
54+
5055
## Using AMIs
5156

5257
The AMIs produced by the template here require further configuration
@@ -70,13 +75,23 @@ Additionally, to ensure the worker node joins an EKS cluster, the normal
7075
EKS bootstrap script must be called.
7176

7277
It's recommended to set this up in the User Data for the EC2 instance
73-
to ensure it's run on first boot. An example user data for this is:
78+
to ensure it's run on first boot. An example section containing this in a MIME
79+
multi-part user-data is:
7480

7581
```bash
76-
#!/usr/bin/env bash
82+
MIME-Version: 1.0
83+
Content-Type: multipart/mixed; boundary="BOUNDARY"
84+
85+
<Other MIME sections, including for NodeConfig>
86+
87+
--BOUNDARY
88+
Content-Type: text/x-shellscript; charset="us-ascii"
89+
90+
#!/bin/bash
7791
HUGEPAGES_GB=6 ISOLATED_CORES=16-23 /etc/xrd/bootstrap.sh
78-
/etc/eks/bootstrap.sh my-cluster-name
7992
reboot
93+
94+
--BOUNDARY--
8095
```
8196

8297
## Image Tuning
@@ -88,6 +103,15 @@ The Packer template uses resources in this repository to run the following
88103
tuning steps:
89104
- Install the [TuneD](https://github.com/redhat-performance/tuned) tool.
90105
- Install an XRd TuneD profile, and run it.
106+
- Set up recommended boot cmdline arguments
91107
- Build, install, and activate the `igb_uio` interface driver kernel module.
92108
- Set up recommended core handling behavior.
93109
- Set up hugepage handling for systems with more than one NUMA node.
110+
111+
Note that the TuneD bootloader plugin does not work in Amazon Linux 2023. The packer template matches the cmdline arguments set by the `realtime-virtual-guest` TuneD profile, in addition to the `default_hugepagesz`, `hugepagesz` and `hugepages` arguments.
112+
113+
## Amazon Linux 2
114+
115+
Amazon Linux 2 is EOL.
116+
117+
To create AMIs for AL2, see the AL2 tagged version of XRd Packer.

amazon-ebs.pkr.hcl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ source "amazon-ebs" "base" {
4545
owners = ["amazon"]
4646

4747
filters = {
48-
name = format("amazon-eks-node-%s-*", var.kubernetes_version)
48+
name = format(
49+
"amazon-eks-node-al2023-x86_64-standard-%s-*",
50+
var.kubernetes_version
51+
)
4952
root-device-type = "ebs"
5053
virtualization-type = "hvm"
5154
}

files/etc/xrd/bootstrap.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ tuned-adm active
5050
# Enable and run the hugepage configuration service.
5151
systemctl start hugetlb-gigantic-pages
5252
systemctl enable hugetlb-gigantic-pages
53+
54+
# Add boot cmdline args
55+
# The below arguments are those that the `realtime-virtual-guest` TuneD profile
56+
# sets, in addition to the default_hugepagesz, hugepagesz and hugepages
57+
# arguments. These are set here as the TuneD bootloader plugin does not work
58+
# in the Amazon Linux 2023 image.
59+
non_isolated_cores=$(/etc/xrd/get_non_isolated_cores.py $ISOLATED_CORES)
60+
grubby --update-kernel ALL --args "nohz_full=${ISOLATED_CORES} nohz=on skew_tick=1 intel_pstate=disable tsc=reliable nosoftlockup isolcpus=${ISOLATED_CORES} irqaffinity=${non_isolated_cores} hugepages=${boot_hugepages} rcu_nocbs=${ISOLATED_CORES} hugepagesz=1G default_hugepagesz=1G rcupdate.rcu_normal_after_boot=1"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/python3
2+
3+
import os
4+
import sys
5+
6+
def expand_range(range_str):
7+
"""Expand a range string like '2-4,6' into a list of integers."""
8+
expanded = []
9+
for part in range_str.split(','):
10+
if '-' in part:
11+
start, end = map(int, part.split('-'))
12+
expanded.extend(range(start, end + 1))
13+
else:
14+
expanded.append(int(part))
15+
return expanded
16+
17+
def compress_to_range(cpu_list):
18+
"""Compress a list of integers into a range string like '2-4,6'."""
19+
cpu_list = sorted(cpu_list)
20+
ranges = []
21+
start = cpu_list[0]
22+
end = start
23+
24+
for i in range(1, len(cpu_list)):
25+
if cpu_list[i] == end + 1:
26+
end = cpu_list[i]
27+
else:
28+
if start == end:
29+
ranges.append(str(start))
30+
else:
31+
ranges.append(f"{start}-{end}")
32+
start = cpu_list[i]
33+
end = start
34+
35+
if start == end:
36+
ranges.append(str(start))
37+
else:
38+
ranges.append(f"{start}-{end}")
39+
40+
return ','.join(ranges)
41+
42+
def exclude_cpus(exclude_set_str):
43+
"""Return a CPU set excluding the specified CPUs."""
44+
all_cpus = set(range(os.cpu_count()))
45+
exclude_cpus = set(expand_range(exclude_set_str))
46+
included_cpus = sorted(all_cpus - exclude_cpus)
47+
return compress_to_range(included_cpus)
48+
49+
def main():
50+
if len(sys.argv) < 2:
51+
# No arguments provided, return all CPUs
52+
all_cpus = list(range(os.cpu_count()))
53+
print(compress_to_range(all_cpus))
54+
else:
55+
exclude_set_str = sys.argv[1]
56+
print(exclude_cpus(exclude_set_str))
57+
58+
if __name__ == "__main__":
59+
main()

install.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
set -x
55

66
# Download and build the igb_uio driver, and load it into the kernel.
7-
yum install -y "kernel-devel-$(uname -r)"
7+
# N.B. A warning for 'Skipping BTF generation' is expected. This doesn't affect
8+
# the performance of the built driver.
9+
dnf install -y "kernel-devel-$(uname -r)"
810

911
mkdir igb_uio
1012
curl https://git.dpdk.org/dpdk-kmods/snapshot/dpdk-kmods-e721c733cd24206399bebb8f0751b0387c4c1595.tar.gz | tar -xz -C igb_uio --strip-components 1
@@ -13,12 +15,10 @@ cp igb_uio/linux/igb_uio/igb_uio.ko "/lib/modules/$(uname -r)/kernel/drivers/uio
1315
depmod "$(uname -r)"
1416
rm -rf igb_uio
1517

16-
# Download a much newer version of TuneD that available from the
17-
# Amazon Linux 2 repositories. This fixes several issues with the old
18-
# version available there.
19-
yum install -y \
18+
# TuneD is not available in the Amazon Linux 2023 repository, so download our
19+
# own version instead.
20+
dnf install -y \
2021
dbus \
21-
dbus-python \
2222
ethtool \
2323
gawk \
2424
polkit \
@@ -28,16 +28,14 @@ yum install -y \
2828
python-linux-procfs \
2929
python-perf \
3030
python-pyudev \
31-
python-schedutils \
32-
tuna \
3331
util-linux \
3432
virt-what
3533

3634
mkdir tuned
37-
curl -L https://github.com/redhat-performance/tuned/archive/refs/tags/v2.20.0.tar.gz | tar -xz -C tuned --strip-components 1
35+
curl -L https://github.com/redhat-performance/tuned/archive/refs/tags/v2.24.1.tar.gz | tar -xz -C tuned --strip-components 1
3836
# N.B. The 'desktop-file-install' action is expected to fail. This doesn't
3937
# affect the installation of the tuned service.
40-
make -C tuned PYTHON=/usr/bin/python2 install
38+
make -C tuned install
4139
rm -rf tuned
4240

4341
# Set up the sysctls.

0 commit comments

Comments
 (0)