From cd52a0eef337fb75c56cf5d35925033c368b9f27 Mon Sep 17 00:00:00 2001
From: Stefan Prodan <stefan.prodan@gmail.com>
Date: Fri, 22 Oct 2021 09:57:54 +0300
Subject: [PATCH] Add poll interval flag to flux check cmd

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
---
 cmd/flux/check.go                         | 5 ++++-
 cmd/flux/install.go                       | 2 +-
 internal/bootstrap/bootstrap_plain_git.go | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmd/flux/check.go b/cmd/flux/check.go
index d613312f..dbfc4059 100644
--- a/cmd/flux/check.go
+++ b/cmd/flux/check.go
@@ -51,6 +51,7 @@ type checkFlags struct {
 	pre             bool
 	components      []string
 	extraComponents []string
+	pollInterval    time.Duration
 }
 
 var kubernetesConstraints = []string{
@@ -69,6 +70,8 @@ func init() {
 		"list of components, accepts comma-separated values")
 	checkCmd.Flags().StringSliceVar(&checkArgs.extraComponents, "components-extra", nil,
 		"list of components in addition to those supplied or defaulted, accepts comma-separated values")
+	checkCmd.Flags().DurationVar(&checkArgs.pollInterval, "poll-interval", 5*time.Second,
+		"how often the health checker should poll the cluster for the latest state of the resources.")
 	rootCmd.AddCommand(checkCmd)
 }
 
@@ -177,7 +180,7 @@ func componentsCheck() bool {
 		return false
 	}
 
-	statusChecker, err := status.NewStatusChecker(kubeConfig, time.Second, rootArgs.timeout, logger)
+	statusChecker, err := status.NewStatusChecker(kubeConfig, checkArgs.pollInterval, rootArgs.timeout, logger)
 	if err != nil {
 		return false
 	}
diff --git a/cmd/flux/install.go b/cmd/flux/install.go
index cd6c8ccb..206d9952 100644
--- a/cmd/flux/install.go
+++ b/cmd/flux/install.go
@@ -206,7 +206,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
 	if err != nil {
 		return fmt.Errorf("install failed: %w", err)
 	}
-	statusChecker, err := status.NewStatusChecker(kubeConfig, time.Second, rootArgs.timeout, logger)
+	statusChecker, err := status.NewStatusChecker(kubeConfig, 5*time.Second, rootArgs.timeout, logger)
 	if err != nil {
 		return fmt.Errorf("install failed: %w", err)
 	}
diff --git a/internal/bootstrap/bootstrap_plain_git.go b/internal/bootstrap/bootstrap_plain_git.go
index ed7e09a5..160594a1 100644
--- a/internal/bootstrap/bootstrap_plain_git.go
+++ b/internal/bootstrap/bootstrap_plain_git.go
@@ -347,7 +347,7 @@ func (b *PlainGitBootstrapper) ReportComponentsHealth(ctx context.Context, insta
 		return err
 	}
 
-	checker, err := status.NewStatusChecker(cfg, 2*time.Second, timeout, b.logger)
+	checker, err := status.NewStatusChecker(cfg, 5*time.Second, timeout, b.logger)
 	if err != nil {
 		return err
 	}
-- 
GitLab