|
| 1 | +# Tuned Package |
| 2 | + |
| 3 | +A Skyhook package for managing the `tuned` system tuning daemon on Linux systems. This package provides automated installation, configuration, and management of tuned profiles for system performance optimization. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +[Tuned](https://github.com/redhat-performance/tuned) is a daemon that uses udev to monitor connected devices and statically and dynamically tunes system settings according to a selected profile. This package automates the deployment and configuration of tuned across different Linux distributions. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Multi-distribution support**: Works on Ubuntu/Debian, CentOS/RHEL/Amazon Linux, and Fedora |
| 12 | +- **Custom profile management**: Deploy and apply custom tuned profiles via configmaps |
| 13 | +- **Idempotent operations**: Safe to run multiple times without side effects |
| 14 | +- **Comprehensive validation**: Built-in checks for installation and configuration status |
| 15 | +- **Service lifecycle management**: Handles installation, configuration, and uninstallation |
| 16 | +- **Handles Necessary Interrupts**: Handles reboots and service restarts around important workloads for specific tuning parameters that require it. |
| 17 | + |
| 18 | +## Package Structure |
| 19 | + |
| 20 | +``` |
| 21 | +tuned/ |
| 22 | +├── config.json # Skyhook package configuration |
| 23 | +├── README.md # This file |
| 24 | +├── Dockerfile # Container build file |
| 25 | +└── skyhook_dir/ |
| 26 | + ├── install_tuned.sh # Install tuned package and service |
| 27 | + ├── install_tuned_check.sh # Validate tuned installation |
| 28 | + ├── uninstall_tuned.sh # Remove tuned package and service |
| 29 | + ├── uninstall_tuned_check.sh # Validate tuned removal |
| 30 | + ├── apply_tuned_profile.sh # Apply tuned profiles from configmaps |
| 31 | + ├── apply_tuned_profile_check.sh # Validate profile configuration |
| 32 | + └── post_interrupt_tuned_check.sh # Validate post-interruption state |
| 33 | +``` |
| 34 | + |
| 35 | +## Supported Operating Systems |
| 36 | + |
| 37 | +- **Ubuntu/Debian**: Uses `apt` package manager |
| 38 | +- **CentOS/RHEL/Amazon Linux**: Uses `yum` package manager |
| 39 | +- **Fedora**: Uses `dnf` package manager |
| 40 | + |
| 41 | +## Package Modes |
| 42 | + |
| 43 | +### Installation Modes |
| 44 | + |
| 45 | +#### `apply` / `upgrade` |
| 46 | +- **Script**: `install_tuned.sh` |
| 47 | +- **Purpose**: Installs the tuned package and starts/enables the service |
| 48 | +- **Actions**: |
| 49 | + - Updates package repositories |
| 50 | + - Installs tuned package |
| 51 | + - Enables and starts tuned service |
| 52 | + - Displays service status |
| 53 | + |
| 54 | +#### `apply-check` / `upgrade-check` |
| 55 | +- **Script**: `install_tuned_check.sh` |
| 56 | +- **Purpose**: Validates successful tuned installation |
| 57 | +- **Checks**: |
| 58 | + - `tuned` command availability |
| 59 | + - `tuned-adm` command availability |
| 60 | + - Service is running (`systemctl is-active`) |
| 61 | + - Service is enabled for boot (`systemctl is-enabled`) |
| 62 | + |
| 63 | +### Configuration Mode |
| 64 | + |
| 65 | +#### `config` |
| 66 | +- **Script**: `apply_tuned_profile.sh` |
| 67 | +- **Purpose**: Deploys custom profiles and applies the specified tuned profile |
| 68 | +- **Process**: |
| 69 | + 1. Creates custom profile directories in `/etc/tuned/` |
| 70 | + 2. Copies configmap files as `tuned.conf` for each custom profile |
| 71 | + 3. Reads the target profile from `tuned_profile` configmap file |
| 72 | + 4. Applies the specified profile using `tuned-adm profile` |
| 73 | + |
| 74 | +#### `config-check` |
| 75 | +- **Script**: `apply_tuned_profile_check.sh` |
| 76 | +- **Purpose**: Validates profile configuration |
| 77 | +- **Checks**: |
| 78 | + - Tuned service is running |
| 79 | + - Configmaps directory exists |
| 80 | + - Custom profiles are properly deployed |
| 81 | + - Correct profile is active and verified |
| 82 | + - Profile verification via `tuned-adm verify` (behavior controlled by `INTERRUPT` variable) |
| 83 | + |
| 84 | +### Uninstallation Mode |
| 85 | + |
| 86 | +#### `uninstall` |
| 87 | +- **Script**: `uninstall_tuned.sh` |
| 88 | +- **Purpose**: Removes tuned package and disables service |
| 89 | +- **Actions**: |
| 90 | + - Disables and stops tuned service |
| 91 | + - Removes tuned package |
| 92 | + - Cleans up unused dependencies (apt only) |
| 93 | + |
| 94 | +#### `uninstall-check` |
| 95 | +- **Script**: `uninstall_tuned_check.sh` |
| 96 | +- **Purpose**: Validates successful tuned removal |
| 97 | +- **Checks**: |
| 98 | + - `tuned` command is not available |
| 99 | + - `tuned-adm` command is not available |
| 100 | + - Service is stopped |
| 101 | + - Service is disabled |
| 102 | + |
| 103 | +## Recovery Mode |
| 104 | + |
| 105 | +#### `post-interrupt-check` |
| 106 | +- **Script**: `post_interrupt_tuned_check.sh` |
| 107 | +- **Purpose**: Validates system state after interrupt (reboot/service restart) |
| 108 | +- **Checks**: Performs comprehensive validation of tuned state, including mandatory `tuned-adm verify` (always enforced regardless of `INTERRUPT` variable) |
| 109 | + |
| 110 | +## Configuration |
| 111 | + |
| 112 | +### Environment Variables |
| 113 | + |
| 114 | +#### INTERRUPT |
| 115 | + |
| 116 | +The `INTERRUPT` environment variable controls how the package handles `tuned-adm verify` failures during different validation phases: |
| 117 | + |
| 118 | +- **Purpose**: Determines whether to fail on `tuned-adm verify` errors in the config-check step |
| 119 | +- **Values**: |
| 120 | + - `true`: Allow config-check to pass even if `tuned-adm verify` fails (recommended for tunings requiring an interrupt) |
| 121 | + - `false` or unset: Fail config-check if `tuned-adm verify` fails (default behavior) |
| 122 | +- **When to use**: Set to `true` when applying tuning profiles that require an interrupt to take effect and verify correctly |
| 123 | +- **Behavior**: |
| 124 | + - **config-check step**: If `INTERRUPT=true`, verification failures are logged as warnings but don't cause the step to fail |
| 125 | + - **post-interrupt-check step**: Always fails on verification errors regardless of INTERRUPT setting (tunings should be verifiable after an interrupt) |
| 126 | + |
| 127 | +**Example configuration in SCR:** |
| 128 | +```yaml |
| 129 | +env: |
| 130 | + name: INTERRUPT |
| 131 | + value: true |
| 132 | +``` |
| 133 | +
|
| 134 | +### Configmaps |
| 135 | +
|
| 136 | +The package expects configmaps to be available in `${SKYHOOK_DIR}/configmaps/`: |
| 137 | + |
| 138 | +#### Required Configmaps |
| 139 | + |
| 140 | +- **`tuned_profile`**: Contains the name of the tuned profile to apply |
| 141 | + ``` |
| 142 | + # Example content |
| 143 | + balanced |
| 144 | + ``` |
| 145 | +
|
| 146 | +#### Optional Configmaps |
| 147 | +
|
| 148 | +- **Custom profile files**: Any other files in the configmaps directory will be treated as custom tuned profile configurations |
| 149 | + - File name becomes the profile name |
| 150 | + - File contents become the `tuned.conf` for that profile |
| 151 | + - Files are deployed to `/etc/tuned/<profile_name>/tuned.conf` |
| 152 | +
|
| 153 | +### Example Custom Profile |
| 154 | +
|
| 155 | +```ini |
| 156 | +# configmaps/my-custom-profile |
| 157 | +[main] |
| 158 | +summary=Custom performance profile for my application |
| 159 | +
|
| 160 | +[cpu] |
| 161 | +governor=performance |
| 162 | +energy_perf_bias=performance |
| 163 | +
|
| 164 | +[disk] |
| 165 | +readahead=4096 |
| 166 | +
|
| 167 | +[vm] |
| 168 | +transparent_hugepages=never |
| 169 | +``` |
| 170 | + |
| 171 | +## Usage Examples |
| 172 | + |
| 173 | +### Basic Installation |
| 174 | +Deploy the package with apply mode to install tuned with default settings. |
| 175 | + |
| 176 | +### Custom Profile Deployment |
| 177 | +1. Create configmap files with your custom tuned profiles |
| 178 | +2. Create a `tuned_profile` configmap specifying which profile to activate |
| 179 | +3. Deploy the package with config mode to apply the custom configuration |
| 180 | + |
| 181 | +### Available Tuned Profiles |
| 182 | + |
| 183 | +Common built-in profiles include: |
| 184 | +- `balanced` - Default balanced profile |
| 185 | +- `powersave` - Power saving profile |
| 186 | +- `throughput-performance` - Maximum throughput |
| 187 | +- `latency-performance` - Low latency optimization |
| 188 | +- `network-latency` - Network latency optimization |
| 189 | +- `network-throughput` - Network throughput optimization |
| 190 | + |
| 191 | +Use `tuned-adm list` to see all available profiles on your system or go to [tuned profiles](https://github.com/redhat-performance/tuned/tree/master/profiles) to see the profiles which are automatically installed with tuned. |
| 192 | + |
| 193 | +## Troubleshooting |
| 194 | + |
| 195 | +### Common Issues |
| 196 | + |
| 197 | +1. **Service fails to start** |
| 198 | + - Check system logs: `journalctl -u tuned` |
| 199 | + - Verify package installation: `rpm -q tuned` or `dpkg -l tuned` |
| 200 | + |
| 201 | +2. **Profile not found** |
| 202 | + - List available profiles: `tuned-adm list` |
| 203 | + - Check custom profile deployment in `/etc/tuned/` |
| 204 | + |
| 205 | +3. **Permission errors** |
| 206 | + - Ensure scripts run with appropriate privileges |
| 207 | + - Check `/etc/tuned/` directory permissions |
| 208 | + |
| 209 | +4. **Verification errors** |
| 210 | + - Check verification: `tuned-adm verify` |
| 211 | + - Verify correct active profile: `tuned-adm active` |
| 212 | + - Check verification logs in `/var/log/tuned/tuned.log` |
| 213 | + - For tunings requiring reboot: Set `INTERRUPT=true` to allow config-check to pass despite verification failures |
| 214 | + |
| 215 | +### Validation Commands |
| 216 | + |
| 217 | +```bash |
| 218 | +# Check tuned status |
| 219 | +systemctl status tuned |
| 220 | + |
| 221 | +# List available profiles |
| 222 | +tuned-adm list |
| 223 | + |
| 224 | +# Check active profile |
| 225 | +tuned-adm active |
| 226 | + |
| 227 | +# Verify profile recommendations |
| 228 | +tuned-adm recommend |
| 229 | + |
| 230 | +# Verify tuning has finished |
| 231 | +tuned-adm verify |
| 232 | +``` |
| 233 | + |
| 234 | +## Dependencies |
| 235 | + |
| 236 | +- **System Requirements**: Linux with systemd |
| 237 | +- **Package Managers**: apt, yum, or dnf |
| 238 | +- **Runtime Dependencies**: |
| 239 | + - `systemctl` (systemd) |
| 240 | + - `sudo` (for profile management) |
| 241 | + |
| 242 | +## Version |
| 243 | + |
| 244 | +- **Package Version**: 1.0.0 |
| 245 | +- **Schema Version**: v1 |
| 246 | + |
| 247 | +## Contributing |
| 248 | + |
| 249 | +When modifying this package: |
| 250 | + |
| 251 | +1. Ensure all scripts maintain idempotency |
| 252 | +2. Add appropriate error handling and validation |
| 253 | +3. Update both action and check scripts for new functionality |
| 254 | +4. Test across all supported distributions |
| 255 | +5. Update this README with any new features or requirements |
0 commit comments