Skip to content

Conversation

bennyyang11
Copy link

@bennyyang11 bennyyang11 commented Sep 17, 2025

Description, Motivation and Context

This PR adds a complete cron job scheduler for automated support bundle collection. This feature enables customers to schedule support bundle collection to run automatically at specified times using standard cron syntax, eliminating the need for manual collection and ensuring consistent diagnostic data gathering.

Key Features:

  • CLI Commands: support-bundle schedule create/list/delete/daemon for complete job management
  • Real-time Daemon: Background process that monitors and executes scheduled jobs with graceful shutdown
  • Cron Syntax Support: Full cron expression support including */N intervals (every N minutes/hours)
  • Kubernetes Integration: Native K8s cluster support with auto-discovery and namespace targeting
  • Production Ready: Comprehensive error handling, signal management, and job statistics tracking

Problem Solved:

  • Manual support bundle collection is time-consuming and often forgotten
  • Critical issues may occur outside business hours when manual collection isn't feasible
  • Proactive diagnostic data collection improves support response times
  • Automated collection ensures consistent data gathering for trend analysis

New CLI Commands

This PR introduces the following new CLI commands under the schedule subcommand:

Job Management

# Create a scheduled job
support-bundle schedule create <job-name> --cron "<schedule>" --namespace <namespace> [--auto] -- upload enabled 

# Examples:
support-bundle schedule create daily-check --cron "0 2 * * *" --namespace production
support-bundle schedule create frequent --cron "*/30 * * * *" --namespace app --auto --upload enabled

# List all scheduled jobs
support-bundle schedule list

# Delete a scheduled job  
support-bundle schedule delete <job-name>

Daemon Control

# Start the scheduler daemon (runs jobs automatically)
support-bundle schedule daemon start

Command Examples with Output

$ support-bundle schedule create daily-backup --cron "0 2 * * *" --namespace production --auto --upload enabled
✓ Created scheduled job 'daily-backup' (ID: job-1234567890)
  Schedule: 0 2 * * *
  Namespace: production
  Auto-discovery: enabled
  Auto-upload: enabled

$ support-bundle schedule list
NAME           SCHEDULE    NAMESPACE    AUTO   AUTO-UPLOAD   RUNS
daily-backup   0 2 * * *   production.  true   enabled   0
hourly-check   0 * * * *   kube-system  false   none   1

$ support-bundle schedule daemon start
✓ Scheduler daemon started
Monitoring scheduled jobs every minute...
🔄 Executing job: daily-backup  
✅ Job completed: daily-backup

Implementation Details:

  • 589 lines of clean, well-tested code across 4 core files
  • File-based job persistence with JSON storage
  • 30-second execution cooldown prevents duplicate runs
  • Comprehensive unit test coverage (4/4 tests passing)
  • Successfully tested with real K3s cluster showing full functionality

Checklist

  • New and existing tests pass locally with introduced changes.
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • Yes
  • No

Note: This is a purely additive feature that doesn't modify existing functionality. All existing CLI commands and APIs remain unchanged.

NoaheCampbell and others added 6 commits September 9, 2025 12:53
Bumps [sigstore/cosign-installer](https://github.com/sigstore/cosign-installer) from 3.9.2 to 3.10.0.
- [Release notes](https://github.com/sigstore/cosign-installer/releases)
- [Commits](sigstore/cosign-installer@v3.9.2...v3.10.0)

---
updated-dependencies:
- dependency-name: sigstore/cosign-installer
  dependency-version: 3.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the security group with 2 updates: [github.com/vmware-tanzu/velero](https://github.com/vmware-tanzu/velero) and [helm.sh/helm/v3](https://github.com/helm/helm).


Updates `github.com/vmware-tanzu/velero` from 1.16.2 to 1.17.0
- [Release notes](https://github.com/vmware-tanzu/velero/releases)
- [Changelog](https://github.com/vmware-tanzu/velero/blob/main/CHANGELOG.md)
- [Commits](vmware-tanzu/velero@v1.16.2...v1.17.0)

Updates `helm.sh/helm/v3` from 3.18.6 to 3.19.0
- [Release notes](https://github.com/helm/helm/releases)
- [Commits](helm/helm@v3.18.6...v3.19.0)

---
updated-dependencies:
- dependency-name: github.com/vmware-tanzu/velero
  dependency-version: 1.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: helm.sh/helm/v3
  dependency-version: 3.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…sdk/helm-template in the security group (#1859)

chore(deps): bump helm.sh/helm/v3

Bumps the security group in /examples/sdk/helm-template with 1 update: [helm.sh/helm/v3](https://github.com/helm/helm).


Updates `helm.sh/helm/v3` from 3.18.6 to 3.19.0
- [Release notes](https://github.com/helm/helm/releases)
- [Commits](helm/helm@v3.18.6...v3.19.0)

---
updated-dependencies:
- dependency-name: helm.sh/helm/v3
  dependency-version: 3.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Complete implementation with K8s integration:
- pkg/schedule/job.go: Job management and persistence
- pkg/schedule/daemon.go: Real-time scheduler daemon
- pkg/schedule/cli.go: CLI commands (create, list, delete, daemon)
- pkg/schedule/schedule_test.go: Comprehensive unit tests
- cmd/troubleshoot/cli/root.go: CLI integration
cursor[bot]

This comment was marked as outdated.

…mote-tracking branch 'origin/main' into cron-job-clean

   Merge main branch to resolve conflicts before PR
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@NoaheCampbell NoaheCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there are some mentions of upload functionality, but there doesnt seem to be any way to actually upload the results, and we could also just use the auto upload functionality that exists to upload it to vendor portal so the user doesn't have to specify where to upload it

@bennyyang11 bennyyang11 added the type::feature New feature or request label Sep 17, 2025
bennyyang11 and others added 4 commits September 17, 2025 14:22
…bleshoot into cron-job-clean

Merge auto-upload functionality with documentation updates

- Integrates PR #1860 auto-upload feature with scheduler
- Updates documentation to reflect new --auto-upload integration
- Removes references to specific developers in markdown files
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@NoaheCampbell NoaheCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

NoaheCampbell and others added 3 commits September 17, 2025 17:34
Resolves merge conflict in auto-update logic:
- Use v1beta3 version of auto-update (fmt.Fprintf to stderr)
- Preserves all cron job scheduling functionality
- Maintains CLI schedule commands (create, list, delete, daemon)

All schedule package functionality retained and integrated with v1beta3 changes
- Ensure autoFromEnv variable and its usage are in correct scope
- Fix build errors: declared and not used / undefined variable
- All functionality preserved and tested locally
- Force add to override gitignore
@bennyyang11 bennyyang11 merged commit 83e6cff into v1beta3 Sep 30, 2025
9 checks passed
@bennyyang11 bennyyang11 deleted the cron-job-clean branch September 30, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants