Scheduled support bundles
Scheduled support bundles turn recurring diagnostic collection into managed jobs. An operator defines when a collection should run and which normal support-bundle options it should use. A long-running daemon watches those jobs and starts the standard support-bundle workflow when their schedules are due.
Capability model
The scheduled-support-bundle capability separates the job definition from job execution. The definition holds the schedule and collection choices. The daemon supplies the execution service that applies those choices over time.
| Concern | System role |
|---|---|
| Schedule | A five-field cron expression selects the collection time. |
| Collection target | An optional Kubernetes namespace limits the target. |
| Collector choice | Auto-discovery can request a foundational set of collectors without a supplied specification. |
| Delivery | Automatic upload can send the resulting bundle to the vendor portal. |
| Run state | The job records whether it is enabled and keeps successful run count and last-run time. |
The scheduled path does not define a second diagnostic format. It passes job choices to the existing support-bundle command, so scheduled and manual collections use the same collection and delivery behavior. See support-bundle workflows for the one-shot bundle process.
Managed collection lifecycle
The lifecycle starts with a saved job and ends with a recorded result. The schedule command manages the definition, while the daemon owns time checks and execution.
flowchart LR
Operator[Operator] --> Define[Define scheduled job]
Define --> Store[(Saved job state)]
Operator --> Start[Start scheduler daemon]
Start --> Watch[Watch due jobs]
Watch --> Store
Watch -->|Schedule is due| Run[Run support-bundle workflow]
Run --> Bundle[Create diagnostic bundle]
Bundle --> Delivery[Optional upload]
Run -->|Successful run| Store
Operator --> Inspect[Inspect or remove job]
Inspect --> Store
Scheduler command integration
The scheduler is exposed under the main support-bundle command as support-bundle schedule. Its commands create, list, and delete job definitions. The daemon start command activates execution, so creating a job alone does not start background collection. See scheduler command integration for the operator-facing command flow.
References: cmd/…/root.go• L108-115 cmd/…/schedule.go• L8-10 pkg/…/cli.go• L11-29 pkg/…/cli.go• L32-88
Daemon lifecycle
The daemon is a long-running process that checks saved jobs once per minute. It stops when it receives an interrupt or termination signal. Each due job starts in the background, and the daemon prevents another run of that same job while the first run is active. See daemon lifecycle and job lifecycle for the detailed lifecycle.
References: pkg/…/daemon.go• L17-25 pkg/…/daemon.go• L62-95 pkg/…/daemon.go• L103-130
Job orchestration
Job orchestration connects a saved schedule to one support-bundle process. The daemon checks that all cron fields match the current time, applies a short duplicate-run guard, and then maps the job's namespace, auto-discovery, and upload choices to the normal command. A successful command updates the job's run state. A failed command remains eligible for a later attempt. See job orchestration for the full sequence and support-bundle execution for the option mapping.
References: pkg/…/job.go• L13-25 pkg/…/job.go• L47-88 pkg/…/daemon.go• L132-205 pkg/…/daemon.go• L231-326
Collection and delivery boundary
The scheduled system supplies timing and a small set of run options. The regular support-bundle command remains responsible for loading collection rules, collecting and analyzing evidence, creating the archive, and performing an optional automatic upload.
When auto-discovery is enabled without a supplied specification, the normal command creates a minimal support-bundle specification and fills it with discovered foundational collectors. When upload is enabled, the normal command attempts delivery after bundle creation. A delivery error does not remove the local archive, which remains available for manual upload.
The boundary keeps scheduled collection aligned with changes to the normal support-bundle workflow. It also means that a scheduled job depends on access to the same support-bundle executable and the same cluster or host resources as a manual run.
References: cmd/…/run.go• L390-432 cmd/…/run.go• L263-281 pkg/…/daemon.go• L246-287
Runtime state
Job definitions persist in the user's Troubleshoot data area. The daemon uses that shared state to discover jobs created by the CLI, while its scheduler log records starts, successes, archive details, and errors.
The runtime state gives operators two separate views. The job list shows durable schedule and success history. The daemon output and log show what happened during execution, including failures that do not increase the successful run count.
References: pkg/…/job.go• L27-45 pkg/…/job.go• L91-157 pkg/…/daemon.go• L34-59 pkg/…/daemon.go• L328-341
Change checklist
When these files or sections are changed, remember to consider these:
- Keep scheduler flags, saved job fields, and the daemon's command mapping aligned. A new option must survive the full path from job creation to bundle execution.
- Keep schedule validation compatible with schedule matching. A schedule accepted by the CLI must have the same meaning when the daemon checks the clock.
- Keep successful-run state updates after the support-bundle command succeeds. Earlier updates can hide failed runs and suppress useful retries.
- Keep the daemon's support-bundle executable lookup aligned with the packaged command name and deployment layout.
- Keep the shared local state location stable across job creation, inspection, removal, and daemon startup so existing jobs remain visible.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The daemon is not running | Saved jobs do not execute. | Run support-bundle schedule daemon start in a process with the required uptime. |
| The support-bundle executable is not available | A due job fails before collection and its success state does not change. | Place the executable beside the daemon or on PATH. |
| A saved schedule is invalid or cannot be parsed | The daemon skips the job. | Create jobs through the scheduler command and keep saved job records valid. |
| Collection exits with an error | The daemon logs the failure and does not increase the successful run count. | Inspect the daemon output or log, then correct the collection cause. |
| Automatic upload fails | The bundle stays local and the daemon reports the upload error. | Use the logged archive path with the normal upload command. |
| A job is due while its earlier run is active | The daemon skips the overlapping start. | Allow the active collection to finish before the next eligible run. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/cli.go | Shows the scheduler commands that create, inspect, remove, and activate recurring jobs. |
| pkg/…/job.go | Defines the durable job contract and the shared job state operations. |
| pkg/…/daemon.go | Shows the time check, run guard, support-bundle launch, state update, and logging flow. |
| cmd/…/root.go | Shows how scheduling joins the main support-bundle command. |
| cmd/…/run.go | Shows the normal collection, auto-discovery, and upload behavior used by scheduled runs. |
| .greptile-internal/…/schedule-daemon-and-jobs.md | Provides the detailed child page for scheduler commands, daemon lifecycle, and job orchestration. |