You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rebase changes onto latest main after PR #2832 consolidation
Applied TTL cache fetching and downtime checking to the new consolidated
runDirectorTestCycle structure from PR #2832. Key changes:
- Modified LaunchPeriodicDirectorTest to accept URL string parameter
- Fetch fresh ServerAd from TTL cache on each test cycle
- Check downtime status using isServerInDowntime() before running tests
- Stop test suite when ServerAd is no longer in cache
- Integrated with new runDirectorTestCycle helper function structure
This maintains the original PR goals while working with the improved
code structure from the consolidation in PR #2832.
Co-authored-by: h2zh <[email protected]>
log.Infof("The Director doesn't have any advertisements for server with URL %s. Stopping director tests.", serverUrlStr)
187
+
returnfalse
188
+
}
189
+
currentServerAd:=adItem.Value().ServerAd
190
+
191
+
// Check if the server is in downtime by checking the filteredServers map
192
+
ifisServerInDowntime(currentServerAd.Name) {
193
+
log.Debugf("Skipping director test cycle for %s server %s: server is in downtime", currentServerAd.Type, currentServerAd.Name)
194
+
returntrue// Return true to continue the loop, but don't run the test
195
+
}
196
+
197
+
log.Debug(fmt.Sprintf("Starting a director test cycle for %s server %s at %s", currentServerAd.Type, currentServerAd.Name, currentServerAd.URL.String()))
// Compose the result of this Director-test to report to the server
208
+
varreportStatus, reportMessagestring// status (result of the Director-test) and message to report back to the server
209
+
varhealthStatusHealthTestStatus
210
+
iftestSucceeded&&testErr==nil {
211
+
reportStatus="ok"
212
+
reportMessage="Director test cycle succeeded at "+time.Now().Format(time.RFC3339)
213
+
healthStatus=HealthStatusOK
214
+
log.Debugf("Director file transfer test cycle succeeded at %s for %s server with URL at %s", time.Now().Format(time.RFC3339), currentServerAd.Type, currentServerAd.URL.String())
215
+
} else {
216
+
reportStatus="error"
217
+
reportMessage="Director file transfer test cycle failed for server: "+currentServerAd.URL.String()
218
+
iftestErr!=nil {
219
+
reportMessage+=" "+testErr.Error()
220
+
}
221
+
healthStatus=HealthStatusError
222
+
log.Warningln("Director file transfer test cycle failed for ", currentServerAd.Type, " server: ", currentServerAd.URL.String(), " ", testErr)
223
+
}
224
+
225
+
// Update healthTestUtils once per cycle
226
+
func() {
227
+
healthTestUtilsMutex.Lock()
228
+
deferhealthTestUtilsMutex.Unlock()
229
+
ifexistingUtil, ok:=healthTestUtils[currentServerAd.URL.String()]; ok {
230
+
existingUtil.Status=healthStatus
231
+
} else {
232
+
log.Debugln("HealthTestUtil missing for ", currentServerAd.Type, " server: ", currentServerAd.URL.String(), " Failed to update internal status")
233
+
}
234
+
}()
235
+
236
+
// Determine the metric status label based on test result
237
+
testStatusMetric:=metrics.MetricSucceeded
238
+
if!testSucceeded||testErr!=nil {
239
+
testStatusMetric=metrics.MetricFailed
240
+
}
241
+
242
+
// Report the result of this Director-test back to origin/server (single call)
log.Debugf("Director file transfer test cycle succeeded at %s for %s server with URL at %s", time.Now().Format(time.RFC3339), serverAd.Type, serverAd.URL.String())
224
-
func() {
225
-
healthTestUtilsMutex.Lock()
226
-
deferhealthTestUtilsMutex.Unlock()
227
-
ifexistingUtil, ok:=healthTestUtils[serverAd.URL.String()]; ok {
228
-
existingUtil.Status=HealthStatusOK
229
-
} else {
230
-
log.Debugln("HealthTestUtil missing for ", serverAd.Type, " server: ", serverAd.URL.String(), " Failed to update internal status")
231
-
}
232
-
}()
233
-
234
-
// Report error back to origin/server
235
-
iferr:=reportStatusToServer(
236
-
ctx,
237
-
serverAd.WebURL.String(),
238
-
"ok", "Director test cycle succeeded at "+time.Now().Format(time.RFC3339),
239
-
serverAd.Type,
240
-
false,
241
-
); err!=nil {
242
-
// origin <7.7 only supports legacy report endpoint. Fallback to the legacy one
243
-
iferr==originReportNotFoundError {
244
-
newErr:=reportStatusToServer(
245
-
ctx,
246
-
serverAd.WebURL.String(),
247
-
"ok", "Director test cycle succeeded at "+time.Now().Format(time.RFC3339),
248
-
serverAd.Type,
249
-
true, // Fallback to legacy endpoint
250
-
)
251
-
// If legacy endpoint still reports error
252
-
ifnewErr!=nil {
253
-
log.Warningf("Failed to report director test result to %s server at %s: %v", serverAd.Type, serverAd.WebURL.String(), err)
0 commit comments