forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloseRunningOpen.py
51 lines (44 loc) · 1.62 KB
/
closeRunningOpen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""c
_closeRunningOpen_
Use it when many requests are stuck in running-open probably because of problems
in the GQ.
Created on Jul 9, 2013
@author: dballest
"""
import sys
from WMCore.Database.CMSCouch import Database
from WMCore.WorkQueue.WorkQueueBackend import WorkQueueBackend
def getProblematicRequests():
"""
_getProblematicRequests_
"""
badWorkflows = []
backend = WorkQueueBackend('https://cmsweb.cern.ch/couchdb')
workflowsToCheck = backend.getInboxElements(OpenForNewData = True)
for element in workflowsToCheck:
childrenElements = backend.getElementsForParent(element)
if not len(childrenElements):
badWorkflows.append(element)
return badWorkflows
def main():
print "Looking for problematic inbox elements..."
problemRequests = getProblematicRequests()
print "Found %d bad elements:" % len(problemRequests)
if not problemRequests:
print "Nothing to fix, contact a developer if the problem persists..."
return 0
for request in problemRequests:
print request["RequestName"]
var = raw_input("Can we delete these inbox elements: Y/N\n")
if var == "Y":
print "Deleting them from the global inbox, you need a WMAgent proxy for this."
inboxDB = Database('workqueue_inbox', 'https://cmsweb.cern.ch/couchdb')
for request in problemRequests:
inboxDB.delete_doc(request._id, request.rev)
print "Done with the deletions, this should fix the problem."
return 0
else:
print "Doing nothing as you commanded..."
return 0
if __name__ == "__main__":
sys.exit(main())