Skip to content

Commit

Permalink
Remove couch db code (#6848)
Browse files Browse the repository at this point in the history
* remove couchDb related code. Easy part for #6834

* remove CouchDB code from DagmanResubmitter. For #6845

* remove CouchDB code from PostJob. For #6845

* remove isCouchDBURL, now unused. For #6845

* one more cleanup in PostJob. For #6845

* one more cleanup in PostJob. For #6845

* restore code deleted by mistake
  • Loading branch information
belforte authored Oct 30, 2021
1 parent cef2ad9 commit f47285b
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 407 deletions.
6 changes: 0 additions & 6 deletions src/python/ServerUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ def getTestDataDirectory():
testdirList = __file__.split(os.sep)[:-3] + ["test", "data"]
return os.sep.join(testdirList)

def isCouchDBURL(url):
""" Return True if the url proviced is a couchdb one
"""
return 'couchdb' in url


def truncateError(msg):
"""Truncate the error message to the first 7400 chars if needed, and add a message if we truncate it.
See https://github.com/dmwm/CRABServer/pull/4867#commitcomment-12086393
Expand Down
60 changes: 1 addition & 59 deletions src/python/TaskWorker/Actions/DagmanResubmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import HTCondorLocator
import HTCondorUtils

from WMCore.Database.CMSCouch import CouchServer

from ServerUtilities import FEEDBACKMAIL
from TaskWorker.Actions.TaskAction import TaskAction
from TaskWorker.Actions.DagmanSubmitter import checkMemoryWalltime
Expand Down Expand Up @@ -43,27 +41,9 @@ def executeInternal(self, *args, **kwargs): #pylint: disable=unused-argument
raise ValueError("No proxy provided")
proxy = task['user_proxy']

if task.get('resubmit_publication', False):
resubmitWhat = "publications"
else:
resubmitWhat = "jobs"

self.logger.info("About to resubmit %s for workflow: %s.", resubmitWhat, workflow)
self.logger.info("About to resubmit failed jobs for workflow: %s.", workflow)
self.logger.debug("Task info: %s", str(task))

if task.get('resubmit_publication', False):
asourl = task.get('tm_asourl', None)
#Let's not assume the db has been updated (mostly for devs), let's default asodb to asynctransfer!
#Also the "or" takes care of the case were the new code is executed on old task
#i.e.: tm_asodb is there but empty.
asodb = task.get('tm_asodb', 'asynctransfer') or 'asynctransfer'
if not asourl:
msg = "ASO URL not set. Can not resubmit publication."
raise TaskWorkerException(msg)
self.logger.info("Will resubmit failed publications")
self.resubmitPublication(asourl, asodb, proxy, workflow)
return

if task['tm_collector']:
self.backendurls['htcondorPool'] = task['tm_collector']
loc = HTCondorLocator.HTCondorLocator(self.backendurls)
Expand Down Expand Up @@ -197,44 +177,6 @@ def execute(self, *args, **kwargs):
raise TaskWorkerException(msg)
return Result.Result(task=kwargs['task'], result='OK')


def resubmitPublication(self, asourl, asodb, proxy, taskname):
"""
Resubmit failed publications by resetting the publication
status in the CouchDB documents.
"""
server = CouchServer(dburl=asourl, ckey=proxy, cert=proxy)
try:
database = server.connectDatabase(asodb)
except Exception as ex:
msg = "Error while trying to connect to CouchDB: %s" % (str(ex))
raise TaskWorkerException(msg)
try:
failedPublications = database.loadView('DBSPublisher', 'PublicationFailedByWorkflow',\
{'reduce': False, 'startkey': [taskname], 'endkey': [taskname, {}]})['rows']
except Exception as ex:
msg = "Error while trying to load view 'DBSPublisher.PublicationFailedByWorkflow' from CouchDB: %s" % (str(ex))
raise TaskWorkerException(msg)
msg = "There are %d failed publications to resubmit: %s" % (len(failedPublications), failedPublications)
self.logger.info(msg)
for doc in failedPublications:
docid = doc['id']
if doc['key'][0] != taskname: # this should never happen...
msg = "Skipping document %s as it seems to correspond to another task: %s" % (docid, doc['key'][0])
self.logger.warning(msg)
continue
data = {'last_update': time.time(),
'retry': str(datetime.datetime.now()),
'publication_state': 'not_published',
}
try:
database.updateDocument(docid, 'DBSPublisher', 'updateFile', data)
except Exception as ex:
msg = "Error updating document %s in CouchDB: %s" % (docid, str(ex))
self.logger.error(msg)
return


if __name__ == "__main__":
import os
import logging
Expand Down
Loading

0 comments on commit f47285b

Please sign in to comment.