From 101c27de519d559d6f664b0aff02e978b5ae9256 Mon Sep 17 00:00:00 2001 From: Catalina <307525548+Catalina-df@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:13:04 +0800 Subject: [PATCH 1/3] chore: prepare onboarding, release notes, and OSS reviews --- .coderabbit.yaml | 7 + .github/workflows/docker-publish.yml | 10 +- CHANGELOG.md | 33 ++++ CONTRIBUTING.md | 57 ++++++ README.md | 127 +++++++++----- README.zh-TW.md | 127 +++++++++----- USAGE_GUIDE.md | 249 +++++++++------------------ docs/RELEASING.md | 74 ++++++++ docs/TEMPERATURE_SOURCES.md | 6 +- docs/TROUBLESHOOTING.md | 222 +++++------------------- 10 files changed, 483 insertions(+), 429 deletions(-) create mode 100644 .coderabbit.yaml create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 docs/RELEASING.md diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..9fb9074 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +language: en-US +reviews: + auto_review: + enabled: true + auto_incremental_review: true + drafts: false diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 17fa5f1..94ae435 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,7 +12,6 @@ on: permissions: contents: read - packages: write jobs: test: @@ -32,7 +31,9 @@ jobs: docker: runs-on: ubuntu-latest needs: test - if: github.event_name == 'push' + permissions: + contents: read + packages: write steps: - name: Check out repository uses: actions/checkout@v4 @@ -41,6 +42,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry + if: github.event_name == 'push' uses: docker/login-action@v3 with: registry: ghcr.io @@ -64,10 +66,10 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=sha,prefix=sha- - - name: Build and push Docker image + - name: Build image (publish only on pushes to master or release tags) uses: docker/build-push-action@v6 with: context: . - push: true + push: ${{ github.event_name == 'push' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..578ba02 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +## Unreleased — proposed v3.0.0 + +This is a release proposal, not a published version. The previous published release is [v2.0.1](https://github.com/DF-wu/iDRACFanSpeedControl/releases/tag/v2.0.1), dated 2024-10-23. Review the [complete changes since v2.0.1](https://github.com/DF-wu/iDRACFanSpeedControl/compare/v2.0.1...master) and [publication checklist](docs/RELEASING.md). + +### Release notes + +- Reworked Bash controller with validated configuration, manual/once/continuous modes, explicit Dell automatic restoration, all-source fail-safe, and persistent cycle logs/healthchecks ([#1](https://github.com/DF-wu/iDRACFanSpeedControl/pull/1), [#2](https://github.com/DF-wu/iDRACFanSpeedControl/pull/2)). +- Pure Bash setup TUI, redacted configuration display, and diagnostics that read configured dependencies without changing fans ([#3](https://github.com/DF-wu/iDRACFanSpeedControl/pull/3)). +- Unified temperature source interface: ESXi NVMe, iDRAC sensors, local Linux SMART disks, and local/remote NVIDIA GPUs. Highest valid adjusted reading drives the curve; partial source/target failures retain other usable readings ([#4](https://github.com/DF-wu/iDRACFanSpeedControl/pull/4)). +- Reject implausible raw readings outside −20…150°C before applying offsets, avoiding packed SMART values being interpreted as temperatures ([#5](https://github.com/DF-wu/iDRACFanSpeedControl/pull/5)). +- Linear fan-speed interpolation enabled by default, including old configurations that omit the switch; ceiling rounding between four anchors, with stepwise/downshift hysteresis available by setting `FAN_SPEED_INTERPOLATION=false` ([#6](https://github.com/DF-wu/iDRACFanSpeedControl/pull/6)). +- Docker deployment with host networking, persistent logs, read-only SSH secrets, optional disk mappings/GPU access, and GHCR publication. Pull requests now validate the image build without publishing it. +- Updated English onboarding, operations, troubleshooting and release instructions, synchronized Traditional Chinese README, and minimal CodeRabbit GitHub App review configuration with owner activation instructions. + +### Migration and compatibility + +A major version is proposed because cumulative changes since v2.0.1 alter deployment, configuration validation, defaults, and fan-curve behavior. This is not a claim that v3.0.0 has been hardware-certified. + +1. Stop the old controller and restore Dell automatic control before migration. Keep the known-good image, code, and protected configuration for rollback. +2. Merge the current `.env.example` into your configuration instead of blindly reusing a 2024 `.env`. Replace placeholders; explicitly select sources and verify required SSH keys/devices/GPU access. +3. Current default thresholds are **65/70/75/80°C**; duties are **30/30/40/50/60%**, with **70% fail-safe**. At the v2.0.1 tag, thresholds were 45/55/65/70°C and low/medium/high/critical duties were 20/30/40/60%. Review every threshold/duty against your hardware. +4. Interpolation is now default and ignores hysteresis. Explicitly set `FAN_SPEED_INTERPOLATION=false` to retain the stepwise decision model, then verify your configured anchors; this does not restore older default values automatically. +5. Runtime mode still defaults to `manual`; the current template selects `auto`. Keep the restartable Compose service on `auto`; run manual/once as one-off commands and explicitly restore afterward. +6. Bare scripts do not read `.env`; Compose does. Logs persist at `./logs/fan_control.log`, SSH secrets mount at `/run/secrets`, and every local disk needs its own device mapping. A local Docker build requires selecting that image in Compose. +7. Validate, diagnose, supervise manual/restore checks, then start unattended operation. See [upgrade and rollback](USAGE_GUIDE.md#upgrade-and-rollback). + +Only one Dell PowerEdge R730xd with iDRAC 8 has historical hardware testing. No firmware version range, other server model, new hardware test, or production deployment is certified by this release preparation. Exit restoration remains best-effort; explicit stop and restore plus verification in iDRAC are required. A fresh fail-safe log can be healthy even when every temperature source has failed. + +## v2.0.1 — 2024-10-23 + +Published as “v2.0.1 hotfix”. Use the actual Git tag `v2.0.1` as the migration baseline. See the [original release](https://github.com/DF-wu/iDRACFanSpeedControl/releases/tag/v2.0.1) for its historical notes. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5e356cf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,57 @@ +# Contributing + +Keep changes focused and describe actual behavior. Do not test against iDRAC, SSH targets, GPUs, or disks without the hardware owner's explicit authorization. The repository tests use mocks; do not describe those as hardware verification. + +## Local checks + +With Bash 4+, GNU coreutils, awk, and Make: + +```bash +make test +make validate-example +git diff --check +``` + +With Docker/Compose, in a disposable checkout using only the example configuration: + +```bash +cp .env.example .env +chmod 600 .env +docker compose config --quiet +make docker-build +``` + +The example contains intentionally invalid live-target placeholders. Do not start the Compose service with it. `make validate-example` uses an offline iDRAC-only dry run and does not load `.env`. The Dockerfile build runs shell syntax/help checks without hardware access. `make validate` validates a real root `.env` inside the selected image; it does not send fan commands. Do not print expanded Compose configuration containing actual secrets into CI logs. + +CI runs the mocked tests, validates Compose, and builds the image for PRs into `master`; PRs do not log in to GHCR or publish. Only pushes to `master` or `v*` tags publish images. Release preparation is in [docs/RELEASING.md](docs/RELEASING.md). + +## Documentation and localization contract + +`README.md` is the English reference and `README.zh-TW.md` is its Traditional Chinese localization. Update both in the same PR whenever commands, defaults, warnings, deployment instructions, or supported behavior change. Preserve the language-switch links and equivalent technical content; translate prose while retaining exact command/variable names. New engineering docs, commits, PR descriptions, and review discussions use English. Operations and troubleshooting guides are maintained in English and linked from both READMEs. + +Verify relative Markdown links and anchors, shell examples, source/default tables against `src/FanControlWithEsxiSmart.sh`, TUI choices against `src/fan-control-tui.sh`, and deployment instructions against Compose/Dockerfile. Keep `.env`, keys, logs, and incident files out of Git. + +## CodeRabbit OSS reviews + +This repository prepares review settings for the **CodeRabbit GitHub App** in [`.coderabbit.yaml`](.coderabbit.yaml); installation and operation must be verified separately. The configuration requests English automatic reviews and incremental review on pushes, skips draft PRs, and uses the default target branch (`master`). No token-based review Action or API secret is required. + +### Owner enablement + +1. Open the [CodeRabbit App installation page](https://github.com/apps/coderabbitai/installations/new), sign in as an owner/admin, and select **DF-wu**. +2. Choose **Only select repositories** and add **iDRACFanSpeedControl**. If CodeRabbit is already installed with selected access, configure that installation and add only this repository, preserving any existing authorized selection. Do not expand access to all repositories. Review the App permissions and finish installation/authorization. +3. Sign in to [CodeRabbit](https://app.coderabbit.ai/) with GitHub, select the DF-wu account, and enable review access for this repository if its repository toggle is off. Keep automatic reviews enabled. Use OSS access; do not add billing, purchase seats, enable usage-based billing, or activate paid products for this setup. +4. Open or mark a PR into `master` ready for review and look for an actual CodeRabbit status/comment/review. Configuration alone does not prove operation. Record the PR head SHA and the review evidence. + +[Official pricing](https://docs.coderabbit.ai/management/plans) states that OSS projects receive review features without a paid subscription or credit card. Public repositories below 10 stars currently require a manual trigger; this repository had 10 stars when checked on 2026-11-11. Eligibility and rate limits are service policy, so recheck before claiming ongoing automatic coverage. The general Free plan and an expiring trial are not evidence of permanent OSS review access. + +### First PR, drafts, and troubleshooting + +The [official YAML guide](https://docs.coderabbit.ai/getting-started/yaml-configuration) says the configuration on the feature branch is used for that PR. The first PR adding `.coderabbit.yaml` can therefore be reviewed before merge, once App access is enabled. With `drafts: false`, keep work in draft until ready, then mark it ready to exercise automatic review. Installation after PR creation may need a one-time manual bootstrap: + +```text +@coderabbitai full review +``` + +For later updates, `@coderabbitai review` requests an incremental review. These commands are an explicit bootstrap/retry, not proof that automatic triggering works. For missing reviews, check App repository selection, the CodeRabbit repository toggle, ready/draft status, target branch, OSS eligibility/rate limits, and the bot's skip reason. `@coderabbitai configuration` shows the resolved settings. The service can pause incremental reviews after its default reviewed-commit limit; use its resume/review controls as needed. + +Validate `.coderabbit.yaml` against the [current official schema](https://coderabbit.ai/integrations/schema.v2.json), using the [YAML validator](https://docs.coderabbit.ai/configuration/yaml-validator) or a local JSON Schema validator. See [automatic review controls](https://docs.coderabbit.ai/configuration/auto-review) for branch/draft behavior. Do not make CodeRabbit a required merge check until actual repository evidence confirms it is running reliably. diff --git a/README.md b/README.md index b961f3b..e7c320c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A fan controller for Dell PowerEdge servers. It sets the fan duty cycle through iDRAC IPMI OEM raw commands, then calculates fan speed from a configurable curve using pluggable temperature sources: ESXi NVMe SMART, iDRAC sensors, local Linux disks, and local or remote NVIDIA GPUs. > [!CAUTION] -> This project has been tested on only my Dell PowerEdge R730xd with iDRAC 8. Other server models and iDRAC firmware versions are untested and must not be assumed compatible. This program temporarily overrides Dell's automatic fan control; use it at your own risk. During initial setup, keep the iDRAC Web UI or a physical console available. Verify `manual`, `restore`, and `diagnose` on your own hardware before running `auto` for an extended period. If the server overheats, readings become unreliable, or behavior is abnormal, run `restore` immediately and stop the container. +> This project has been tested on only my Dell PowerEdge R730xd with iDRAC 8. Other server models and iDRAC firmware versions are untested and must not be assumed compatible. This program temporarily overrides Dell's automatic fan control; use it at your own risk. During initial setup, keep the iDRAC Web UI or a physical console available. Verify `manual`, `restore`, and `diagnose` on your own hardware before running `auto` for an extended period. If the server overheats, readings become unreliable, or behavior is abnormal, stop the controller and explicitly run `restore`; confirm recovery in iDRAC. See the [recovery procedure](USAGE_GUIDE.md#stop-and-restore-dell-automatic-control). ## How it works @@ -26,12 +26,29 @@ flowchart LR CTRL --> LOG[logs/fan_control.log\nhealthcheck] ``` -The controller sends fan commands only to iDRAC; all temperature sources are read-only. Every provider implements the same `validate`, `collect`, and `adjust` interface. When multiple sources are enabled, the controller uses the highest valid adjusted temperature. GPU and disk offsets let unlike sensors share one fan curve without source-specific decision code. +The controller sends fan commands only to iDRAC; all temperature sources are read-only. Every provider implements the same `validate`, `collect`, and `adjust` interface. When multiple sources are enabled, the controller uses the highest valid adjusted temperature. Raw readings outside −20…150°C are rejected before offsets. Failed sources/targets are logged; remaining valid readings still drive control, so a partial failure can remove the hottest component from the decision. GPU and disk offsets let unlike sensors share one fan curve without source-specific decision code. ![iDRAC IPMI over LAN settings](images/image.png) *Figure 1: Enabling IPMI over LAN in the iDRAC Web UI. The exact option name may vary by iDRAC firmware version.* +## Prerequisites and compatibility + +- A Linux Docker host with Git, Bash 4+, Make, Docker Engine, and Docker Compose with `env_file` support. GPU deployments additionally need Compose support for `gpus: all`, the NVIDIA driver, and NVIDIA Container Toolkit. +- Access to the iDRAC management network, IPMI over LAN enabled, and an account permitted to use the OEM fan commands. Keep an iDRAC Web UI session or physical console available. +- Historical hardware testing covers **one PowerEdge R730xd with iDRAC 8**. There is no verified firmware compatibility matrix; R730, other generations, and other firmware revisions require their own checks. Successful IPMI login does not prove fan-command support. No new hardware verification is claimed by this documentation update. +- Optional sources need ESXi SSH with readable NVMe SMART data, mapped local Linux disks, local NVIDIA GPUs, or SSH access to remote NVIDIA hosts. Start with `idrac` only, then add sources individually. An inlet sensor alone may not reflect hot disks or GPUs; choose sensors and a conservative curve for your hardware. + +Check the host tools before proceeding: + +```bash +git --version +bash --version +make --version +docker version +docker compose version +``` + ## Quick start: safe first-time setup with the TUI Run the setup on the Docker host. The TUI requires no `dialog`, Python, or other additional packages. It is written in pure Bash, preserves comments from `.env.example`, updates files atomically, and sets file permissions to `600`. @@ -45,36 +62,42 @@ make tui The main menu looks like this. Each submenu writes changes back to `.env`, and the file location is shown again when you exit. ```text -╭────────────────────────────────────────────────────────────╮ -│ iDRAC Fan Control · Setup TUI │ -╰────────────────────────────────────────────────────────────╯ - - 1) Quick setup wizard 6) Safety, timing, and logging - 2) iDRAC / IPMI settings 7) Review redacted configuration - 3) Temperature source 8) Safety, timing, and logging - 4) ESXi NVMe source 9) Review redacted configuration - 5) Local Linux disks 10) Validate configuration - 6) Remote NVIDIA GPUs 11) Run read-only diagnostics - 7) Fan curve 0) Save and exit + 1) Quick setup wizard + 2) iDRAC / IPMI settings + 3) Temperature source preset + 4) ESXi NVMe source settings + 5) Local Linux disk settings + 6) Remote NVIDIA GPU settings + 7) Fan curve + 8) Safety, timing, and logging + 9) Review redacted configuration + 10) Validate configuration + 11) Run read-only diagnostics + 0) Save and exit ``` -For your first setup, select `iDRAC sensors only` and leave external sources disabled. After completing the TUI, run: +For your first setup, select `iDRAC sensors only` and leave external sources disabled. Set `OPERATION_MODE=auto`, keep `RESTORE_AUTO_ON_EXIT=true`, replace all selected-source placeholders, and review the curve before starting. The TUI saves configuration; it does not start the service. After completing the TUI, run: ```bash +mkdir -p logs secrets +docker compose pull make validate -docker compose run --rm idrac-fan-control diagnose -docker compose up -d -docker logs -f idrac-fan-control +docker compose run --rm --no-deps idrac-fan-control config +docker compose run --rm --no-deps idrac-fan-control diagnose ``` -`diagnose` is read-only and never sends fan raw commands. It checks iDRAC, every temperature source, the writable log path, and previews the fan level that would be selected. If you do not need a source, remove it from the TUI source preset instead of ignoring its errors. +`diagnose` never sends fan raw commands. It reads hardware and remote hosts and creates/touches the local log path. It checks iDRAC, every temperature source, the writable log path, and previews the fan level that would be selected. If you do not need a source, remove it from the TUI source preset instead of ignoring its errors. -To edit a different configuration file: +Before starting unattended control, complete the supervised [manual and restore checks](#safe-startup-sequence). Only then start the service: ```bash -src/fan-control-tui.sh --config /path/to/staging.env +docker compose up -d +docker compose ps +docker logs -f idrac-fan-control ``` +Use the repository-root `.env` for Compose. The TUI's `--config /path/to/staging.env` option edits an alternate file, but Compose still requires the repository `.env`; copy the reviewed configuration there before deployment. Do not use alternate-file diagnostics as proof of the deployed configuration. + ### Create `.env` manually ```bash @@ -121,14 +144,16 @@ docker compose run --rm idrac-fan-control manual 35 docker compose run --rm idrac-fan-control restore ``` -The local script accepts the same commands: +`manual` and `once` leave their selected duty active after exiting; run `restore` explicitly. `RESTORE_AUTO_ON_EXIT` applies only to continuous `auto`. Stop any active controller before one-off fan commands so the next cycle cannot overwrite them. The Compose service uses `restart: unless-stopped`; keep its `.env` mode at `auto`, and invoke `manual`/`once` only as one-off `docker compose run --rm --no-deps` commands. + +The local script accepts the same commands but **does not load `.env`**. It reads exported environment variables; prefer Compose for the configured deployment. A safe offline local check is: ```bash -src/FanControlWithEsxiSmart.sh diagnose -src/FanControlWithEsxiSmart.sh config +make validate-example +src/FanControlWithEsxiSmart.sh help ``` -Local execution requires `bash`, `coreutils`, `ipmitool`, and `timeout`. Linux disk mode also requires `smartctl` and `jq`; SSH password authentication requires `sshpass`. The Docker image includes these dependencies. +Local execution requires Bash 4+, GNU coreutils (`timeout`, `stat`), awk, and `ipmitool`. Linux disk mode also requires `smartctl` and `jq`; SSH sources require OpenSSH, and password authentication requires `sshpass`. Local GPU mode requires `nvidia-smi`. The Docker image includes the CLI dependencies other than the host NVIDIA driver/toolkit. ## Safe startup sequence @@ -143,7 +168,7 @@ sequenceDiagram C->>D: mc info / SDR (read-only) D-->>C: Connection and temperatures C-->>U: Source checks + decision preview - U->>C: manual 30 + U->>C: manual 70 (supervised example) C->>D: Set fan duty (controlled test) U->>C: restore C->>D: Dell automatic fan control @@ -154,10 +179,21 @@ Before unattended operation, confirm each item: 1. IPMI over LAN is enabled in the iDRAC Web UI and the management network is reachable. 2. The iDRAC account has the required permissions and its password is not a placeholder. -3. `manual 30` sets a low speed, `manual 70` sets a conservative speed, and `restore` returns control to Dell automatic mode. +3. With the controller stopped, test a conservative duty (for example `manual 70`) while watching temperatures and fans in iDRAC, then run `restore` and verify Dell automatic control. Adjust the duty only within a supervised maintenance window; no percentage is universally safe. 4. Every enabled source reports `[PASS]` in `diagnose`; disable sources you do not use. 5. Start with a conservative `FAILSAFE_FAN_SPEED` and `RESTORE_AUTO_ON_EXIT=true`. +Example supervised checks (these **change hardware**; run only on your own compatible server): + +```bash +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control manual 70 +docker compose run --rm --no-deps idrac-fan-control status +docker compose run --rm --no-deps idrac-fan-control restore +``` + +`auto` is this project's software loop; it repeatedly takes manual control of iDRAC. `restore` returns control to Dell's firmware algorithm. Exit restoration is best-effort: foreground queries/sleep can delay signal handling, Docker can force-kill the process, and a host/network failure can prevent IPMI restoration. Always use the explicit [stop and restore procedure](USAGE_GUIDE.md#stop-and-restore-dell-automatic-control). + ## Temperature sources and control decisions `TEMPERATURE_SOURCES` is a comma-separated list containing `esxi`, `idrac`, `gpu`, `linux_disk`, and/or `remote_gpu`. Sources can be combined, and the controller retains each source label for logging and diagnostics. See [Temperature source interface](docs/TEMPERATURE_SOURCES.md) for the extension contract and deployment examples. @@ -218,11 +254,11 @@ Each source owns its adjustment: local and remote GPUs subtract their configured | `IDRAC_PASSWORD` | Empty | Passed to `ipmitool -E` through the `IPMI_PASSWORD` environment variable; never appears in argv | | `IPMI_INTERFACE` | `lanplus` | Usually left unchanged | | `IPMI_TIMEOUT` / `IPMI_RETRIES` | `5` / `2` | Per-command timeout and retry count | -| `OPERATION_MODE` | `manual` | `auto`, `once`, or `manual` | -| `DRY_RUN` | `false` | Only for testing command construction; does not produce real readings | +| `OPERATION_MODE` | `manual` (template: `auto`) | Command used when no CLI command is supplied | +| `DRY_RUN` | `false` | Suppresses IPMI calls only; SSH, GPU, and disk collectors can still run. Not an offline sandbox | | `COMMAND_TIMEOUT` | `20` | Maximum duration in seconds for SSH, IPMI, and GPU commands | | `CHECK_INTERVAL` | `60` | Seconds between cycles in auto mode | -| `RESTORE_AUTO_ON_EXIT` | `true` | Restores automatic control when auto mode receives SIGTERM or exits | +| `RESTORE_AUTO_ON_EXIT` | `true` | Best-effort restore on continuous `auto` exit; not a guarantee after SIGKILL, power loss, or network failure | ### Temperature sources @@ -258,14 +294,14 @@ Each source owns its adjustment: local and remote GPUs subtract their configured | `HYSTERESIS` | `2` | Stepwise mode only: degrees below the previous threshold required before lowering fan speed | | `FAILSAFE_ON_ERROR` | `true` | Uses a conservative speed when all sources fail | | `FAILSAFE_FAN_SPEED` | `70` | Must be greater than or equal to the critical speed | -| `MANUAL_FAN_SPEED` | `35` | Used by `manual` when no argument is provided | +| `MANUAL_FAN_SPEED` | Empty (template: `35`) | Used without a speed argument; otherwise prompts on a terminal or fails on noninteractive stdin | | `LOG_DIR` / `LOG_FILE` | `/var/log/fan-control` / `fan_control.log` | Persistent state log | | `LOG_LEVEL` | `INFO` | `DEBUG` adds command and source details but never logs passwords | | `HEALTHCHECK_MAX_AGE` | `0` | `0` means `CHECK_INTERVAL*3 + COMMAND_TIMEOUT` | ## Docker deployment, Linux disks, and GPUs -The Compose configuration uses the GHCR image, host networking, and a `./logs` volume by default: +The Compose configuration uses `ghcr.io/df-wu/idrac-fan-control:latest`, Linux host networking, and a `./logs` volume by default. `latest` tracks default-branch builds and is not a stable release pin. Record a known-good digest before upgrading; see [upgrade and rollback](USAGE_GUIDE.md#upgrade-and-rollback). ```bash docker compose pull @@ -274,7 +310,7 @@ docker compose ps docker inspect --format '{{.State.Health.Status}}' idrac-fan-control ``` -The `healthcheck` verifies more than environment configuration. In `OPERATION_MODE=auto`, it also confirms that `fan_control.log` has been updated within `HEALTHCHECK_MAX_AGE`. If every data source fails while `FAILSAFE_ON_ERROR=false`, the control cycle does not write a success record and the container becomes unhealthy. This is an intentional safety signal. +The `healthcheck` verifies more than environment configuration. In `OPERATION_MODE=auto`, it also confirms that `fan_control.log` has been updated within `HEALTHCHECK_MAX_AGE`. If every data source fails while `FAILSAFE_ON_ERROR=false`, the control cycle does not write a success record and the container becomes unhealthy. This is an intentional safety signal. Fail-safe records also keep the log fresh: `healthy` does not mean every sensor works or the hardware is cool. Docker does not restart a container just because it is unhealthy. Check logs and iDRAC independently. GPU mode requires the NVIDIA Container Toolkit. Uncomment `gpus: all` in `docker-compose.yml`, then configure: @@ -296,6 +332,8 @@ If GPU support is unnecessary, build locally without CUDA to reduce the image si docker build --build-arg BASE_IMAGE=ubuntu:24.04 -t idrac-fan-control:local . ``` +Then change the Compose service's `image:` to `idrac-fan-control:local` before running `make validate` and `diagnose`. `make docker-build` also creates only a local image; it does not change what Compose deploys. For default CUDA builds the image targets Linux/amd64; other architectures are not verified. + Linux disk mode needs a device mapping for every entry in `LINUX_DISK_DEVICES`. For example: ```yaml @@ -312,7 +350,7 @@ For a TrueNAS CD6 plus NVIDIA GPUs in other VMs, use `TEMPERATURE_SOURCES=linux_ Example normal log entry: ```text -2026-07-18 03:12:10 [INFO] Control temp 68C -> low (30%). Sources: idrac:Inlet Temp=68C +2026-11-11 03:12:10 [INFO] Control temp 68C -> low (36%). Sources: idrac:Inlet Temp=68C ``` For additional context, temporarily set: @@ -334,8 +372,9 @@ docker compose run --rm idrac-fan-control diagnose Shortest recovery path for common problems: ```bash -# Restore Dell automatic control first whenever risk is uncertain -docker compose run --rm idrac-fan-control restore +# Stop the loop before the final restore so it cannot overwrite Dell mode +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control restore # Inspect the effective configuration and dependency state docker compose run --rm idrac-fan-control config @@ -364,7 +403,7 @@ Copy the complete identifier into `DRIVE_DEVICE`; do not shorten it. If the SMAR ## Testing and quality gates ```bash -make test # bash -n + 52 core assertions + 14 TUI assertions +make test # Bash syntax checks and mocked controller/TUI suites make validate # Check the current .env with Docker dependencies; does not change fans make validate-example # DRY_RUN smoke test that does not require .env make docker-build @@ -372,6 +411,12 @@ make docker-build Tests cover the source interface, Linux SMART collection, multi-host remote GPUs, source offsets, SDR parsing, interpolation anchors/rounding/bounds, legacy hysteresis, control-cycle state and fail-safe recovery, configuration validation, credential redaction, health freshness, diagnostics, and safe TUI configuration round-trips. Real hardware, SSH targets, disks, iDRAC, and GPUs must still be verified with `diagnose` on your management network. +## Releases and contributing + +The latest published GitHub release is `v2.0.1` (2024-10-23); current `master` has substantial later changes. **`v3.0.0` is proposed, not published.** Read [CHANGELOG.md](CHANGELOG.md) for migration changes and [docs/RELEASING.md](docs/RELEASING.md) for the maintainer publication checklist. In particular, interpolation is now enabled when old configurations omit `FAN_SPEED_INTERPOLATION`; set it to `false` to retain stepwise control. + +See [CONTRIBUTING.md](CONTRIBUTING.md) for local checks, the README localization contract, and free OSS CodeRabbit GitHub App enablement. Adding `.coderabbit.yaml` alone does not install or activate the App. + ## Project structure ```text @@ -385,12 +430,16 @@ Tests cover the source interface, Linux SMART collection, multi-host remote GPUs │ └── tui.test.sh # .env parser/writer tests ├── docs/ │ ├── TEMPERATURE_SOURCES.md # Source interface and deployment examples -│ └── TROUBLESHOOTING.md # Symptom-based troubleshooting guide +│ ├── TROUBLESHOOTING.md # Symptom-based troubleshooting guide +│ └── RELEASING.md # Proposed release and publication checklist ├── images/image.png # iDRAC IPMI settings screenshot ├── .env.example # Fully commented configuration template ├── docker-compose.yml ├── Dockerfile ├── Makefile +├── CHANGELOG.md # Unreleased changes and migration notes +├── CONTRIBUTING.md # Checks, localization, and CodeRabbit +├── .coderabbit.yaml # GitHub App review configuration ├── README.md # English documentation ├── README.zh-TW.md # Traditional Chinese documentation └── USAGE_GUIDE.md @@ -398,10 +447,10 @@ Tests cover the source interface, Linux SMART collection, multi-host remote GPUs ## Compatibility and limitations -The project primarily targets Dell PowerEdge R730/R730xd-class systems with iDRAC 8 OEM fan raw commands. Other generations may be compatible, but identical behavior must not be assumed. Complete `manual`, `restore`, and `diagnose` checks before unattended operation. Sensor names, disk permissions, SSH access, and driver behavior vary by environment, so rely on diagnostic output from your own deployment. +Only a PowerEdge R730xd with iDRAC 8 has historical test evidence. No firmware version range or other model is certified compatible. Complete `manual`, `restore`, and `diagnose` checks before unattended operation. Sensor names, disk permissions, SSH access, and driver behavior vary by environment, so rely on diagnostic output from your own deployment. ## License MIT. See [LICENSE](LICENSE). -Documentation last reviewed: August 15, 2026. +Documentation last reviewed: November 11, 2026. diff --git a/README.zh-TW.md b/README.zh-TW.md index f57d2af..aa39e9a 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -9,7 +9,7 @@ 這是一個給 Dell PowerEdge 使用的風扇控制器。它透過 iDRAC 的 IPMI OEM raw command 設定 fan duty cycle,再以可插拔溫度來源決定風扇曲線:ESXi NVMe SMART、iDRAC sensor、本機 Linux 磁碟,以及本機或遠端 NVIDIA GPU。 > [!CAUTION] -> 本專案只在我自己的 Dell PowerEdge R730xd(iDRAC 8)上實機測試過;其他伺服器型號與 iDRAC 韌體版本均未驗證,不應假設相容。這個程式會暫時覆寫 Dell 原廠風扇控制,使用風險由使用者自行承擔。第一次設定請保留 iDRAC Web UI 或實體主控台,務必先在自己的硬體上用 `manual`、`restore`、`diagnose` 驗證,再讓 `auto` 長時間執行。任何過熱、讀值不可信或行為異常時,立即執行 `restore` 並停止容器。 +> 本專案只在我自己的 Dell PowerEdge R730xd(iDRAC 8)上實機測試過;其他伺服器型號與 iDRAC 韌體版本均未驗證,不應假設相容。這個程式會暫時覆寫 Dell 原廠風扇控制,使用風險由使用者自行承擔。第一次設定請保留 iDRAC Web UI 或實體主控台,務必先在自己的硬體上用 `manual`、`restore`、`diagnose` 驗證,再讓 `auto` 長時間執行。任何過熱、讀值不可信或行為異常時,先停止控制器,再明確執行 `restore`,並在 iDRAC 確認復原。請見[停止與還原程序](USAGE_GUIDE.md#stop-and-restore-dell-automatic-control)。 ## 先看懂它如何工作 @@ -26,12 +26,29 @@ flowchart LR CTRL --> LOG[logs/fan_control.log\nhealthcheck] ``` -控制器只會對 iDRAC 發送風扇命令;溫度來源全部是讀取。每個 provider 都實作同一組 `validate`、`collect`、`adjust` 介面。多來源時採用最高的有效 adjusted temperature;GPU 與磁碟可各自套用 offset,不需在決策流程加入來源特例。 +控制器只會對 iDRAC 發送風扇命令;溫度來源全部是讀取。每個 provider 都實作同一組 `validate`、`collect`、`adjust` 介面。多來源時採用最高的有效 adjusted temperature。原始溫度超出 −20…150°C 會在套用 offset 前被排除;部分來源或目標失敗時會記錄警告,其餘有效讀值仍會控制風扇,因此最熱的元件可能不再參與決策。GPU 與磁碟可各自套用 offset,不需在決策流程加入來源特例。 ![iDRAC IPMI over LAN 設定畫面](images/image.png) *圖 1:在 iDRAC Web UI 開啟 IPMI over LAN;實際選項名稱會依 iDRAC 韌體版本略有不同。* +## 前置條件與相容性 + +- Linux Docker 主機,具備 Git、Bash 4+、Make、Docker Engine 與支援 `env_file` 的 Docker Compose。GPU 部署另需支援 `gpus: all` 的 Compose、NVIDIA driver 與 NVIDIA Container Toolkit。 +- 可連線至 iDRAC 管理網路、已啟用 IPMI over LAN,且帳號有權執行 OEM 風扇命令。請保留 iDRAC Web UI 工作階段或實體主控台。 +- 歷史實機測試僅涵蓋**一台 PowerEdge R730xd(iDRAC 8)**,沒有已驗證的韌體相容範圍;R730、其他世代與韌體版本都須自行驗證。IPMI 能登入不代表支援風扇命令。本次文件更新沒有新增實機驗證。 +- 選用來源另需 ESXi SSH 與可讀取的 NVMe SMART、本機 Linux 磁碟映射、本機 NVIDIA GPU,或遠端 NVIDIA 主機的 SSH 權限。先只選 `idrac`,再逐一加入其他來源。僅看進氣溫度未必能反映磁碟與 GPU 熱點,請依硬體挑選感測器與保守曲線。 + +先確認主機工具: + +```bash +git --version +bash --version +make --version +docker version +docker compose version +``` + ## 快速開始:用 TUI 完成安全的第一次設定 建議在 Docker 主機上操作。TUI 不需要 `dialog`、Python 或其他額外套件;它使用純 Bash,會保留 `.env.example` 的註解、以原子方式更新檔案,並將檔案權限設為 `600`。 @@ -45,36 +62,42 @@ make tui 主畫面如下(每次進入子頁都會寫回 `.env`,離開時會再次顯示檔案位置): ```text -╭────────────────────────────────────────────────────────────╮ -│ iDRAC Fan Control · Setup TUI │ -╰────────────────────────────────────────────────────────────╯ - - 1) Quick setup wizard 6) Safety, timing, and logging - 2) iDRAC / IPMI settings 7) Review redacted configuration - 3) Temperature source 8) Safety, timing, and logging - 4) ESXi NVMe source 9) Review redacted configuration - 5) Local Linux disks 10) Validate configuration - 6) Remote NVIDIA GPUs 11) Run read-only diagnostics - 7) Fan curve 0) Save and exit + 1) Quick setup wizard + 2) iDRAC / IPMI settings + 3) Temperature source preset + 4) ESXi NVMe source settings + 5) Local Linux disk settings + 6) Remote NVIDIA GPU settings + 7) Fan curve + 8) Safety, timing, and logging + 9) Review redacted configuration + 10) Validate configuration + 11) Run read-only diagnostics + 0) Save and exit ``` -第一次建議選 `iDRAC sensors only`,先不要把外部來源加入決策。TUI 完成後,依序執行: +第一次建議選 `iDRAC sensors only`,先不要把外部來源加入決策。設定 `OPERATION_MODE=auto`、保留 `RESTORE_AUTO_ON_EXIT=true`、替換所選來源的 placeholder,並在啟動前核對曲線。TUI 只儲存設定,不會啟動服務。完成後依序執行: ```bash +mkdir -p logs secrets +docker compose pull make validate -docker compose run --rm idrac-fan-control diagnose -docker compose up -d -docker logs -f idrac-fan-control +docker compose run --rm --no-deps idrac-fan-control config +docker compose run --rm --no-deps idrac-fan-control diagnose ``` -`diagnose` 是唯讀檢查,不會送出風扇 raw command。它會逐項顯示 iDRAC、每個溫度來源、可寫 log 路徑與「如果現在控制會選哪一檔」的 preview。若某個來源不用,從 TUI 的 source preset 移除它,而不是忽略錯誤後繼續運行。 +`diagnose` 不會送出風扇 raw command;會讀取硬體與遠端主機,並建立或 touch 本機 log 路徑。它會逐項顯示 iDRAC、每個溫度來源、可寫 log 路徑與「如果現在控制會選哪一檔」的 preview。若某個來源不用,從 TUI 的 source preset 移除它,而不是忽略錯誤後繼續運行。 -若要編輯另一份設定檔: +完成有人監看的[手動與還原測試](#安全啟動順序)後,才啟動無人值守服務: ```bash -src/fan-control-tui.sh --config /path/to/staging.env +docker compose up -d +docker compose ps +docker logs -f idrac-fan-control ``` +Compose 使用儲存庫根目錄的 `.env`。TUI 的 `--config /path/to/staging.env` 可編輯其他檔案,但 Compose 仍需要根目錄 `.env`;部署前請將核對後的設定複製至該處。替代檔案的診斷不能證明實際部署設定正確。 + ### 手動建立 `.env`(不用 TUI 也可以) ```bash @@ -121,14 +144,16 @@ docker compose run --rm idrac-fan-control manual 35 docker compose run --rm idrac-fan-control restore ``` -本機腳本可直接使用相同命令: +`manual` 與 `once` 離開後仍維持所選 duty,必須明確執行 `restore`。`RESTORE_AUTO_ON_EXIT` 只適用於持續執行的 `auto`。執行一次性風扇命令前,先停止現有控制器,避免下一個 cycle 覆寫。Compose 使用 `restart: unless-stopped`;服務的 `.env` 請維持 `OPERATION_MODE=auto`,`manual`/`once` 則透過 `docker compose run --rm --no-deps` 一次性執行。 + +本機腳本接受相同命令,但**不會載入 `.env`**,只讀取已匯出的環境變數;正式部署建議使用 Compose。安全的離線檢查: ```bash -src/FanControlWithEsxiSmart.sh diagnose -src/FanControlWithEsxiSmart.sh config +make validate-example +src/FanControlWithEsxiSmart.sh help ``` -本機執行需要 `bash`、`coreutils`、`ipmitool`、`timeout`。Linux 磁碟模式另需 `smartctl` 與 `jq`;SSH password 模式另需 `sshpass`。Docker image 已包含這些依賴。 +本機執行需要 Bash 4+、GNU coreutils(`timeout`、`stat`)、awk 與 `ipmitool`。Linux 磁碟另需 `smartctl`、`jq`;SSH 來源需要 OpenSSH,密碼認證另需 `sshpass`;本機 GPU 需要 `nvidia-smi`。Docker image 包含 CLI 依賴,但主機仍須提供 NVIDIA driver/toolkit。 ## 安全啟動順序 @@ -143,7 +168,7 @@ sequenceDiagram C->>D: mc info / SDR (read-only) D-->>C: 連線與溫度 C-->>U: source checks + decision preview - U->>C: manual 30 + U->>C: manual 70 (有人監看的範例) C->>D: set fan duty (受控測試) U->>C: restore C->>D: Dell automatic fan control @@ -154,10 +179,21 @@ sequenceDiagram 1. iDRAC Web UI 的 IPMI over LAN 已開啟,管理網路可達。 2. iDRAC 帳號具備必要權限,密碼不再是 placeholder。 -3. `manual 30` 能設定低速,`manual 70` 能設定保守速度,`restore` 能回到 Dell 自動模式。 +3. 停止控制器後,以保守 duty(例如 `manual 70`)測試,同時在 iDRAC 觀察溫度與風扇,再執行 `restore` 並確認 Dell 自動模式。僅在有人監看的維護時段調整;沒有適用所有硬體的安全百分比。 4. `diagnose` 的每一個已啟用來源都是 `[PASS]`;不用的來源請停用。 5. 先以較保守的 `FAILSAFE_FAN_SPEED` 和 `RESTORE_AUTO_ON_EXIT=true` 運行。 +有人監看的測試範例(**會改變硬體狀態**,僅在自己的相容伺服器上執行): + +```bash +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control manual 70 +docker compose run --rm --no-deps idrac-fan-control status +docker compose run --rm --no-deps idrac-fan-control restore +``` + +`auto` 是本專案的軟體迴圈,會反覆接管 iDRAC 手動控制;`restore` 才是交還 Dell 韌體演算法。離開時的自動還原只能盡力執行:前景查詢/sleep 會延遲訊號處理、Docker 可能強制終止程序,主機或網路故障也可能阻止 IPMI 還原。請始終遵循明確的[停止與還原程序](USAGE_GUIDE.md#stop-and-restore-dell-automatic-control)。 + ## 溫度來源與控制決策 `TEMPERATURE_SOURCES` 使用逗號分隔,可填 `esxi`、`idrac`、`gpu`、`linux_disk`、`remote_gpu`。來源可以混合;控制器會保留每個來源的 label 供 log 與診斷追蹤。擴充介面與部署範例請見 [Temperature source interface](docs/TEMPERATURE_SOURCES.md)。 @@ -218,11 +254,11 @@ flowchart TD | `IDRAC_PASSWORD` | 空 | 由 `IPMI_PASSWORD` environment 傳給 `ipmitool -E`,不出現在 argv | | `IPMI_INTERFACE` | `lanplus` | 通常保持不變 | | `IPMI_TIMEOUT` / `IPMI_RETRIES` | `5` / `2` | 單次 timeout 與 retry | -| `OPERATION_MODE` | `manual` | `auto`、`once`、`manual` | -| `DRY_RUN` | `false` | 只在測試命令組合時使用;不會產生真實讀值 | +| `OPERATION_MODE` | `manual`(模板:`auto`) | 未帶 CLI 命令時執行的命令 | +| `DRY_RUN` | `false` | 只抑制 IPMI;SSH、GPU 與磁碟收集仍可能執行,不是離線沙箱 | | `COMMAND_TIMEOUT` | `20` | SSH、IPMI、GPU 外部命令上限(秒) | | `CHECK_INTERVAL` | `60` | auto 每個 cycle 間隔(秒) | -| `RESTORE_AUTO_ON_EXIT` | `true` | auto 收到 SIGTERM/離開時還原 | +| `RESTORE_AUTO_ON_EXIT` | `true` | 僅持續 `auto` 離開時盡力還原;SIGKILL、斷電或網路故障後無法保證 | ### 溫度來源 @@ -258,14 +294,14 @@ flowchart TD | `HYSTERESIS` | `2` | 僅階梯模式:降檔所需低於前 threshold 的°C | | `FAILSAFE_ON_ERROR` | `true` | 所有來源失敗時使用保守速度 | | `FAILSAFE_FAN_SPEED` | `70` | 必須 >= critical speed | -| `MANUAL_FAN_SPEED` | `35` | `manual` 未帶參數時使用 | +| `MANUAL_FAN_SPEED` | 空(模板:`35`) | 未帶速度參數時使用;否則在終端提示輸入,非互動 stdin 則失敗 | | `LOG_DIR` / `LOG_FILE` | `/var/log/fan-control` / `fan_control.log` | 持久化狀態 log | | `LOG_LEVEL` | `INFO` | `DEBUG` 會增加命令與來源細節,絕不列密碼 | | `HEALTHCHECK_MAX_AGE` | `0` | 0 代表 `CHECK_INTERVAL*3 + COMMAND_TIMEOUT` | ## Docker 部署、Linux 磁碟與 GPU -Compose 預設使用 GHCR image、host network 與 `./logs` volume: +Compose 預設使用 `ghcr.io/df-wu/idrac-fan-control:latest`、Linux host network 與 `./logs` volume。`latest` 跟隨預設分支建置,不是固定版本;升級前記錄可用的 digest,請見[升級與回復](USAGE_GUIDE.md#upgrade-and-rollback)。 ```bash docker compose pull @@ -274,7 +310,7 @@ docker compose ps docker inspect --format '{{.State.Health.Status}}' idrac-fan-control ``` -`healthcheck` 不只驗證 env;在 `OPERATION_MODE=auto` 時也會確認 `fan_control.log` 在 `HEALTHCHECK_MAX_AGE` 內更新。若資料來源全部失敗且 `FAILSAFE_ON_ERROR=false`,控制 cycle 不會寫成功紀錄,容器會變成 unhealthy,這是刻意的安全訊號。 +`healthcheck` 不只驗證 env;在 `OPERATION_MODE=auto` 時也會確認 `fan_control.log` 在 `HEALTHCHECK_MAX_AGE` 內更新。若資料來源全部失敗且 `FAILSAFE_ON_ERROR=false`,控制 cycle 不會寫成功紀錄,容器會變成 unhealthy,這是刻意的安全訊號。Fail-safe 紀錄也會維持 log 新鮮度:`healthy` 不代表所有 sensor 正常或硬體溫度安全。Docker 不會僅因 unhealthy 自動重啟;仍須觀察 log 與 iDRAC。 GPU 模式需要 NVIDIA Container Toolkit。編輯 `docker-compose.yml`,取消 `gpus: all` 註解,再設定: @@ -296,6 +332,8 @@ docker compose run --rm idrac-fan-control diagnose docker build --build-arg BASE_IMAGE=ubuntu:24.04 -t idrac-fan-control:local . ``` +接著將 Compose service 的 `image:` 改為 `idrac-fan-control:local`,再執行 `make validate` 與 `diagnose`。`make docker-build` 也只建立本機 image,不會改變 Compose 部署對象。預設 CUDA 建置以 Linux/amd64 為目標,其他架構未驗證。 + Linux 磁碟模式必須將 `LINUX_DISK_DEVICES` 的每個 device 映射進容器,例如: ```yaml @@ -312,7 +350,7 @@ services: 正常 log 範例: ```text -2026-07-18 03:12:10 [INFO] Control temp 68C -> low (30%). Sources: idrac:Inlet Temp=68C +2026-11-11 03:12:10 [INFO] Control temp 68C -> low (36%). Sources: idrac:Inlet Temp=68C ``` 需要更多上下文時暫時設定: @@ -334,8 +372,9 @@ docker compose run --rm idrac-fan-control diagnose 常見最短修復路徑: ```bash -# 任何不確定的風險先還原 Dell 自動控制 -docker compose run --rm idrac-fan-control restore +# 先停止迴圈,再最終還原,避免下一個 cycle 覆寫 +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control restore # 看目前有效設定與依賴狀態 docker compose run --rm idrac-fan-control config @@ -364,7 +403,7 @@ esxcli storage core device smart get -d 't10.NVMe____完整識別字串' ## 測試與品質門檻 ```bash -make test # bash -n + 52 個核心 assertions + 14 個 TUI assertions +make test # Bash 語法檢查與 mock 控制器/TUI 測試 make validate # 以 Docker 依賴檢查目前的 .env(不改變風扇) make validate-example # 不需要 .env 的 DRY_RUN smoke test make docker-build @@ -372,6 +411,12 @@ make docker-build 測試涵蓋統一 source 介面、Linux SMART 收集、多主機 remote GPU、source offset、SDR parsing、插值錨點/取整/邊界、原本降檔遲滯、控制循環狀態與 fail-safe 復原、設定驗證、credential redaction、health freshness、診斷 preview,以及 TUI 設定檔安全 round-trip。真實硬體、SSH target、磁碟、iDRAC 與 GPU 仍須在管理網路上以 `diagnose` 驗證。 +## 版本與貢獻 + +最新已發布 GitHub release 為 `v2.0.1`(2024-10-23),目前 `master` 已累積多項變更。**`v3.0.0` 僅為提案,尚未發布。** 遷移差異請見 [CHANGELOG.md](CHANGELOG.md),維護者發布清單請見 [docs/RELEASING.md](docs/RELEASING.md)。舊設定未指定 `FAN_SPEED_INTERPOLATION` 時也會啟用插值;如需原本階梯控制,請明確設為 `false`。 + +[CONTRIBUTING.md](CONTRIBUTING.md) 說明本機驗證、README 翻譯同步規則,以及免費 OSS CodeRabbit GitHub App 啟用步驟。單獨加入 `.coderabbit.yaml` 不代表已安裝或啟用 App。 + ## 專案結構 ```text @@ -385,12 +430,16 @@ make docker-build │ └── tui.test.sh # .env parser / writer 測試 ├── docs/ │ ├── TEMPERATURE_SOURCES.md # Source 介面與部署範例 -│ └── TROUBLESHOOTING.md # 症狀導向除錯手冊 +│ ├── TROUBLESHOOTING.md # 症狀導向除錯手冊(英文) +│ └── RELEASING.md # 版本提案與發布清單(英文) ├── images/image.png # iDRAC IPMI 設定畫面 ├── .env.example # 帶完整註解的設定模板 ├── docker-compose.yml ├── Dockerfile ├── Makefile +├── CHANGELOG.md # 未發布變更與遷移說明(英文) +├── CONTRIBUTING.md # 驗證、翻譯同步與 CodeRabbit(英文) +├── .coderabbit.yaml # GitHub App 審查設定 ├── README.md ├── README.zh-TW.md └── USAGE_GUIDE.md @@ -398,10 +447,10 @@ make docker-build ## 相容性與限制 -專案以 Dell PowerEdge R730/R730xd、iDRAC 8 類機型的 OEM fan raw command 為主要驗證目標。其他世代可能相容,但不能假設相同;請在無人值守前完成 `manual`/`restore`/`diagnose`。Sensor 名稱、磁碟權限、SSH access 與 driver 行為會依環境改變,應以實際 diagnostic output 為準。 +歷史實機測試僅涵蓋 PowerEdge R730xd 與 iDRAC 8,沒有其他型號或韌體版本範圍的相容認證;請在無人值守前完成 `manual`/`restore`/`diagnose`。Sensor 名稱、磁碟權限、SSH access 與 driver 行為會依環境改變,應以實際 diagnostic output 為準。 ## 授權 MIT,詳見 [LICENSE](LICENSE)。 -文件最後檢視:2026-08-15。 +文件最後檢視:2026-11-11。 diff --git a/USAGE_GUIDE.md b/USAGE_GUIDE.md index d8c848a..df055c3 100644 --- a/USAGE_GUIDE.md +++ b/USAGE_GUIDE.md @@ -1,226 +1,145 @@ -# iDRAC Fan Control 日常 Runbook +# Operations guide -這份文件給已完成初始設定的操作者。第一次安裝、參數定義與架構請先看 [README.md](README.md);遇到錯誤則直接跳到 [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)。 +For first installation, prerequisites, configuration variables, and hardware limitations, start with [README.md](README.md). For errors, use [troubleshooting](docs/TROUBLESHOOTING.md). Commands below assume the repository directory, a reviewed `.env`, and the selected Compose image. They are operator instructions, not evidence of hardware testing. -## 每次變更前的安全習慣 +## Before starting -```text -編輯 .env → validate → diagnose → manual 小幅測試 → restore → 啟動 auto -``` +1. Keep iDRAC Web UI or physical console access available. Historical testing covers only one R730xd with iDRAC 8; verify your own model and firmware. +2. Create `.env` with `make tui` or copy `.env.example`, set permissions to `600`, and replace selected-source placeholders. Keep `OPERATION_MODE=auto` for the long-running Compose service. +3. Prepare directories and the image, then perform checks that do not change fans: -永遠保留一個能登入 iDRAC Web UI 的工作階段。`diagnose` 只讀取,不等於 `manual` 已在你的機型上驗證;第一次仍應完成一次低速、一次保守速度與一次 restore。 + ```bash + mkdir -p logs secrets + docker compose pull + make validate + docker compose run --rm --no-deps idrac-fan-control config + docker compose run --rm --no-deps idrac-fan-control diagnose + ``` -## 每日操作 +`validate` checks the configured `OPERATION_MODE`; it does not test connectivity. `diagnose` validates all selected sources, reads hardware/SSH endpoints, and creates/touches the log path without sending fan raw commands. Check each device/host warning as well as the overall result: a multi-target source passes if at least one target supplies a reading. Review the selected temperature and predicted duty against your hardware needs. -啟動、查看狀態與持續 log: +Before unattended operation, stop any active controller, test a conservative manual duty while watching iDRAC temperatures/fans, and explicitly restore. For example: ```bash -docker compose up -d -docker compose ps -docker logs -f idrac-fan-control -tail -f logs/fan_control.log +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control manual 70 +docker compose run --rm --no-deps idrac-fan-control status +docker compose run --rm --no-deps idrac-fan-control restore ``` -`fan_control.log` 的每一筆成功 cycle 會包含 status、決策溫度、level、fan 與來源細節。若 container 顯示 `unhealthy`,不要只重啟;先執行: +These commands change hardware. No duty is universally safe. `status` shows chassis and temperatures, not proof of the selected fan duty; verify fans and firmware automatic control in iDRAC. If any command fails, keep the controller stopped and resolve recovery before proceeding. -```bash -docker compose run --rm idrac-fan-control healthcheck -docker compose run --rm idrac-fan-control diagnose -``` +## Daily operation -執行一次控制(適合維護視窗): +After the supervised checks: ```bash -docker compose run --rm idrac-fan-control once +docker compose up -d +docker compose ps +docker logs -f idrac-fan-control +tail -f logs/fan_control.log ``` -查看不改變風扇的摘要: +A successful cycle records `status=ok`, temperature, level, duty, and source details. All-source failure with `FAILSAFE_ON_ERROR=true` writes `status=failsafe` and applies `FAILSAFE_FAN_SPEED`. Partial failures continue with remaining readings; investigate them because the hottest component may be missing. With fail-safe disabled, all-source failure leaves the previous fan state and writes no new cycle record. -```bash -docker compose run --rm idrac-fan-control config -docker compose run --rm idrac-fan-control status -``` - -## TUI 設定與變更流程 +The healthcheck measures log freshness in `OPERATION_MODE=auto`, including fail-safe records. It does not prove safe temperatures, complete source coverage, or hardware response. Outside `auto`, it only validates configuration. Docker does not restart containers solely because they become unhealthy. ```bash -make tui +docker compose exec idrac-fan-control /usr/local/bin/fan-control.sh healthcheck +docker compose run --rm --no-deps idrac-fan-control diagnose ``` -TUI 的每個子頁會直接更新 `.env`,退出時不會自動啟動服務。建議順序: - -1. `Review redacted configuration` 確認來源、曲線與 fail-safe;密碼只會顯示為 set/長度。 -2. `Validate configuration` 修正所有 ERROR;不要把 WARN 當成成功的替代品。 -3. `Run read-only diagnostics` 確認每個選取的 source 都是 PASS。 -4. 回到 shell,執行 `docker compose up -d`。 +Use `exec` for the running controller healthcheck; a one-off `run ... healthcheck` uses the current disk `.env`, which may differ from the running container after edits. `config` is redacted, but review hostnames and addresses before sharing it. -如果只要改一個值,手動編輯 `.env` 也可以;不要直接改容器裡的檔案,因為 container 會被重建。 +## Manual and one-cycle operation -## 手動風扇與還原 - -先在低風險維護時段測試: +Stop the continuous controller first. `once` reads temperatures and applies one curve/fail-safe decision; `manual 70` applies a fixed duty. Both leave manual control active after exit. Only continuous `auto` has an exit restoration trap. ```bash -docker compose run --rm idrac-fan-control manual 30 -docker compose run --rm idrac-fan-control status -docker compose run --rm idrac-fan-control manual 70 -docker compose run --rm idrac-fan-control restore +docker compose stop --timeout 90 +docker compose run --rm --no-deps idrac-fan-control once +# Observe the hardware, then explicitly restore: +docker compose run --rm --no-deps idrac-fan-control restore ``` -`manual` 的百分比範圍是 1–100;`restore` 送出 `raw 0x30 0x30 0x01 0x01`,將控制權交還 Dell。不要用 `DRY_RUN=true` 來判斷真實硬體反應,它只會顯示命令而不觸碰 iDRAC。 - -## 緊急程序 - -遇到溫度異常、噪音失控、來源讀值不可信或不確定目前狀態時: +Manual accepts integer duty from 1–100. Without a CLI speed, it uses `MANUAL_FAN_SPEED` (template: `35`; runtime default: empty). Without either, it prompts on a terminal or fails with noninteractive stdin. Do not put `once` or `manual` into the long-running service: its restart policy can repeatedly execute them. -1. 立即還原 Dell 自動控制。 +`DRY_RUN=true` suppresses IPMI calls, including restoration. It does not simulate sensor data or suppress SSH, `nvidia-smi`, or `smartctl` queries. Use `make test` and `make validate-example` for offline verification. - ```bash - docker compose run --rm idrac-fan-control restore - ``` - -2. 停止 controller,避免下一個 cycle 再次覆寫設定。 - - ```bash - docker compose down - ``` +## Stop and restore Dell automatic control -3. 從 iDRAC Web UI 或實體主控台確認溫度與風扇;必要時保持 Dell 自動模式。 - -4. 保存當下輸出供除錯: - - ```bash - docker compose run --rm idrac-fan-control config > config-after-incident.txt - docker compose run --rm idrac-fan-control diagnose 2>&1 | tee diagnose-after-incident.txt - cp .env .env.after-incident - chmod 600 .env.after-incident - ``` - -5. 修正來源、曲線或管理網路後,重新走一次 `validate → diagnose → manual → restore`,才恢復 `auto`。 - -## 常見變更 - -### 改用 iDRAC sensors,不依賴 ESXi - -```dotenv -TEMPERATURE_SOURCES=idrac -``` - -### 混合 ESXi 與 iDRAC - -```dotenv -TEMPERATURE_SOURCES=esxi,idrac -ESXI_HOST=192.0.2.20 -ESXI_USERNAME=root -ESXI_SSH_KEY=/run/secrets/esxi_ed25519 -DRIVE_DEVICE=t10.NVMe____full_identifier -``` - -準備 key volume(不要提交 `secrets/`): +Stop the loop **before the final restore**, so another cycle cannot retake manual control: ```bash -mkdir -p secrets -cp ~/.ssh/esxi_ed25519 secrets/esxi_ed25519 -chmod 600 secrets/esxi_ed25519 +docker compose stop --timeout 90 +docker compose run --rm --no-deps -e DRY_RUN=false idrac-fan-control restore ``` -### TrueNAS CD6 與其他 VM 的 GPU - -目前 TrueNAS 25.10 主機上的 Kioxia CD6 controller device 是 `/dev/nvme1`。先在 host 唯讀確認: - -```bash -sudo smartctl -A -j /dev/nvme1 | jq '.temperature.current' -``` +Confirm the restore command succeeded and verify firmware automatic control and temperatures in iDRAC. Keep the service stopped until the problem is understood. After successful recovery, `docker compose down` can remove the stopped service; logs remain in `./logs`. -設定 CD6 與多台 NVIDIA VM: +`RESTORE_AUTO_ON_EXIT=true` is best-effort. Bash can defer signal handling while waiting for a foreground query or sleep; the default Compose stop timeout can expire first. The explicit 90-second wait accommodates the default 60-second sleep and usual command timing, but longer intervals, multiple slow sources, SIGKILL, host failure, or lost IPMI connectivity can still prevent trap restoration. The separate restore command remains required. If Docker or IPMI is unavailable, use the supported iDRAC/console recovery procedure for your server and verify cooling there. -```dotenv -TEMPERATURE_SOURCES=linux_disk,remote_gpu -LINUX_DISK_DEVICES=/dev/nvme1 -LINUX_DISK_TEMP_OFFSET=0 +For an incident, capture evidence after recovery: -REMOTE_GPU_HOSTS=gpu-vm-1,gpu-vm-2 -REMOTE_GPU_USERNAME=monitor -REMOTE_GPU_SSH_KEY=/run/secrets/gpu_vms_ed25519 -REMOTE_GPU_PASSWORD= -REMOTE_GPU_SSH_PORT=22 -REMOTE_GPU_TEMP_OFFSET=15 -``` - -在 `docker-compose.yml` 的 service 加入精確 device mapping: - -```yaml -devices: - - /dev/nvme1:/dev/nvme1 +```bash +docker logs --tail 200 idrac-fan-control > incident-container.log 2>&1 +docker compose run --rm --no-deps idrac-fan-control config > incident-config.txt +docker compose run --rm --no-deps idrac-fan-control diagnose > incident-diagnose.txt 2>&1 ``` -每台 GPU VM 必須讓該 SSH 帳號可執行唯讀的 `nvidia-smi --query-gpu=index,temperature.gpu --format=csv,noheader,nounits`。設定後先跑 `validate` 與 `diagnose`;預期同時看到 `source:linux_disk`、`source:remote_gpu` 和 decision preview。詳見 [Temperature source interface](docs/TEMPERATURE_SOURCES.md)。 +Review these files before sharing. Never upload `.env`, private keys, service tags, or management credentials. -### 啟用 GPU +## Configuration changes and optional sources -```dotenv -TEMPERATURE_SOURCES=idrac,gpu -GPU_TEMP_OFFSET=15 -``` - -同時確認 Compose 的 `gpus: all` 已啟用、主機有 NVIDIA Container Toolkit,再用 `diagnose` 驗證;GPU 失敗不應被悄悄當作 0°C。 +`make tui` saves each submenu directly to `.env` and does not start the service. Stop and restore before changing the deployed configuration; use the root `.env`, review `config`, validate, diagnose, and repeat supervised checks as needed. Recreate the container with `docker compose up -d --force-recreate` after validation. `docker compose restart` does not reload environment changes. -### 線性插值與階梯模式 - -```dotenv -FAN_SPEED_INTERPOLATION=true -``` +- `idrac`: start with `TEMPERATURE_SOURCES=idrac`; inspect the sensor list and choose filters that cover relevant heat sources. +- `esxi`: configure host, username, password or key, and the full `DRIVE_DEVICE`. Use the identifier commands in [README.md](README.md#finding-the-esxi-drive-identifier). +- `linux_disk`: configure exact device paths and corresponding Compose `devices` mappings. Discover paths on your host; `/dev/nvme1` is an example, not a universal CD6 identifier. +- `gpu`: enable Compose `gpus: all` and install the host driver/toolkit before diagnostics. +- `remote_gpu`: configure hosts and a shared SSH identity. Every host must expose `nvidia-smi` in its noninteractive SSH PATH. -預設開啟,舊 `.env` 沒有此選項也會啟用。TUI 的 **Fan curve** 可切換,Compose 經由既有 `env_file: .env` 傳入;修改後需重建容器才會套用。`config` 與唯讀 `diagnose` 會顯示目前模式及遲滯是否生效。 +For keys, copy only the selected identity into `./secrets`, restrict it to `600`, and reference `/run/secrets/` in `.env`. New containers do not persist learned SSH host keys by default; provision a verified `known_hosts` mount and use `SSH_STRICT_HOST_KEY_CHECKING=yes` where required. See [source deployment examples](docs/TEMPERATURE_SOURCES.md). -插值以 `TEMP_LOW/MEDIUM/HIGH/CRITICAL` 及相對應的 `FAN_SPEED_LOW/MEDIUM/HIGH/CRITICAL` 為錨點,錨點間線性計算並向上取整為整數 duty。低於 `TEMP_LOW` 保留 `FAN_SPEED_IDLE`,達到/超過 `TEMP_CRITICAL` 固定為 critical speed;idle 與 low 不同時在 `TEMP_LOW` 會跳差,沒有另設 idle 溫度錨點。例如閾值 `65/70/75/80`、速度 `30/35/45/60/65` 時,`70/71/72/73/74/75°C` 對應 `45/48/51/54/57/60%`。 +Interpolation is now default even when an old `.env` omits the switch. It rounds duty upward between four anchors and ignores hysteresis. Set `FAN_SPEED_INTERPOLATION=false` to retain stepwise control with downshift-only hysteresis. See the [curve reference](README.md#temperature-sources-and-control-decisions). -插值模式不使用 `HYSTERESIS`,不受前次 level 限制。每次收集後立即依需求升降速,同 level 內也會更新;整數 duty 相同時不重送命令。不加入額外平滑、PID 或速率限制。感測器最大值、offset、異常讀值過濾與 fail-safe 保護維持原有行為。 +## Upgrade and rollback -若要恢復原本階梯模式與降檔遲滯: +`latest` is mutable and follows default-branch builds. Before an upgrade, record the running image reference/digest and code revision, and back up `.env` plus Compose overrides privately: -```dotenv -FAN_SPEED_INTERPOLATION=false -HYSTERESIS=3 -``` - -此時每檔維持固定速度;Hysteresis 只延遲降檔,溫度降到前一檔閾值減 `HYSTERESIS`(含等號)就釋放。升檔不延遲,critical 仍會立即生效。 - -### 提高感測器失敗時的保護 - -```dotenv -FAILSAFE_ON_ERROR=true -FAILSAFE_FAN_SPEED=80 +```bash +umask 077 +backup_dir="../idrac-fan-backup-$(date +%Y%m%d-%H%M%S)" +mkdir -p "$backup_dir" +cp .env docker-compose.yml "$backup_dir/" +# Also copy any Compose override files you use. +git rev-parse HEAD > "$backup_dir/code-revision.txt" +docker inspect idrac-fan-control --format '{{.Config.Image}} {{.Image}}' > "$backup_dir/container-image.txt" +docker image inspect "$(docker inspect idrac-fan-control --format '{{.Image}}')" \ + --format '{{json .RepoDigests}}' > "$backup_dir/image-digests.txt" ``` -`FAILSAFE_FAN_SPEED` 必須不低於 `FAN_SPEED_CRITICAL`;`validate` 會拒絕不安全的遞減曲線。 - -## 更新與回復 +Stop and explicitly restore using the procedure above. Update only a clean checkout; preserve local Compose changes/overrides and do not discard them to force an update. For a branch following upstream: ```bash git pull --ff-only -docker compose pull -docker compose up -d -docker compose ps ``` -更新前先備份設定(不要提交到 Git): +Review [migration notes](CHANGELOG.md), merge new `.env.example` options into the protected `.env`, and select the intended image in Compose. Prefer `ghcr.io/df-wu/idrac-fan-control@sha256:` or a published version tag over `latest`. `3.0.0` becomes available only after the proposed release is published. Do not paste the digest placeholder literally. ```bash -cp .env ".env.backup.$(date +%Y%m%d-%H%M%S)" -chmod 600 .env.backup.* +docker compose pull +make validate +docker compose run --rm --no-deps idrac-fan-control diagnose +# Repeat supervised manual/restore checks for behavior changes, then: +docker compose up -d --force-recreate +docker compose ps ``` -若新 image 行為不符預期,先 `restore`、`down`,再切回已知版本 image 或回復程式碼;不要在風扇已異常時反覆 `up`。 +For rollback, stop and restore again, select the saved known-good image digest (or retained local image), restore the matching code/config/Compose files, validate and diagnose, and only then restart. Restoring old code alone does not change the Compose image. Do not prune the previous image until the new deployment is verified. If the previous version cannot restore or monitor safely, keep Dell automatic control active instead of restarting it. -## 維護與驗證 - -```bash -make test -make validate -make docker-build -``` +## Log retention -長時間運行請確認 `logs/` 有輪替策略;專案只負責寫入單一 log,不會替主機設定 logrotate。建議以主機的 logrotate 或 journald retention 管理容量。 +The controller appends to a single `logs/fan_control.log`; it does not rotate it. Configure host logrotate/retention and monitor space. Stderr appears in Docker logs; apply a host Docker logging policy as needed. -文件最後檢視:2026-08-15。 +Documentation last reviewed: November 11, 2026. diff --git a/docs/RELEASING.md b/docs/RELEASING.md new file mode 100644 index 0000000..e538e12 --- /dev/null +++ b/docs/RELEASING.md @@ -0,0 +1,74 @@ +# Release preparation and maintainer checklist + +**Proposed version: v3.0.0. Status: unpublished; no release tag or publication is authorized by this preparation.** + +The last published GitHub release and Git tag are `v2.0.1` (2024-10-23). At preparation time, `master` was `5aee2b9d2746fd46a2a792897962e3d185316e1c` (interpolation, PR #6). [CHANGELOG.md](../CHANGELOG.md) contains proposed release notes and migration steps for all changes since that tag. Version 3 is proposed because the accumulated controller/deployment changes, stricter validation, new defaults, and default-enabled interpolation alter existing operation. There is no package version file to bump. + +## Review before publication + +- [ ] Review and merge the preparation PR through the normal maintainer process. This document does not authorize merge or publication. +- [ ] Select the final release commit from reviewed `master`; record its **full SHA** in the release notes/checklist. Refresh the history comparison if more changes land. +- [ ] Confirm `v3.0.0` remains unused, review the changelog, rename the Unreleased heading with the actual publication date, and synchronize release status in both READMEs. Commit those final documentation changes before selecting the tag target. +- [ ] Confirm mocked tests, offline validation, Compose validation, and the default Docker build pass at the exact release commit. Keep logs/CI links: + + ```bash + git status --short + git log --oneline v2.0.1..HEAD + make test + make validate-example + # In a disposable checkout only; never overwrite a deployment .env: + cp .env.example .env + chmod 600 .env + docker compose config --quiet + make docker-build + git diff --check + ``` + +- [ ] Review interpolation migration (`FAN_SPEED_INTERPOLATION=false` for stepwise control), old/new threshold defaults, placeholder validation, explicit image selection, source dependencies and mappings, log persistence, and protected config backups. +- [ ] Record the hardware verification actually performed, with model/firmware and results, or explicitly state none was performed. Historical evidence covers only one R730xd/iDRAC 8; do not claim a supported firmware range. Keep hardware/services unchanged during software-only release preparation. +- [ ] Confirm exit restoration is described as best-effort and the manual stop/restore procedure is available. A healthy log is not evidence of safe cooling. +- [ ] Confirm CodeRabbit App access/OSS eligibility and check actual PR review evidence. Record any activation blocker instead of claiming reviews work from configuration alone. CodeRabbit does not replace maintainer review or hardware validation. +- [ ] Prepare the final release body from the v3.0.0 changelog section, including migration notes, exact target SHA, verification evidence/limits, and rollback instructions. Review it as a local Markdown file before publishing. + +## Publication boundary — separate maintainer action + +The existing workflow publishes images on **every push to `master` and every `v*` tag**. Pushing a tag is already a publication action; a draft GitHub release is not a safeguard against it. PRs run a non-publishing build. Do not push a tag just to test this workflow. + +After a maintainer separately approves publication and checks the selected SHA: + +1. Fetch `origin/master` and tags, ensure a clean checkout, and select the reviewed release commit. Check it contains the final workflow and documentation. Confirm the remote tag does not exist: + + ```bash + git fetch origin master --tags + git rev-parse HEAD + git ls-remote --tags origin refs/tags/v3.0.0 + ``` + +2. Create an annotated `v3.0.0` tag at that exact approved commit and push **only that tag**. This immediately triggers the Docker publication job. Do not run these until publication approval: + + ```bash + release_commit=REPLACE_WITH_APPROVED_FULL_SHA + git tag -a v3.0.0 "$release_commit" -m "Release v3.0.0" + git push origin refs/tags/v3.0.0 + ``` + +3. Confirm the tag workflow succeeds. It publishes `ghcr.io/df-wu/idrac-fan-control:3.0.0`, `:3.0`, and a `:sha-` tag. The `v` prefix is removed from semver image tags; there is no configured major-only `:3` tag. `latest` tracks default-branch pushes and is **not** updated by the tag event. Verify version labels and record the immutable image digest: + + ```bash + docker buildx imagetools inspect ghcr.io/df-wu/idrac-fan-control:3.0.0 + ``` + +4. Publish the GitHub release using the reviewed local notes and existing tag, after image verification. GitHub release publication is a separate step; the image workflow does not create it. For example, with a reviewed local `release-notes-v3.0.0.md`: + + ```bash + gh release create v3.0.0 --repo DF-wu/iDRACFanSpeedControl \ + --verify-tag --title 'v3.0.0' --notes-file release-notes-v3.0.0.md + ``` + +5. Check the public release notes, source archives, image tags/digest, and README links. Record any failed publication step; do not move a published tag silently. If a rebuild is required, agree on a new patch release. + +## Rollback + +Keep the previous known-good image digest and matching code/configuration. Stop the controller, explicitly restore Dell firmware control, restore the saved deployment/image/config, validate and diagnose, then supervise restart. See the complete [upgrade and rollback procedure](../USAGE_GUIDE.md#upgrade-and-rollback). Do not assume checking out an older Git tag changes the Compose image, and do not recommend v2.0.1 as a universal safe rollback target: its controller and deployment differ substantially. + +Publication remains pending maintainer action. This checklist does not deploy a service, touch iDRAC, or certify hardware. diff --git a/docs/TEMPERATURE_SOURCES.md b/docs/TEMPERATURE_SOURCES.md index f6834e9..571520a 100644 --- a/docs/TEMPERATURE_SOURCES.md +++ b/docs/TEMPERATURE_SOURCES.md @@ -6,7 +6,7 @@ The controller treats every temperature provider through the same interface. `co Register a source ID in `TEMPERATURE_SOURCE_IDS`, then implement these Bash functions in `src/FanControlWithEsxiSmart.sh`: -```bash +```text temperature_source__validate() { ...; } temperature_source__collect() { ...; } temperature_source__adjust() { ...; } @@ -22,7 +22,7 @@ Each collection record has this format: source_idsensor_labelraw_temperature_celsius ``` -Labels must not contain tabs or newlines. A source must reject missing, malformed, or unsupported readings instead of emitting `0`. The controller applies every source's `adjust` method, logs both raw and adjusted values when they differ, and selects the highest adjusted temperature. +Labels must not contain tabs or newlines. A source must reject missing, malformed, or unsupported readings instead of emitting `0`. The controller rejects raw temperatures outside −20…150°C before applying every source's `adjust` method, logs both raw and adjusted values when they differ, and selects the highest adjusted temperature. `temperature_source_interface_complete` checks the contract during validation. The supported source list is an allowlist, so an environment value cannot invoke an arbitrary shell function. @@ -55,7 +55,7 @@ Grant access only to selected devices. Raw disk access is sensitive even though ## TrueNAS CD6 plus remote GPU VMs -The following configuration combines a TrueNAS-hosted Kioxia CD6 with GPUs in two Linux VMs: +The following example combines a TrueNAS-hosted Kioxia CD6 with GPUs in two Linux VMs. Discover the real disk path on your own host; `/dev/nvme1` is not a universal CD6 identifier: ```dotenv TEMPERATURE_SOURCES=linux_disk,remote_gpu diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index c8faf0a..149b31d 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -1,184 +1,61 @@ -# iDRAC Fan Control 故障排除手冊 +# Troubleshooting -這份手冊以症狀為入口。任何可能涉及過熱或未知 fan state 的問題,第一步都不是重啟,而是把控制交還 Dell: +If cooling or the current fan state is uncertain, follow [stop and restore](../USAGE_GUIDE.md#stop-and-restore-dell-automatic-control) first: ```bash -docker compose run --rm idrac-fan-control restore -docker compose down +docker compose stop --timeout 90 +docker compose run --rm --no-deps -e DRY_RUN=false idrac-fan-control restore ``` -## 標準診斷流程 - -```mermaid -flowchart TD - A[發現錯誤或 unhealthy] --> B{溫度或風扇有立即風險?} - B -- 是/不確定 --> C[restore + docker compose down] - B -- 否 --> D[config + validate] - C --> D - D --> E[LOG_LEVEL=DEBUG] - E --> F[diagnose] - F --> G{iDRAC/IPMI PASS?} - G -- 否 --> H[修復管理網路、權限、IPMI over LAN] - G -- 是 --> I{每個 selected source PASS?} - I -- 否 --> J[修復或從 TEMPERATURE_SOURCES 移除] - I -- 是 --> K[once / manual 維護測試] - K --> L[restore 後再啟動 auto] -``` +Confirm firmware automatic control in iDRAC. Keep the controller stopped while diagnosing. Exit restoration is best-effort and may not execute before Docker force-kills a process blocked in a foreground query/sleep. -先收集不含明文密碼的證據: +## Collect evidence without changing fans ```bash -docker compose run --rm idrac-fan-control config -docker compose run --rm idrac-fan-control validate -docker compose run --rm idrac-fan-control diagnose +docker compose run --rm --no-deps idrac-fan-control config +make validate +docker compose run --rm --no-deps idrac-fan-control diagnose docker compose ps docker logs --tail 200 idrac-fan-control tail -n 200 logs/fan_control.log ``` -需要命令階段與來源選擇細節時,在 `.env` 設 `LOG_LEVEL=DEBUG` 後重跑 `diagnose`。Debug log 不會列出 iDRAC、ESXi 或 remote GPU 密碼;提交 issue 前仍應檢查主機名稱、IP、device identifier 是否需要遮罩。 - -## Diagnostic output 怎麼讀 - -成功範例: - -```text -iDRAC Fan Control diagnostics (read-only) -[PASS] configuration static validation passed -[PASS] log path /var/log/fan-control -[PASS] iDRAC/IPMI 2.60, PowerEdge R730xd -[PASS] source:idrac Inlet Temp=24C, Exhaust Temp=39C -[PASS] source:esxi t10.NVMe...=46C -[PASS] decision preview 46C -> idle (30%), no command sent - -Result: PASS - controller dependencies are ready. -``` - -`source:*` 只要有一個選取來源失敗,diagnose 就回傳非零,即使另一來源仍可讀。這是為了讓「降級運行」變得可觀測;auto 實際決策仍會使用剩餘的有效 readings,只有全部失敗才進 fail-safe。 - -## 症狀對照表 - -| 症狀/訊息 | 最可能原因 | 確認方式 | 修復 | -| --- | --- | --- | --- | -| `Missing required configuration: IDRAC_IP` | `.env` 未填或 TUI 未完成 | `... config` | `make tui` 填入真實 target | -| `Replace placeholder value` | 還在用 `change-me`、`192.0.2.*` 類模板值 | `... config` | 換成環境實值 | -| `Required command not found: ipmitool` | 直接在 host 跑但未安裝依賴 | `command -v ipmitool` | 用 Docker,或安裝 ipmitool/coreutils | -| `iDRAC/IPMI ... failed` | IPMI over LAN 關閉、網路 ACL、帳密/權限錯 | `ipmitool ... mc info` | 修復 iDRAC 設定與管理網路 | -| `source:idrac ... no valid` | SDR 無 readable temperature 或 regex 過濾全部 | `status`、清空 include regex | 修正 filter;保留預設 exclude | -| `source:esxi ... no valid` | SSH、device ID 或 SMART 格式錯 | ESXi 上直接跑 `esxcli ... smart get` | 修復 key/password、port、完整 ID | -| `source:gpu ... no valid` | 容器無 GPU、驅動/Toolkit 未配置 | `docker ... nvidia-smi` | 啟用 `gpus: all` 與 Toolkit,或移除 gpu source | -| `source:linux_disk ... no valid` | device 未映射、權限不足、SMART 無溫度 | host 與容器內分別執行 `smartctl -A -j` | 加入精確 `devices` mapping,確認 `jq` 與路徑 | -| `source:remote_gpu ... no valid` | VM 不可達、SSH 認證或遠端 `nvidia-smi` 失敗 | 以相同 key 手動 SSH 執行 query | 修復 host/key/known_hosts/driver,或移除失敗 target | -| `No valid temperature readings` | 所有 selected sources 都失敗 | `diagnose` | 修復至少一個 source;先保留 fail-safe | -| `Fail-safe fan speed applied` | 上述全部失敗且 fail-safe 開啟 | 同時看前面的 source WARN | 修復來源;這不是曲線 level | -| `Fan speeds must not decrease` | 高溫檔位比低溫檔位低 | TUI Review | 讓 idle ≤ low ≤ medium ≤ high ≤ critical | -| `FAILSAFE_FAN_SPEED must be at least...` | fail-safe 比 critical 還低 | `validate` | 提高 fail-safe 或調整曲線 | -| `Healthcheck control loop is stale` | auto cycle 不再寫 log、volume 或來源失敗 | `healthcheck`、`docker logs` | 修正 cycle 錯誤/volume,不要只提高 max age | -| 容器反覆 restart | 主程序啟動 validation 失敗 | `docker compose logs` | 修正 `.env` 後再 up | -| 關閉容器後仍是 manual fan | restore 指令失敗或容器被強制終止 | 直接執行 `restore` | 確認 iDRAC 可達並從 Web UI 檢查 | - -## iDRAC / IPMI 深入檢查 - -控制器使用 `IPMI_PASSWORD` environment 搭配 `ipmitool -E`,密碼不會出現在 process argv。手動測試時也建議使用相同方式: - -```bash -read -rs IPMI_PASSWORD -export IPMI_PASSWORD -ipmitool -I lanplus -H "$IDRAC_IP" -U "$IDRAC_ID" -E mc info -ipmitool -I lanplus -H "$IDRAC_IP" -U "$IDRAC_ID" -E sdr type Temperature -unset IPMI_PASSWORD -``` - -檢查項目: - -1. iDRAC Web UI 的 IPMI over LAN 已開啟。 -2. host 到 iDRAC 的 UDP 623 未被 ACL/firewall 擋住。 -3. 帳號不是只有 read-only 權限。 -4. `IPMI_INTERFACE=lanplus` 適合該 iDRAC 世代。 -5. timeout 才發生時,可小幅增加 `IPMI_TIMEOUT` 與 `IPMI_RETRIES`,但先排除網路品質。 - -如果 `mc info` 成功但 OEM raw fan command 失敗,機型或 firmware 可能不支援這組 Dell command。不要假設其他 PowerEdge 世代一定相容。 - -## iDRAC sensor filtering - -先看原始輸出: - -```bash -docker compose run --rm idrac-fan-control status -``` - -預設排除 `no reading|disabled|not readable`。若只想採用特定 sensor,可設定 awk regular expression: - -```dotenv -IDRAC_SENSOR_INCLUDE_REGEX=^(Inlet Temp|Exhaust Temp|CPU[12] Temp)$ -``` - -注意 sensor 名稱大小寫由 iDRAC 決定;include regex 套用在 sensor name,exclude regex 套用在轉成小寫的整行。`validate` 會拒絕語法不合法的 regex,但無法預先知道它是否會過濾掉所有實際 sensor,因此仍須跑 `diagnose`。 - -## ESXi NVMe 深入檢查 - -```bash -ssh -p 22 root@ESXI_HOST -esxcli storage core device list -esxcli storage core device smart get -d '完整 DRIVE_DEVICE' -``` - -控制器預期輸出含 `Drive Temperature` 與整數。若裝置只提供其他欄位、輸出語系/格式不同,parser 會安全地回報失敗,不會猜測溫度。SSH key 模式下確認: +Set `LOG_LEVEL=DEBUG` in `.env` and rerun one-off diagnostics for command stages and source details. Recreate the service to apply environment changes when it is safe to restart. `diagnose` never sends fan raw commands, but it performs real read queries and creates/touches the log path. `DRY_RUN` suppresses only IPMI, so it is not a way to run arbitrary configured sources offline. -```bash -chmod 600 /path/to/key -ssh -i /path/to/key -o BatchMode=yes root@ESXI_HOST true -``` - -容器要使用 host key file 時,還必須把 key 以 read-only volume 掛進 container,且 `.env` 的 `ESXI_SSH_KEY` 要填 container 內路徑;只填 host path 不會自動掛載。 - -## Linux 磁碟深入檢查 - -先在 host 上執行與控制器相同的唯讀查詢: - -```bash -sudo smartctl -A -j /dev/nvme1 | jq '.temperature.current // .nvme_smart_health_information_log.temperature' -``` +The config summary redacts passwords; still remove hostnames, addresses, service tags, and device identifiers before sharing. Never attach `.env` or private keys. -再確認容器看到同一個 device: +## Symptoms and checks -```bash -docker compose run --rm --entrypoint sh idrac-fan-control -c \ - 'ls -l /dev/nvme1 && smartctl -A -j /dev/nvme1 | jq .temperature' -``` +| Symptom | Check | Action | +| --- | --- | --- | +| Missing `.env` or placeholder validation errors | Root `.env`, selected sources, actual credentials/address | Run `make tui` or copy the template and replace selected-source placeholders. Alternate TUI config paths do not replace the required root `.env` | +| Local script ignores `.env` | Script reads exported environment only | Use Compose for deployment; the bare script does not load dotenv files | +| IPMI login or `mc info` fails | IPMI over LAN, routing/firewall, privileges, password, `lanplus` support | Resolve management access first; do not start auto | +| Fan raw command rejected | Exact model/firmware and OEM command support | Login success does not prove fan-command support. Only one R730xd/iDRAC 8 has historical testing; keep firmware control active on unsupported systems | +| ESXi has no temperature | SSH, full `DRIVE_DEVICE`, numeric `Drive Temperature` | Check the [ESXi identifier commands](../README.md#finding-the-esxi-drive-identifier) and select a device with usable SMART output | +| Linux disk has no temperature | Device mapping, permissions, `smartctl -A -j`, JSON fields | Map every selected device and discover its actual host path. Nonzero smartctl health bits alone do not invalidate a usable temperature | +| Sleeping disk disappears | `LINUX_DISK_NOCHECK=standby` and power state | A sleeping disk may intentionally have no reading; choose always-available sources instead of treating missing data as zero | +| Local GPU missing | Driver, NVIDIA Container Toolkit, Compose `gpus: all`, `nvidia-smi` | Verify host/container GPU access, then diagnose | +| Remote GPU fails | Shared SSH identity, key permissions, port, noninteractive PATH | Every host must run the read-only `nvidia-smi` query from [source examples](TEMPERATURE_SOURCES.md). Inspect warnings for each host | +| SSH host keys fail or are repeatedly relearned | Known-hosts file inside ephemeral containers | Verify fingerprints through a trusted channel and mount known-hosts; avoid disabling verification to hide errors | +| Source passes despite failed device/VM | Warnings and sensor labels | Multi-target sources pass if any target succeeds. Repair every expected target; the hottest component may be missing | +| Decision ignores a reading | Raw value, integer parsing, filters, offsets | Raw values outside −20…150°C are rejected. GPU/disk offsets subtract and clamp at zero | +| All sources fail | Fail-safe settings and `status=failsafe` | Enabled fail-safe applies its configured duty; disabled fail-safe leaves previous fan state with no new cycle record. Restore while fixing sources | +| Healthy but readings fail | Cycle status and warnings | Fail-safe records keep freshness healthy. Health does not guarantee temperature safety or source completeness | +| Container unhealthy | Writable log mount, record time, interval/command duration | Repair the loop/source instead of only increasing freshness. Docker does not restart solely on unhealthy | +| Manual duty changes again | Another controller/container/process | Stop all writers before one-off tests or final restore | +| Duty remains after once/manual | No exit restoration trap for those commands | Explicitly restore; do not use those commands as restartable service mode | +| Stop does not restore | Foreground sleep/query, force-kill, lost IPMI | Explicitly stop and restore; verify in iDRAC instead of relying on the trap | +| Local build has no effect | Compose `image:` | Select `idrac-fan-control:local`; `make docker-build` does not change the deployed image | +| Edited settings have no effect | Running environment/image vs `.env` | Validate and diagnose, then `docker compose up -d --force-recreate`; restart does not reload environment | -Host 成功、容器失敗通常代表 `docker-compose.yml` 未加入 `/dev/nvme1:/dev/nvme1`。`LINUX_DISK_DEVICES` 必須是 `/dev/...` 逗號清單;控制器會拒絕空白、shell metacharacter、相對路徑,以及含 `.`、`..` 或空元件的路徑。smartctl 的非零狀態可能是 SMART health bitmask,因此只要 JSON 仍含有效溫度,控制器會保留該讀值;timeout、無效 JSON 或沒有溫度才使該 device 失敗。 +## Interpolation and hysteresis -## NVIDIA GPU 深入檢查 +`FAN_SPEED_INTERPOLATION=true` is default, including when omitted in old configs. Between low/medium/high/critical anchors it rounds upward, so the same logged level may have different duties. Below `TEMP_LOW`, idle remains separate; distinct idle/low speeds cause a jump at that boundary. At/above critical it clamps to the configured critical duty, which is not necessarily 100%. -```bash -nvidia-smi -docker run --rm --gpus all nvidia/cuda:12.9.0-runtime-ubuntu24.04 nvidia-smi -docker compose run --rm idrac-fan-control diagnose -``` - -第一個失敗代表主機驅動問題;第一個成功、第二個失敗通常是 Container Toolkit;兩者成功但 Compose 失敗則檢查 `docker-compose.yml` 的 `gpus: all`。不用 GPU 做控制時,最安全的修復是從 `TEMPERATURE_SOURCES` 移除 `gpu`,而不是把錯誤隱藏。 +Interpolation ignores `HYSTERESIS`. For the old staircase and downshift-only hysteresis, explicitly set `FAN_SPEED_INTERPOLATION=false`, validate, and recreate. `config` and `diagnose` show the mode and decision preview. -遠端 GPU 來源請從 controller host 或容器測試完全相同的命令: - -```bash -ssh -i /run/secrets/gpu_vms_ed25519 monitor@gpu-vm-1 \ - 'nvidia-smi --query-gpu=index,temperature.gpu --format=csv,noheader,nounits' -``` - -若互動式 SSH 成功但 controller 失敗,檢查 key 的容器內路徑、`REMOTE_GPU_USERNAME`、port 與 `SSH_STRICT_HOST_KEY_CHECKING`。遠端登入 shell 必須能在非互動 `PATH` 找到 `nvidia-smi`。 - -## Healthcheck 與 log - -auto mode 每次成功決策或套用 fail-safe 都會更新 `${LOG_DIR}/${LOG_FILE}`。預設允許的最大年齡為: - -```text -CHECK_INTERVAL * 3 + COMMAND_TIMEOUT -``` - -`HEALTHCHECK_MAX_AGE=0` 代表使用上述公式。只有在外部監控有明確 cadence 需求時才固定正整數;把值設得很大會掩蓋停止更新的控制迴圈。 - -檢查 host volume: +## Logs and health freshness ```bash ls -ld logs @@ -186,25 +63,12 @@ ls -l logs/fan_control.log docker inspect idrac-fan-control --format '{{json .Mounts}}' ``` -專案不自動 rotate log。可用 host logrotate,例如針對 repository 的 `logs/fan_control.log` 設定 weekly rotation;不要在 container 裡安裝 cron,因為 container 重建後不會保留。 - -## 收集 issue 資訊 - -請附上: - -- Server model 與 iDRAC major version(不要附 service tag)。 -- `config` 輸出。 -- `diagnose` 與最近 100 行 container log。 -- 使用的 `TEMPERATURE_SOURCES`。 -- 問題發生前的變更。 -- `make test` 結果。 - -請勿附上 `.env`、密碼、SSH private key、公開可達的管理 IP 或完整 service tag。 +Default freshness is `CHECK_INTERVAL*3 + COMMAND_TIMEOUT` seconds (200 with defaults). Collection across multiple targets can take longer than one command timeout. Size interval/freshness for measured collection time while keeping fault detection useful. Health uses file modification time; one-off processes or touched files can mask a stale main loop. Check timestamps and cycle status too. -## 插值模式與預期速度不同 +See [log retention](../USAGE_GUIDE.md#log-retention) and [upgrade/rollback](../USAGE_GUIDE.md#upgrade-and-rollback). -`FAN_SPEED_INTERPOLATION` 預設為 `true`,包括未設定此選項的舊 `.env`。先用 `config` 確認模式與四個錨點,再用唯讀 `diagnose` 檢查目前最高有效調整溫度對應的 duty;插值會向上取整,並忽略 `HYSTERESIS`。同一 level 中的 duty 也可能不同,日誌 level 僅表示溫度區間。 +## Reporting an issue -低於 `TEMP_LOW` 仍使用 idle,達到 `TEMP_LOW` 使用 low;兩者不同時會跳差,不會在兩者間另造溫度錨點。達到/超過 critical 固定使用 critical speed。若要保留舊階梯行為與只延遲降檔的遲滯,設 `FAN_SPEED_INTERPOLATION=false`,並在更新 `.env` 後重建容器。TUI 的 **Fan curve** 也可切換。診斷不會送出風扇控制命令。 +Include model and firmware, image tag/digest and code revision, selected sources, redacted config/diagnose, recent logs, the preceding change, and `make test` results if available. State whether evidence uses mocks or hardware. Exclude credentials, keys, service tags, and public management endpoints. -文件最後檢視:2026-11-01。 +Documentation last reviewed: November 11, 2026. From ba2ff452416ed133f5a05e9df52d39b8b400a4b4 Mon Sep 17 00:00:00 2001 From: Catalina Date: Wed, 11 Nov 2026 17:23:31 +0800 Subject: [PATCH 2/3] chore: configure CodeRabbit OSS reviews --- .coderabbit.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 9fb9074..658c7c5 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,7 +1,39 @@ # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json language: en-US +enable_free_tier: true +tone_instructions: >- + Use concise engineering English. Prioritize actionable correctness, security, + and regression findings with concrete evidence. Avoid style-only nitpicks, + praise, and repeated summaries. reviews: + profile: chill + auto_approvals: + enabled: false + high_level_summary: false + poem: false + in_progress_fortune: false + sequence_diagrams: false + suggested_labels: false + suggested_reviewers: false auto_review: enabled: true auto_incremental_review: true + auto_pause_after_reviewed_commits: 0 drafts: false + base_branches: + - ".*" + path_instructions: + - path: "src/**" + instructions: >- + Check Bash quoting, numeric and configuration validation, bounded external + commands, temperature aggregation, fan-curve boundaries, and fail-safe or + automatic-restoration regressions. Preserve TUI configuration round trips + and redaction. Do not suggest live hardware commands as verification. + - path: "docker-compose.yml" + instructions: >- + Check environment defaults, read-only secret mounts, device access and + persistent logs against the controller's runtime requirements. Preserve + explicit opt-in for optional temperature sources and hardware access. +chat: + auto_reply: false + art: false From 2f656cd1f6e5e9e7628021595c89672e3931fbe8 Mon Sep 17 00:00:00 2001 From: Catalina Date: Thu, 12 Nov 2026 02:38:20 +0800 Subject: [PATCH 3/3] chore(coderabbit): enable automatic review decisions --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 658c7c5..4d28202 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -8,7 +8,7 @@ tone_instructions: >- reviews: profile: chill auto_approvals: - enabled: false + enabled: true high_level_summary: false poem: false in_progress_fortune: false