@@ -6,10 +6,10 @@ package cmd
66import (
77 "context"
88 "log"
9+ "os"
910 "strconv"
1011 "time"
1112
12- "github.com/gobuffalo/envy"
1313 osconfigv1 "github.com/openshift/api/config/v1"
1414 "github.com/spf13/cobra"
1515 "k8s.io/apimachinery/pkg/runtime"
@@ -34,6 +34,7 @@ Progrssing status is not true.'`,
3434var (
3535 kclient * kubernetes.Clientset
3636 oclient ctrlrtc.Client
37+ timeout int
3738)
3839
3940func init () {
@@ -56,17 +57,20 @@ func checkhealthPreRun(cmd *cobra.Command, args []string) {
5657 if err != nil {
5758 log .Fatalf ("Error getting OpenShift config client: %s" , err )
5859 }
60+
61+ if val , found := os .LookupEnv ("OPERATOR_HEALTH_TIMEOUT" ); found {
62+ timeout , err = strconv .Atoi (val )
63+ if err != nil {
64+ log .Fatalf ("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s" , err )
65+ }
66+ } else {
67+ timeout = 10
68+ }
5969}
6070
6171func checkhealthRun (cmd * cobra.Command , args []string ) {
6272 checkreadyz ()
6373
64- oht := envy .Get ("OPERATOR_HEALTH_TIMEOUT" , "10" )
65- timeout , err := strconv .Atoi (oht )
66- if err != nil {
67- log .Fatalf ("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s" , err )
68- }
69-
7074 for i := 0 ; i < timeout ; i ++ {
7175 var cvok bool
7276 cook := checkclusteroperators ()
@@ -84,11 +88,6 @@ func checkhealthRun(cmd *cobra.Command, args []string) {
8488
8589func checkreadyz () {
8690 var readyz []byte
87- oht := envy .Get ("OPERATOR_HEALTH_TIMEOUT" , "10" )
88- timeout , err := strconv .Atoi (oht )
89- if err != nil {
90- log .Fatalf ("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s" , err )
91- }
9291
9392 for i := 0 ; i < timeout ; i ++ {
9493 // TODO: do we want to catch this error or ignore it? Ignoring for now
@@ -126,14 +125,8 @@ func checkclusterversion() bool {
126125}
127126
128127func checkclusteroperators () bool {
129- oht := envy .Get ("OPERATOR_HEALTH_TIMEOUT" , "10" )
130- _ , err := strconv .Atoi (oht )
131- if err != nil {
132- log .Fatalf ("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s" , err )
133- }
134-
135128 col := osconfigv1.ClusterOperatorList {}
136- err = oclient .List (context .Background (), & col )
129+ err : = oclient .List (context .Background (), & col )
137130 if err != nil {
138131 log .Fatalf ("Unable to list cluster operators: %v" , err )
139132 }
0 commit comments