Skip to content

Commit 3e4b6c6

Browse files
committed
markups
1 parent b362d4b commit 3e4b6c6

File tree

6 files changed

+81
-100
lines changed

6 files changed

+81
-100
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,7 +75,7 @@ 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 section fo this in a MIME
78+
to ensure it's run on first boot. An example section containing this in a MIME
7479
multi-part user-data is:
7580

7681
```bash
@@ -102,3 +107,5 @@ tuning steps:
102107
- Build, install, and activate the `igb_uio` interface driver kernel module.
103108
- Set up recommended core handling behavior.
104109
- 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.

amazon-ebs.pkr.hcl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ variable "tags" {
2626

2727
locals {
2828
default_tags = {
29-
Generated_By = "xrd-packer"
30-
Kubernetes_Version = var.kubernetes_version
31-
Base_AMI_ID = "{{ .SourceAMI }}"
32-
Base_AMI_Name = "{{ .SourceAMIName }}"
29+
Generated_By = "xrd-packer"
30+
Kubernetes_Version = var.kubernetes_version
31+
Base_AMI_ID = "{{ .SourceAMI }}"
32+
Base_AMI_Name = "{{ .SourceAMIName }}"
3333
}
3434
}
3535

@@ -45,7 +45,10 @@ source "amazon-ebs" "base" {
4545
owners = ["amazon"]
4646

4747
filters = {
48-
name = format("amazon-eks-node-al2023-x86_64-standard-%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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ systemctl start hugetlb-gigantic-pages
5252
systemctl enable hugetlb-gigantic-pages
5353

5454
# Add boot cmdline args
55-
non_isolated_cores=$(/etc/xrd/get_non_isolated_cores.sh $ISOLATED_CORES)
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)
5660
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()

files/etc/xrd/get_non_isolated_cores.sh

Lines changed: 0 additions & 92 deletions
This file was deleted.

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -x
55

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

0 commit comments

Comments
 (0)