Skip to content

Commit 7ac946a

Browse files
authored
fix(nvidia-tuned): version-aware profile directory on tuned 1.3.1 base (#87)
## Summary Part 2 of the version-aware tuned profile directory change. The `nvidia-tuned` package now deploys and verifies all NVIDIA tuned profiles in the single directory the installed tuned version reads from: - tuned >= 2.23.0: `/etc/tuned/profiles` - older tuned: `/etc/tuned` Everything (common base, OS, and service profiles) goes to that one directory; nothing is written to `/usr/lib/tuned`. This fixes profiles being invisible to tuned on distros shipping tuned >= 2.23.0. > Stacked on #86 (the `tuned` package change that adds the shared `resolve_tuned_profiles_dir` helper). This PR's base is the #86 branch so the diff shows only the Part 2 commits. After #86 merges, I will retarget the base to `main` (rebasing if #86 is squash-merged). ## Changes - `skyhook_dir/prepare_nvidia_profiles.sh`: sources the inherited `utils.sh`, resolves `TUNED_PROFILES_DIR`, and deploys common + OS + service profiles to that single dir (drops the old `/usr/lib/tuned` system dir). - `skyhook_dir/prepare_nvidia_profiles_check.sh`: sources `utils.sh` and verifies under the resolved dir. - `tests/integration/nvidia_tuned/test_prepare_nvidia_profiles.py`: derives the expected dir from the container's tuned version and injects the parent `utils.sh` into test containers. - `Dockerfile`: `ARG TUNED_VERSION` 1.2.0 -> 1.3.0 (the Part 1 release). - `config.json`: `package_version` 0.3.0 -> 0.3.1. - `RELEASE_NOTES.md`, `README.md`: document the version-aware directory. ## Sequencing - Depends on #86: this needs `ghcr.io/nvidia/skyhook-packages/tuned:1.3.0` published, so `make validate-inherited` and the CI dev build will not pass until #86 is merged, tagged `tuned/1.3.0`, and its image is published. - After merge, tag `nvidia-tuned/0.3.1`. ## Testing The Docker-based integration suite and `make validate-inherited` were not run locally (they require the published `tuned:1.3.0` base image). In-session gates pass: `shellcheck` (no new findings beyond pre-existing style items), `python -m py_compile` on the test file, and `make license-check`. Signed-off-by: Alex Yuskauskas <ayuskauskas@nvidia.com>
1 parent 1cb86cc commit 7ac946a

7 files changed

Lines changed: 175 additions & 110 deletions

File tree

nvidia-tuned/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
ARG TUNED_VERSION=1.2.0
16+
ARG TUNED_VERSION=1.3.1
1717

18-
FROM ghcr.io/nvidia/skyhook-packages/tuned:${TUNED_VERSION}
18+
FROM ghcr.io/nvidia/nodewright-packages/tuned:${TUNED_VERSION}
1919

2020
COPY ./ /skyhook-package
2121

nvidia-tuned/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A NodeWright package that extends the base `tuned` package with NVIDIA-specific
66

77
This package inherits from the base `tuned` package and adds pre-configured tuned profiles optimized for NVIDIA hardware. The profiles are organized by:
88

9-
- **Common base profiles**: Foundational settings deployed to `/usr/lib/tuned/`
9+
- **Common base profiles**: Foundational settings deployed to the tuned profiles dir (`/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
1010
- **OS-specific workload profiles**: Profiles that may vary by OS version
1111
- **Service profiles**: Service-specific settings (eks, GCP, etc.)
1212

@@ -36,7 +36,7 @@ This package requires **tuned >= 2.19**. The following operating systems are sup
3636

3737
```
3838
profiles/
39-
├── common/ # Base profiles → /usr/lib/tuned/
39+
├── common/ # Base profiles → tuned profiles dir
4040
│ ├── nvidia-base/
4141
│ └── nvidia-acs-disable/
4242
├── os/
@@ -78,9 +78,9 @@ Note: Profiles are stored in `profiles/` (not `root_dir/`) to avoid polluting th
7878
1. **Prepare stage**: `prepare_nvidia_profiles.sh` runs:
7979
- Reads `intent` and `accelerator` from the configmap
8080
- Constructs the profile name as `nvidia-{accelerator}-{intent}`
81-
- Deploys common base profiles to `/usr/lib/tuned/`
81+
- Deploys common base profiles to the resolved tuned profiles dir
8282
- Detects OS from `/etc/os-release`
83-
- Copies the appropriate OS-specific workload profiles to `/etc/tuned/`
83+
- Copies the appropriate OS-specific workload profiles to the resolved tuned profiles dir (`/etc/tuned/profiles` on tuned >= 2.23, else `/etc/tuned`)
8484
- If a `service` is specified, creates service profile with dynamic `include=` pointing to the workload profile
8585

8686
2. **Config stage**: The inherited `tuned` package applies the configured profile

nvidia-tuned/RELEASE_NOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ example is not itself picked up as release notes):
1919
2020
- Notable behavior change worth calling out.
2121
-->
22+
23+
## 0.3.1
24+
25+
- NVIDIA tuned profiles are now deployed to the directory the installed tuned
26+
version reads from (`/etc/tuned/profiles` on tuned >= 2.23.0, else `/etc/tuned`),
27+
fixing profiles being invisible to tuned on distros shipping tuned >= 2.23.0.
28+
All profiles, including the common base profiles, now live in that one
29+
directory; nothing is written to `/usr/lib/tuned`. No action is required.

nvidia-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": "nvidia_tuned",
4-
"package_version": "0.3.0",
4+
"package_version": "0.3.1",
55
"expected_config_files": ["accelerator"],
66
"modes": {
77
"uninstall": [

nvidia-tuned/skyhook_dir/prepare_nvidia_profiles.sh

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020
# 1. Reading intent, accelerator, and service from configmap
2121
# 2. Constructing the workload profile name as nvidia-{accelerator}-{intent}
2222
# 3. Final profile name: {service}-{accelerator}-{intent} when service is set, else workload profile name
23-
# 4. Copying common base profiles to /usr/lib/tuned/
23+
# 4. Copying common base profiles to the resolved profiles directory
2424
# 5. Selecting the appropriate OS-specific workload profiles
2525
# 6. Setting up the service profile with dynamic include
2626

2727
set -xe
2828
set -u
2929

30+
# Source shared utilities (inherited from the tuned base image)
31+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
32+
# shellcheck source=utils.sh
33+
source "${SCRIPT_DIR}/utils.sh"
34+
3035
CONFIGMAP_DIR="${SKYHOOK_DIR}/configmaps"
3136
PROFILES_DIR="${SKYHOOK_DIR}/profiles"
32-
TUNED_SYSTEM_DIR="/usr/lib/tuned"
33-
TUNED_USER_DIR="/etc/tuned"
3437

3538
# Read configmap fields
3639
INTENT_FILE="$CONFIGMAP_DIR/intent"
@@ -65,16 +68,16 @@ build_profile_name() {
6568
echo "nvidia-${accelerator}-${intent}"
6669
}
6770

68-
# Copy common base profiles to /usr/lib/tuned/
71+
# Copy common base profiles to the resolved tuned profiles dir
6972
deploy_common_profiles() {
70-
echo "Deploying common profiles to $TUNED_SYSTEM_DIR..."
73+
echo "Deploying common profiles to $TUNED_PROFILES_DIR..."
7174

7275
if [ -d "$PROFILES_DIR/common" ]; then
7376
for profile_dir in "$PROFILES_DIR/common"/*/; do
7477
[ -d "$profile_dir" ] || continue
7578
profile_name=$(basename "$profile_dir")
76-
rm -rf "$TUNED_SYSTEM_DIR/$profile_name"
77-
cp -rL "$profile_dir" "$TUNED_SYSTEM_DIR/$profile_name"
79+
rm -rf "${TUNED_PROFILES_DIR:?}/$profile_name"
80+
cp -rL "$profile_dir" "$TUNED_PROFILES_DIR/$profile_name"
7881
echo "Deployed common profile: $profile_name"
7982
done
8083
else
@@ -84,18 +87,25 @@ deploy_common_profiles() {
8487

8588
# Deploy ALL OS-specific workload profiles
8689
deploy_os_profiles() {
87-
echo "Deploying OS profiles to $TUNED_USER_DIR..."
90+
echo "Deploying OS profiles to $TUNED_PROFILES_DIR..."
91+
92+
mkdir -p "$TUNED_PROFILES_DIR"
8893

89-
mkdir -p "$TUNED_USER_DIR"
94+
# Track what this function deploys. Since all profiles now share one
95+
# directory (common base profiles are deployed here first), checking the
96+
# directory's overall contents no longer tells us whether OS profiles were
97+
# found, so track it explicitly instead.
98+
local deployed_any=false
9099

91100
# Always deploy from os/common first (provides all profiles)
92101
if [ -d "$PROFILES_DIR/os/common" ]; then
93102
echo "Deploying common OS profiles from: os/common"
94103
for profile_dir in "$PROFILES_DIR/os/common"/*/; do
95104
[ -d "$profile_dir" ] || continue
96105
profile_name=$(basename "$profile_dir")
97-
rm -rf "$TUNED_USER_DIR/$profile_name"
98-
cp -rL "$profile_dir" "$TUNED_USER_DIR/$profile_name"
106+
rm -rf "${TUNED_PROFILES_DIR:?}/$profile_name"
107+
cp -rL "$profile_dir" "$TUNED_PROFILES_DIR/$profile_name"
108+
deployed_any=true
99109
echo "Deployed common profile: $profile_name"
100110
done
101111
else
@@ -108,14 +118,15 @@ deploy_os_profiles() {
108118
for profile_dir in "$PROFILES_DIR/os/$OS_ID/$VERSION"/*/; do
109119
[ -d "$profile_dir" ] || continue
110120
profile_name=$(basename "$profile_dir")
111-
rm -rf "$TUNED_USER_DIR/$profile_name"
112-
cp -rL "$profile_dir" "$TUNED_USER_DIR/$profile_name"
121+
rm -rf "${TUNED_PROFILES_DIR:?}/$profile_name"
122+
cp -rL "$profile_dir" "$TUNED_PROFILES_DIR/$profile_name"
123+
deployed_any=true
113124
echo "Deployed OS-specific profile: $profile_name"
114125
done
115126
fi
116127

117-
# Verify we have at least some profiles
118-
if [ ! -d "$TUNED_USER_DIR" ] || [ -z "$(ls -A "$TUNED_USER_DIR" 2>/dev/null)" ]; then
128+
# Verify this function actually deployed at least one OS profile
129+
if [ "$deployed_any" = false ]; then
119130
echo "ERROR: No OS profiles found in os/$OS_ID/$VERSION/ or os/common/"
120131
exit 1
121132
fi
@@ -125,11 +136,11 @@ deploy_os_profiles() {
125136
validate_profile() {
126137
local profile=$1
127138

128-
if [ ! -d "$TUNED_USER_DIR/$profile" ]; then
129-
echo "ERROR: Constructed profile '$profile' not found in $TUNED_USER_DIR"
139+
if [ ! -d "$TUNED_PROFILES_DIR/$profile" ]; then
140+
echo "ERROR: Constructed profile '$profile' not found in $TUNED_PROFILES_DIR"
130141
echo " intent=$INTENT, accelerator=$ACCELERATOR -> profile=$profile"
131142
echo "Available profiles:"
132-
ls -1 "$TUNED_USER_DIR" 2>/dev/null || echo " (none)"
143+
ls -1 "$TUNED_PROFILES_DIR" 2>/dev/null || echo " (none)"
133144
exit 1
134145
fi
135146

@@ -165,8 +176,8 @@ deploy_service_profile() {
165176
if [ -f "$service_specific_profile" ]; then
166177
echo "Found service-specific profile: $service_specific_profile"
167178
# Deploy the service-specific profile to /etc/tuned/
168-
mkdir -p "$TUNED_USER_DIR/$profile"
169-
cp "$service_specific_profile" "$TUNED_USER_DIR/$profile/tuned.conf"
179+
mkdir -p "$TUNED_PROFILES_DIR/$profile"
180+
cp "$service_specific_profile" "$TUNED_PROFILES_DIR/$profile/tuned.conf"
170181
echo "Deployed service-specific profile: $profile"
171182
# Use the service-specific profile in the include
172183
local profile_to_include="$profile"
@@ -176,8 +187,8 @@ deploy_service_profile() {
176187
fi
177188

178189
# Create service profile directory (final profile name = {service}-{accelerator}-{intent}); remove first so changed content is applied
179-
rm -rf "$TUNED_USER_DIR/$final_profile_name"
180-
mkdir -p "$TUNED_USER_DIR/$final_profile_name"
190+
rm -rf "${TUNED_PROFILES_DIR:?}/$final_profile_name"
191+
mkdir -p "$TUNED_PROFILES_DIR/$final_profile_name"
181192

182193
# Copy shared helper scripts from profiles/service/common/ into the final profile dir.
183194
# Each service's script.sh sources these helpers from its own profile dir ($SCRIPT_DIR).
@@ -187,8 +198,8 @@ deploy_service_profile() {
187198
[ -f "$helper" ] || continue
188199
local helper_name
189200
helper_name=$(basename "$helper")
190-
cp "$helper" "$TUNED_USER_DIR/$final_profile_name/$helper_name"
191-
chmod +x "$TUNED_USER_DIR/$final_profile_name/$helper_name"
201+
cp "$helper" "$TUNED_PROFILES_DIR/$final_profile_name/$helper_name"
202+
chmod +x "$TUNED_PROFILES_DIR/$final_profile_name/$helper_name"
192203
echo "Copied shared helper: $helper_name"
193204
done
194205
fi
@@ -197,7 +208,7 @@ deploy_service_profile() {
197208
local template="$service_dir/tuned.conf.template"
198209
if [ -f "$template" ]; then
199210
# Insert include= line after [main]
200-
sed "s/^\[main\]/[main]\ninclude=$profile_to_include/" "$template" | tee "$TUNED_USER_DIR/$final_profile_name/tuned.conf" > /dev/null
211+
sed "s/^\[main\]/[main]\ninclude=$profile_to_include/" "$template" | tee "$TUNED_PROFILES_DIR/$final_profile_name/tuned.conf" > /dev/null
201212
echo "Created service profile: $final_profile_name with include=$profile_to_include"
202213
else
203214
echo "ERROR: Service template not found: $template"
@@ -210,8 +221,8 @@ deploy_service_profile() {
210221
filename=$(basename "$file")
211222
[ "$filename" = "tuned.conf.template" ] && continue
212223
[[ "$filename" == *.conf ]] && continue # Skip .conf files (they're service-specific profiles)
213-
cp "$file" "$TUNED_USER_DIR/$final_profile_name/$filename"
214-
chmod +x "$TUNED_USER_DIR/$final_profile_name/$filename" 2>/dev/null || true
224+
cp "$file" "$TUNED_PROFILES_DIR/$final_profile_name/$filename"
225+
chmod +x "$TUNED_PROFILES_DIR/$final_profile_name/$filename" 2>/dev/null || true
215226
echo "Copied service file: $filename"
216227
done
217228
}
@@ -244,7 +255,7 @@ set_reapply_sysctl_off() {
244255
main() {
245256
# Read intent from configmap (defaults to performance)
246257
if [ -f "$INTENT_FILE" ]; then
247-
INTENT=$(cat "$INTENT_FILE" | xargs)
258+
INTENT=$(xargs < "$INTENT_FILE")
248259
fi
249260
if [ -z "${INTENT:-}" ]; then
250261
INTENT="performance"
@@ -256,12 +267,17 @@ main() {
256267
echo "ERROR: accelerator configmap not found at $ACCELERATOR_FILE"
257268
exit 1
258269
fi
259-
ACCELERATOR=$(cat "$ACCELERATOR_FILE" | xargs)
270+
ACCELERATOR=$(xargs < "$ACCELERATOR_FILE")
260271

261272
# Detect OS
262273
detect_os
263274

264-
# Deploy common base profiles to /usr/lib/tuned/
275+
# Resolve the single profiles directory for the installed tuned version
276+
# and ensure it exists before deploying anything into it.
277+
resolve_tuned_profiles_dir
278+
mkdir -p "${TUNED_PROFILES_DIR}"
279+
280+
# Deploy common base profiles
265281
deploy_common_profiles
266282

267283
# Deploy ALL OS-specific profiles to /etc/tuned/
@@ -287,7 +303,7 @@ main() {
287303

288304
# Check if service is specified (optional)
289305
if [ -f "$SERVICE_FILE" ]; then
290-
SERVICE=$(cat "$SERVICE_FILE" | xargs)
306+
SERVICE=$(xargs < "$SERVICE_FILE")
291307
fi
292308
if [ -n "${SERVICE:-}" ]; then
293309
if [ "$SERVICE" = "common" ]; then

0 commit comments

Comments
 (0)