@@ -13,6 +13,7 @@ import (
13
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
14
coreinformersv1 "k8s.io/client-go/informers/core/v1"
15
15
coreclientv1 "k8s.io/client-go/kubernetes/typed/core/v1"
16
+ "k8s.io/client-go/util/retry"
16
17
"k8s.io/klog/v2"
17
18
18
19
// openshift
@@ -150,32 +151,45 @@ func (c *HealthCheckController) Sync(ctx context.Context, controllerContext fact
150
151
}
151
152
152
153
func (c * HealthCheckController ) CheckRouteHealth (ctx context.Context , operatorConfig * operatorsv1.Console , route * routev1.Route ) (string , error ) {
153
- url , _ , err := routeapihelpers .IngressURI (route , route .Spec .Host )
154
- if err != nil {
155
- return "RouteNotAdmitted" , fmt .Errorf ("console route is not admitted" )
156
- }
157
-
158
- caPool , err := c .getCA (ctx , route .Spec .TLS )
159
- if err != nil {
160
- return "FailedLoadCA" , fmt .Errorf ("failed to read CA to check route health: %v" , err )
161
- }
162
- client := clientWithCA (caPool )
163
-
164
- req , err := http .NewRequest (http .MethodGet , url .String (), nil )
165
- if err != nil {
166
- return "FailedRequest" , fmt .Errorf ("failed to build request to route (%s): %v" , url , err )
167
- }
168
- resp , err := client .Do (req )
169
- if err != nil {
170
- return "FailedGet" , fmt .Errorf ("failed to GET route (%s): %v" , url , err )
171
- }
172
- defer resp .Body .Close ()
173
-
174
- if resp .StatusCode != http .StatusOK {
175
- return "StatusError" , fmt .Errorf ("route not yet available, %s returns '%s'" , url , resp .Status )
176
- }
177
-
178
- return "" , nil
154
+ var reason string
155
+ err := retry .OnError (
156
+ retry .DefaultRetry ,
157
+ func (err error ) bool { return err != nil },
158
+ func () error {
159
+ url , _ , err := routeapihelpers .IngressURI (route , route .Spec .Host )
160
+ if err != nil {
161
+ reason = "RouteNotAdmitted"
162
+ return fmt .Errorf ("console route is not admitted" )
163
+ }
164
+
165
+ caPool , err := c .getCA (ctx , route .Spec .TLS )
166
+ if err != nil {
167
+ reason = "FailedLoadCA"
168
+ return fmt .Errorf ("failed to read CA to check route health: %v" , err )
169
+ }
170
+ client := clientWithCA (caPool )
171
+
172
+ req , err := http .NewRequest (http .MethodGet , url .String (), nil )
173
+ if err != nil {
174
+ reason = "FailedRequest"
175
+ return fmt .Errorf ("failed to build request to route (%s): %v" , url , err )
176
+ }
177
+ resp , err := client .Do (req )
178
+ if err != nil {
179
+ reason = "FailedGet"
180
+ return fmt .Errorf ("failed to GET route (%s): %v" , url , err )
181
+ }
182
+ defer resp .Body .Close ()
183
+
184
+ if resp .StatusCode != http .StatusOK {
185
+ reason = "StatusError"
186
+ return fmt .Errorf ("route not yet available, %s returns '%s'" , url , resp .Status )
187
+ }
188
+ reason = ""
189
+ return nil
190
+ },
191
+ )
192
+ return reason , err
179
193
}
180
194
181
195
func (c * HealthCheckController ) getCA (ctx context.Context , tls * routev1.TLSConfig ) (* x509.CertPool , error ) {
0 commit comments