Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lofar_stager_api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
lofar_stager_api
Commits
100b0833
Commit
100b0833
authored
4 years ago
by
Thomas Juerges
Browse files
Options
Downloads
Patches
Plain Diff
Add function that tries to query for hanging requests only
parent
98bb1131
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stager_access.py
+26
-0
26 additions, 0 deletions
stager_access.py
with
26 additions
and
0 deletions
stager_access.py
+
26
−
0
View file @
100b0833
...
...
@@ -186,6 +186,32 @@ def get_progress(status=None, exclude=False, only_last24h=False):
requests
=
all_requests
return
requests
def
get_stuck_requests
(
min_retries
=
3
,
days_without_activity
=
30
):
try
:
p
=
proxy
.
LtaStager
.
getprogress
(
True
,
0
)
except
xmlrpclib
.
Error
as
e
:
raise
Exception
(
remove_credentials_from_exception
(
e
))
stuck
=
{}
for
request_id
,
request_stats
in
p
.
items
():
if
request_stats
[
'
Status
'
]
!=
'
aborted
'
and
int
(
request_stats
[
'
Retries
'
])
>=
min_retries
:
pending
=
get_surls_pending
(
int
(
request_id
))
request_stats
[
'
Pending surls
'
]
=
pending
token
=
get_srm_token
(
int
(
request_id
))
request_stats
[
'
SRM token
'
]
=
token
if
days_without_activity
is
None
or
'
Latest success
'
not
in
request_stats
.
keys
():
request_stats
[
'
Pending since
'
]
=
"
Cannot be determined
"
stuck
[
request_id
]
=
request_stats
else
:
dt
=
datetime
.
datetime
.
strptime
(
request_stats
[
'
Latest success
'
],
'
%Y-%m-%d %H:%M:%S.%f
'
)
if
datetime
.
datetime
.
now
()
-
dt
>
datetime
.
timedelta
(
hours
=
24
*
days_without_activity
):
request_stats
[
'
Pending since
'
]
=
dt
stuck
[
request_id
]
=
request_stats
if
stuck
:
prettyprint
(
stuck
)
else
:
print
(
'
Nothing found, all running requests are OK.
'
)
def
reschedule_on_status
(
status
=
None
):
"""
Reschedule requests that have a status
"
on hold
"
or
"
aborted
"
.
:param status: The status that a request has to have in order to be
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment