mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
* created roadmap and yaml claude agent * Update roadmap.md * chore(deps): bump sigstore/cosign-installer from 3.9.2 to 3.10.0 (#1857) 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](https://github.com/sigstore/cosign-installer/compare/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] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump the security group with 2 updates (#1858) 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](https://github.com/vmware-tanzu/velero/compare/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](https://github.com/helm/helm/compare/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] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump helm.sh/helm/v3 from 3.18.6 to 3.19.0 in /examples/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](https://github.com/helm/helm/compare/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] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add cron job support bundle scheduler 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 * fixing bugbot * Fix all bugbot errors: auto-update stability, job cooldown timing, and daemon execution * Deleting Agent * removed unused flags * fixing auto-upload * fixing markdown files * namespace not required flag for auto collectors to work * loosened cron job validation * writes logs to logfile * fix: resolve autoFromEnv variable scoping issue for CI - 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 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Noah Campbell <noah.edward.campbell@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
173 lines
4.3 KiB
Go
173 lines
4.3 KiB
Go
package schedule
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"text/tabwriter"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// CLI creates the schedule command
|
|
func CLI() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "schedule",
|
|
Short: "Manage scheduled support bundle jobs",
|
|
Long: `Create and manage scheduled support bundle collection jobs.
|
|
|
|
This allows customers to schedule support bundle collection to run automatically
|
|
at specified times using standard cron syntax.`,
|
|
}
|
|
|
|
cmd.AddCommand(
|
|
createCommand(),
|
|
listCommand(),
|
|
deleteCommand(),
|
|
daemonCommand(),
|
|
)
|
|
|
|
return cmd
|
|
}
|
|
|
|
// createCommand creates the create subcommand
|
|
func createCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "create [job-name] --cron [schedule] [--namespace ns]",
|
|
Short: "Create a scheduled support bundle job",
|
|
Long: `Create a new scheduled job to automatically collect support bundles.
|
|
|
|
Examples:
|
|
# Daily at 2 AM
|
|
support-bundle schedule create daily-check --cron "0 2 * * *" --namespace production
|
|
|
|
# Every 6 hours with auto-discovery and auto-upload to vendor portal
|
|
support-bundle schedule create frequent --cron "0 */6 * * *" --namespace app --auto --upload enabled`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cronSchedule, _ := cmd.Flags().GetString("cron")
|
|
namespace, _ := cmd.Flags().GetString("namespace")
|
|
auto, _ := cmd.Flags().GetBool("auto")
|
|
upload, _ := cmd.Flags().GetString("upload")
|
|
|
|
if cronSchedule == "" {
|
|
return fmt.Errorf("--cron is required")
|
|
}
|
|
|
|
manager, err := NewManager()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
job, err := manager.CreateJob(args[0], cronSchedule, namespace, auto, upload)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("✓ Created scheduled job '%s' (ID: %s)\n", job.Name, job.ID)
|
|
fmt.Printf(" Schedule: %s\n", job.Schedule)
|
|
fmt.Printf(" Namespace: %s\n", job.Namespace)
|
|
if auto {
|
|
fmt.Printf(" Auto-discovery: enabled\n")
|
|
}
|
|
if upload != "" {
|
|
fmt.Printf(" Auto-upload: enabled (uploads to vendor portal)\n")
|
|
}
|
|
|
|
fmt.Printf("\n💡 To activate, start the daemon:\n")
|
|
fmt.Printf(" support-bundle schedule daemon start\n")
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
cmd.Flags().StringP("cron", "c", "", "Cron expression (required)")
|
|
cmd.Flags().StringP("namespace", "n", "", "Kubernetes namespace (optional)")
|
|
cmd.Flags().Bool("auto", false, "Enable auto-discovery")
|
|
cmd.Flags().String("upload", "", "Enable auto-upload to vendor portal (any non-empty value enables auto-upload)")
|
|
cmd.MarkFlagRequired("cron")
|
|
|
|
return cmd
|
|
}
|
|
|
|
// listCommand creates the list subcommand
|
|
func listCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all scheduled jobs",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
manager, err := NewManager()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
jobs, err := manager.ListJobs()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(jobs) == 0 {
|
|
fmt.Println("No scheduled jobs found")
|
|
return nil
|
|
}
|
|
|
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
|
fmt.Fprintln(w, "NAME\tSCHEDULE\tNAMESPACE\tAUTO\tAUTO-UPLOAD\tRUNS")
|
|
|
|
for _, job := range jobs {
|
|
upload := "none"
|
|
if job.Upload != "" {
|
|
upload = "enabled"
|
|
}
|
|
fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\t%d\n",
|
|
job.Name, job.Schedule, job.Namespace, job.Auto, upload, job.RunCount)
|
|
}
|
|
|
|
return w.Flush()
|
|
},
|
|
}
|
|
}
|
|
|
|
// deleteCommand creates the delete subcommand
|
|
func deleteCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "delete [job-name]",
|
|
Short: "Delete a scheduled job",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
manager, err := NewManager()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := manager.DeleteJob(args[0]); err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("✓ Deleted job: %s\n", args[0])
|
|
return nil
|
|
},
|
|
}
|
|
}
|
|
|
|
// daemonCommand creates the daemon subcommand
|
|
func daemonCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "daemon",
|
|
Short: "Manage scheduler daemon",
|
|
}
|
|
|
|
start := &cobra.Command{
|
|
Use: "start",
|
|
Short: "Start the scheduler daemon",
|
|
Long: "Start the daemon to automatically execute scheduled jobs",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
daemon, err := NewDaemon()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return daemon.Start()
|
|
},
|
|
}
|
|
|
|
cmd.AddCommand(start)
|
|
return cmd
|
|
}
|