add trackLogsInterval option (#2825)

* add trackLogsInterval option

Signed-off-by: pznamensky <kompastver@gmail.com>

* test: add coverage for trackLogsInterval option

The trackLogsInterval feature shipped without tests. Add coverage for:

- config getter: zero when --track-logs-interval is not supplied, explicit
  value (including an explicit default) when supplied, and the nil-Cmd
  fallback for non-cobra callers (pkg/config/apply_test.go, sync_test.go)
- buildReleaseTracker resolution: explicit CLI interval overrides the
  release setting, release setting used when the flag is absent, 10s
  default preserved when both are unset (pkg/state/helmx_test.go)
- release-level minimum validation in ExecuteTemplates: below/zero/
  negative rejected, 1s and above accepted (pkg/state/state_exec_tmpl_test.go)

Also add the missing blank line after syncImpl.Cmd in cmd/sync.go for
consistency with cmd/apply.go.

Signed-off-by: yxxhero <aiopsclub@163.com>

---------

Signed-off-by: pznamensky <kompastver@gmail.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
pznamensky
2026-10-10 14:13:10 +08:00
committed by GitHub
co-authored by yxxhero
parent 3216c02743
commit 12fb6887c0
14 changed files with 266 additions and 12 deletions
+2 -1
View File
@@ -34,12 +34,13 @@ helmfile apply --track-mode kubedog --track-timeout 300 --track-logs --track-log
- **`trackMode`**: Set to `kubedog` to enable kubedog tracking, or `helm-legacy` to use Helm v4's legacy wait mode (default: `helm`)
- **`trackTimeout`**: Timeout in seconds for tracking resources (default: 300)
- **`trackLogs`**: Print logs from tracked resources during deployment
- **`trackLogsInterval`**: Interval between log output updates, as a duration such as `1s` or `30s` (default: `10s`; minimum: `1s`)
- **`trackLogsUntilReady`**: With `trackLogs: true`, stop routine pod logs once each pod first becomes ready (default: false)
- **`trackFailedLogs`**: Print collected logs only for pods that fail during deployment
To see logs only for failed pods, set `trackFailedLogs: true` on a release or use `--track-failed-logs` with `helmfile apply` or `helmfile sync`. If both log options are enabled, logs from all tracked pods are printed.
With kubedog tracking and either log option enabled, `helmfile apply` and `helmfile sync` print collected logs every 10 seconds by default. Use `--track-logs-interval` to change this interval (for example, `1s` above). The minimum is `1s`. Deployment progress is checked for changes every 10 seconds.
With kubedog tracking and either `trackLogs` or `trackFailedLogs` enabled, `helmfile apply` and `helmfile sync` print collected logs every 10 seconds by default. Set `trackLogsInterval` on a release or use `--track-logs-interval` to change this interval (for example, `1s` above). An explicitly supplied command-line flag overrides the release setting; otherwise, the release setting takes precedence over the `10s` default. The minimum is `1s`. Deployment progress is checked for changes every 10 seconds.
### Startup-Only Pod Logs
+2 -1
View File
@@ -514,7 +514,8 @@ See [Advanced Features](advanced-features.md#resource-tracking-with-kubedog) for
|-------|------|---------|-------------|
| `trackMode` | string | `""` | Track mode: `helm`, `helm-legacy`, or `kubedog` |
| `trackTimeout` | int | 300 | Tracking timeout in seconds |
| `trackLogs` | bool | false | Print logs from tracked resources during deployment (every 10 seconds by default; see [`--track-logs-interval`](advanced-features.md#resource-tracking-with-kubedog)) |
| `trackLogs` | bool | false | Print logs from tracked resources during deployment |
| `trackLogsInterval` | duration | `10s` | Interval between log output updates for `trackLogs` or `trackFailedLogs` (e.g. `1s`; minimum `1s`); overrides the default, but an explicitly supplied `--track-logs-interval` takes precedence |
| `trackLogsUntilReady` | bool | false | With `trackLogs: true`, stop routine pod logs once each pod first becomes ready; readiness and failure tracking continue. Job logs are unaffected |
| `trackFailedLogs` | bool | false | Print collected logs only for pods that fail during deployment; overridden by `trackLogs` |
| `trackKinds` | list | | Whitelist of resource kinds to track |