Skip to content

Commit 34a19fc

Browse files
authored
fix(tuned): version-aware profile directory (#86)
## Summary The `tuned` package now deploys and verifies custom tuned profiles in the directory the installed tuned version actually reads from: - tuned >= 2.23.0: `/etc/tuned/profiles` - older tuned: `/etc/tuned` Before this change, profiles were written only to the legacy `/etc/tuned/<profile>` location, which tuned >= 2.23.0 no longer searches by default (the default `profile_dirs` became the `profiles/` subdirectories in tuned 2.23.0). On distros shipping tuned >= 2.23.0 (RHEL 9.5+, newer Ubuntu/Debian) `tuned-adm profile` could not find the profiles. ## Changes - `skyhook_dir/utils.sh`: new `get_tuned_version` and `resolve_tuned_profiles_dir` helpers (the latter sets `TUNED_PROFILES_DIR` from the installed version); refactored `check_tuned_version_for_multiple_profiles` to reuse `get_tuned_version` (its 2.24 multi-profile boundary is unchanged). - `skyhook_dir/apply_tuned_profile.sh`, `apply_tuned_profile_check.sh`, `post_interrupt_tuned_check.sh`: deploy and verify custom profiles under the resolved directory. `/etc/tuned/scripts` (the `_script` deploy dir) is unchanged. - `config.json`: `package_version` 1.0.0 -> 1.3.0 (minor bump; the release aggregates unreleased `feat(tuned)` commits since `tuned/1.2.0`). - `RELEASE_NOTES.md`, `README.md`: document the version-aware directory. ## Notes - This is Part 1 of 2. Part 2 updates the `nvidia-tuned` package (which inherits this `utils.sh` from the `tuned` base image) and will follow after `tuned/1.3.0` is tagged and its image is published. - After merge, tag `tuned/1.3.0` to build and publish the image. - The Docker-based integration suite and `make validate-standalone` were not run locally; `shellcheck` (only pre-existing SC2002 style findings) and `make license-check` pass. --------- Signed-off-by: Alex Yuskauskas <ayuskauskas@nvidia.com>
1 parent 88a9ad7 commit 34a19fc

7 files changed

Lines changed: 74 additions & 15 deletions

File tree

tuned/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ tuned/
6666
- **Script**: `apply_tuned_profile.sh`
6767
- **Purpose**: Deploys custom profiles and applies the specified tuned profile
6868
- **Process**:
69-
1. Creates custom profile directories in `/etc/tuned/`
69+
1. Creates custom profile directories in the tuned profiles dir (`/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
7070
2. Copies configmap files as `tuned.conf` for each custom profile
7171
3. Reads the target profile from `tuned_profile` configmap file
7272
4. Applies the specified profile using `tuned-adm profile`
@@ -151,7 +151,7 @@ The package expects configmaps to be available in `${SKYHOOK_DIR}/configmaps/`:
151151
- **Custom profile files**: Any files in the configmaps directory (except `tuned_profile` and `*_script` files) will be treated as custom tuned profile configurations
152152
- File name becomes the profile name
153153
- File contents become the `tuned.conf` for that profile
154-
- Files are deployed to `/etc/tuned/<profile_name>/tuned.conf`
154+
- Files are deployed to `<profiles_dir>/<profile_name>/tuned.conf` (`<profiles_dir>` is `/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
155155
156156
- **Script files**: Any files ending with `_script` will be deployed as executable scripts to `/etc/tuned/scripts/`
157157
- File name pattern: `<name>_script` (e.g., `setup_script`, `my_optimization_script`)
@@ -343,11 +343,11 @@ Use `tuned-adm list` to see all available profiles on your system or go to [tune
343343

344344
2. **Profile not found**
345345
- List available profiles: `tuned-adm list`
346-
- Check custom profile deployment in `/etc/tuned/`
346+
- Check custom profile deployment in the tuned profiles dir (`/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
347347

348348
3. **Permission errors**
349349
- Ensure scripts run with appropriate privileges
350-
- Check `/etc/tuned/` directory permissions
350+
- Check tuned profiles dir permissions (`/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
351351

352352
4. **Verification errors**
353353
- Check verification: `tuned-adm verify`

tuned/RELEASE_NOTES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ example is not itself picked up as release notes):
1919
2020
- Notable behavior change worth calling out.
2121
-->
22+
23+
## 1.3.0
24+
25+
- Custom tuned profiles are now deployed to the directory the installed tuned
26+
version reads from. On tuned >= 2.23.0 that is `/etc/tuned/profiles`; on older
27+
tuned it remains `/etc/tuned`. No action is required.
28+
- This is driven by newer distributions shipping tuned >= 2.23.0, which reads
29+
profiles only from the `profiles/` subdirectory. In particular, Ubuntu 26.04
30+
installs tuned 2.25, so profiles written to the old `/etc/tuned/<profile>`
31+
location were no longer picked up.

tuned/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schema_version": "v1",
33
"package_name": "tuned",
4-
"package_version": "1.0.0",
4+
"package_version": "1.3.0",
55
"expected_config_files": [],
66
"modes": {
77
"uninstall": [

tuned/skyhook_dir/apply_tuned_profile.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
# SPDX-License-Identifier: Apache-2.0
@@ -26,7 +26,9 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2626
source "${SCRIPT_DIR}/utils.sh"
2727

2828
CONFIGMAP_DIR="${SKYHOOK_DIR}/configmaps"
29-
TUNED_DIR="/etc/tuned"
29+
# Deploy custom profiles where the installed tuned version reads them.
30+
resolve_tuned_profiles_dir
31+
TUNED_DIR="${TUNED_PROFILES_DIR}"
3032
SCRIPTS_DIR="/etc/tuned/scripts"
3133

3234
# ensure tuned directory exists
@@ -74,7 +76,7 @@ done
7476
# Supports multiple space-separated profiles, e.g., "hpc-compute aws"
7577
TUNED_PROFILE_FILE="$CONFIGMAP_DIR/tuned_profile"
7678
if [ -f "$TUNED_PROFILE_FILE" ]; then
77-
tuned_profiles=$(cat "$TUNED_PROFILE_FILE" | xargs) # read and trim
79+
tuned_profiles=$(xargs < "$TUNED_PROFILE_FILE") # read and trim
7880

7981
# Count the number of profiles
8082
# shellcheck disable=SC2086

tuned/skyhook_dir/apply_tuned_profile_check.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
# SPDX-License-Identifier: Apache-2.0
@@ -25,7 +25,9 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2525
source "${SCRIPT_DIR}/utils.sh"
2626

2727
CONFIGMAP_DIR="${SKYHOOK_DIR}/configmaps"
28-
TUNED_DIR="/etc/tuned"
28+
# Verify custom profiles where the installed tuned version reads them.
29+
resolve_tuned_profiles_dir
30+
TUNED_DIR="${TUNED_PROFILES_DIR}"
2931
SCRIPTS_DIR="/etc/tuned/scripts"
3032

3133
# check tuned service is installed and running
@@ -105,7 +107,7 @@ TUNED_PROFILE_FILE="$CONFIGMAP_DIR/tuned_profile"
105107
if [ ! -f "$TUNED_PROFILE_FILE" ]; then
106108
echo "WARNING: tuned_profile file missing in $CONFIGMAP_DIR"
107109
else
108-
tuned_profiles=$(cat "$TUNED_PROFILE_FILE" | xargs)
110+
tuned_profiles=$(xargs < "$TUNED_PROFILE_FILE")
109111

110112
# Count the number of profiles
111113
# shellcheck disable=SC2086

tuned/skyhook_dir/post_interrupt_tuned_check.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
# SPDX-License-Identifier: Apache-2.0
@@ -19,8 +19,15 @@
1919

2020
set -x
2121

22+
# Source shared utilities
23+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24+
# shellcheck source=utils.sh
25+
source "${SCRIPT_DIR}/utils.sh"
26+
2227
CONFIGMAP_DIR="${SKYHOOK_DIR}/configmaps"
23-
TUNED_DIR="/etc/tuned"
28+
# Verify custom profiles where the installed tuned version reads them.
29+
resolve_tuned_profiles_dir
30+
TUNED_DIR="${TUNED_PROFILES_DIR}"
2431
SCRIPTS_DIR="/etc/tuned/scripts"
2532

2633
# check tuned service is installed and running
@@ -100,7 +107,7 @@ TUNED_PROFILE_FILE="$CONFIGMAP_DIR/tuned_profile"
100107
if [ ! -f "$TUNED_PROFILE_FILE" ]; then
101108
echo "WARNING: tuned_profile file missing in $CONFIGMAP_DIR"
102109
else
103-
tuned_profiles=$(cat "$TUNED_PROFILE_FILE" | xargs)
110+
tuned_profiles=$(xargs < "$TUNED_PROFILE_FILE")
104111

105112
# Validate each profile exists
106113
available_profiles=$(tuned-adm list)

tuned/skyhook_dir/utils.sh

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ check_tuned_version_for_multiple_profiles() {
3232

3333
# Get tuned version (format: "tuned 2.21.0")
3434
local tuned_version
35-
tuned_version=$(tuned --version 2>/dev/null | awk '{print $2}')
35+
tuned_version="$(get_tuned_version)"
3636

3737
if [ -z "$tuned_version" ]; then
3838
echo "ERROR: Could not determine tuned version"
@@ -60,3 +60,41 @@ check_tuned_version_for_multiple_profiles() {
6060

6161
echo "tuned version $tuned_version supports multiple profiles"
6262
}
63+
64+
# Get the installed tuned version string (e.g. "2.23.0").
65+
# Echoes an empty string if tuned is not installed or the version cannot be parsed.
66+
get_tuned_version() {
67+
tuned --version 2>/dev/null | awk '{print $2}'
68+
}
69+
70+
# Set TUNED_PROFILES_DIR to the single directory all tuned profiles should be
71+
# deployed to, based on the installed tuned version. tuned >= 2.23.0 reads
72+
# profiles only from the profiles/ subdirectory (/etc/tuned/profiles); older
73+
# tuned reads them directly from /etc/tuned. We deploy everything to this one
74+
# user directory and write nothing to /usr/lib/tuned (tuned resolves include=
75+
# targets across all profile_dirs, and the user dir takes precedence).
76+
# Exits 1 if the tuned version cannot be determined.
77+
resolve_tuned_profiles_dir() {
78+
local tuned_version major minor
79+
tuned_version="$(get_tuned_version)"
80+
if [ -z "$tuned_version" ]; then
81+
echo "ERROR: Could not determine tuned version"
82+
exit 1
83+
fi
84+
85+
major="$(echo "$tuned_version" | cut -d. -f1)"
86+
minor="$(echo "$tuned_version" | cut -d. -f2)"
87+
88+
if ! [[ "$major" =~ ^[0-9]+$ ]] || ! [[ "$minor" =~ ^[0-9]+$ ]]; then
89+
echo "ERROR: Could not parse tuned version: $tuned_version"
90+
exit 1
91+
fi
92+
93+
if [[ "$major" -gt 2 ]] || { [[ "$major" -eq 2 ]] && [[ "$minor" -ge 23 ]]; }; then
94+
TUNED_PROFILES_DIR="/etc/tuned/profiles"
95+
else
96+
TUNED_PROFILES_DIR="/etc/tuned"
97+
fi
98+
99+
echo "tuned $tuned_version: profiles dir is $TUNED_PROFILES_DIR"
100+
}

0 commit comments

Comments
 (0)