Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions synda/sdt/sdinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def run(args, metadata=None):
sdlog.info("SYNDINST-006", "Exception occured during installation ('{}')".format(e))
raise

if 'status' in metadata.store.__dict__ and metadata.store.status=='incomplete':
print_stderr("WARNING: The file search failed part way through. Proceeding with what was found.")
sdlog.warning("SYNDINST-008","Installing from incomplete search results.")
# in dry-run mode, we stop here
if args.dry_run:
return 0, 0
Expand Down
7 changes: 6 additions & 1 deletion synda/sdt/sdmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import sqlite3
import contextlib
import shutil
from synda.sdt import sddbpagination
from synda.sdt import sdconfig
# from synda.sdt import sddbpagination
# sddbpagination is imported in DatabaseStorage.get_chunks_PAGINATION, to prevent circular imports.

from synda.source.config.path.tree.models import Config as TreePath
from synda.source.config.file.internal.models import Config as Internal
Expand Down Expand Up @@ -106,6 +107,7 @@ def __init__(self,dbfile=None):

self.connect()
self.create_table()
self.status = 'ok'
else:
# this case is only to duplicate the object (see copy method)

Expand Down Expand Up @@ -201,6 +203,7 @@ def get_chunks_GENERATOR(self):
yield li

def get_chunks_PAGINATION(self):
from synda.sdt import sddbpagination
dbpagination=sddbpagination.DBPagination('bla','foo',self.conn)
dbpagination.reset()

Expand Down Expand Up @@ -268,6 +271,8 @@ def copy(self):

# create new instance
cpy=DatabaseStorage(dbfile=dbfile_cpy)
if 'status' in self.__dict__:
cpy.status = self.status

# re-open ori connection
self.connect()
Expand Down
26 changes: 21 additions & 5 deletions synda/sdt/sdproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from synda.sdt import sdurlutils

from synda.source.config.file.user.preferences.models import Config as Preferences

from synda.source.config.process.constants import NEVER_RAISE_EXCEPTION

# not a singleton
class SearchAPIProxy():
Expand Down Expand Up @@ -68,11 +68,15 @@ def call_web_service(self,request):

# if exception occurs in sdnetutils.call_web_service() method, all
# previous calls to this method inside this paginated call are also
# cancelled
# cancelled (unless call_web_service__RETRY is the calling method)

# (original)
# we reset the offset so the paginated call can be restarted from the begining the next time
# (maybe overkill as offset is reinitialized when entering 'call_web_service__PAGINATION()' func)
request.offset=0
# JFP: In fact, if call_web_service__RETRY is being used, then resetting request.offset here will
# cause the wrong offset to be used on the next try. It is better to give the paginator exclusive
# rights to change the offset.
#request.offset=0

raise

Expand All @@ -91,7 +95,8 @@ def call_web_service__RETRY(self,request):
probability for a failure inside one pagination call is big (because one
pagination call is composed of many sub calls (i.e. not just 2 or 3)).
"""
max_retry=3
# original max_retry=3
max_retry=6

i=0
while True:
Expand Down Expand Up @@ -133,7 +138,18 @@ def call_web_service__PAGINATION(self,request):

# call
if sdconfig.mono_host_retry:
response=self.call_web_service__RETRY(request)
try:
response=self.call_web_service__RETRY(request)
except:
if NEVER_RAISE_EXCEPTION:
# Despite retrying, we couldn't get a response from the index node.
# Return the partial response that we already have, but mark it with an
# "incomplete" flag.
sdlog.debug('SYDPROXY-120', 'Network error, giving up with what we have' )
paginated_response.store.status = 'incomplete'
return paginated_response
else:
raise
else:
response=self.call_web_service(request)

Expand Down
5 changes: 5 additions & 0 deletions synda/source/config/process/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# as list maybe duplicated in memory at some point in the pipeline, we use a lower value here than SEARCH_API_CHUNKSIZE
CHUNKSIZE = 5000

# NEVER_RAISE_EXCEPTION=False means that a paginated search should follow the older behavior where
# an exception will kill the search. If True, partial information will be returned, with a status
# flag changed for use elsewhere in the code.
NEVER_RAISE_EXCEPTION = False

FETCH_MODE_GENERATOR = 'generator'

ADMIN_SUBCOMMANDS = ['autoremove', 'install', 'open', 'pexec', 'remove', 'reset', 'retry', 'update', 'upgrade']