@@ -83,14 +83,6 @@ func checkForUpgrades(ctx context.Context, url, versionString string, backoff wa
83
83
isOpenShift bool ) (message string , header string , err error ) {
84
84
var headerPayloadStruct * clientUpgradeData
85
85
86
- // Guard against panics within the checkForUpgrades function to allow the
87
- // checkForUpgradesScheduler to reschedule a check
88
- defer func () {
89
- if panicErr := recover (); panicErr != nil {
90
- err = fmt .Errorf ("%s" , panicErr )
91
- }
92
- }()
93
-
94
86
// Prep request
95
87
req , err := http .NewRequest ("GET" , url , nil )
96
88
if err == nil {
@@ -151,13 +143,6 @@ func CheckForUpgradesScheduler(ctx context.Context,
151
143
cacheClient CacheWithWait ,
152
144
) {
153
145
log := logging .FromContext (ctx )
154
- defer func () {
155
- if err := recover (); err != nil {
156
- log .V (1 ).Info ("encountered panic in upgrade check" ,
157
- "response" , err ,
158
- )
159
- }
160
- }()
161
146
162
147
if url == "" {
163
148
url = upgradeCheckURL
@@ -174,30 +159,38 @@ func CheckForUpgradesScheduler(ctx context.Context,
174
159
return
175
160
}
176
161
177
- info , header , err := checkForUpgrades (ctx , url , versionString , backoff ,
178
- crclient , cfg , isOpenShift )
179
- if err != nil {
180
- log .V (1 ).Info ("could not complete upgrade check" ,
181
- "response" , err .Error ())
182
- } else {
183
- log .Info (info , clientHeader , header )
184
- }
162
+ check (ctx , versionString , url , crclient , cfg , isOpenShift )
185
163
186
164
ticker := time .NewTicker (upgradeCheckPeriod )
187
165
for {
188
166
select {
189
167
case <- ticker .C :
190
- info , header , err = checkForUpgrades (ctx , url , versionString , backoff ,
191
- crclient , cfg , isOpenShift )
192
- if err != nil {
193
- log .V (1 ).Info ("could not complete scheduled upgrade check" ,
194
- "response" , err .Error ())
195
- } else {
196
- log .Info (info , clientHeader , header )
197
- }
168
+ check (ctx , versionString , url , crclient , cfg , isOpenShift )
198
169
case <- ctx .Done ():
199
170
ticker .Stop ()
200
171
return
201
172
}
202
173
}
203
174
}
175
+
176
+ func check (ctx context.Context ,
177
+ versionString , url string , crclient crclient.Client ,
178
+ cfg * rest.Config , isOpenShift bool ,
179
+ ) {
180
+ log := logging .FromContext (ctx )
181
+
182
+ defer func () {
183
+ if v := recover (); v != nil {
184
+ log .V (1 ).Info ("encountered panic in upgrade check" , "response" , v )
185
+ }
186
+ }()
187
+
188
+ info , header , err := checkForUpgrades (ctx ,
189
+ url , versionString , backoff , crclient , cfg , isOpenShift )
190
+
191
+ if err != nil {
192
+ log .V (1 ).Info ("could not complete upgrade check" , "response" , err .Error ())
193
+ } else {
194
+ log .Info (info , clientHeader , header )
195
+ }
196
+ }
0 commit comments