Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
[ADDON-43496] retry on mongo error
Browse files Browse the repository at this point in the history
  • Loading branch information
okuzhel committed Oct 19, 2021
1 parent de7fbfe commit 71bdd89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion splunk_connect_for_snmp_mib_server/snmp_mib_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# ########################################################################
import argparse
import logging
import time

import yaml
from pymongo.errors import ServerSelectionTimeoutError

from splunk_connect_for_snmp_mib_server.mib_server import MibServer
from splunk_connect_for_snmp_mib_server.mongo import MibsRepository
Expand All @@ -30,7 +32,15 @@ def upload_mibs(server_config):
mibs_collection = MibsRepository(mibs_mongo_config)
# TODO do we need to clean up before loading
# Clean up
mibs_collection.clear()
try:
mibs_collection.clear()
except ServerSelectionTimeoutError:
logger.exception(
"Connection refused while trying to clean mongo db, retrying in 15 seconds"
)
time.sleep(15)
mibs_collection.clear()

# Upload all mib files in specific dir into mongo
mibs_collection.upload_files(mib_files_dir)
mibs_collection.create_text_index()
Expand Down

0 comments on commit 71bdd89

Please sign in to comment.