openmsk

MO-error500

Sep 15th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 20.90 KB | None | 0 0
  1. [root@noc noc]# ./noc fix  apply fix_platform_full_name
  2. 2017-09-15 15:15:42,114 [noc.core.dcs.base] Resolve near service postgres
  3. 2017-09-15 15:15:42,119 [noc.core.dcs.base] Resolved near service postgres to ['10.0.4.111:5432']
  4. 2017-09-15 15:15:42,346 [noc.core.dcs.base] Running resolver for service mongo
  5. 2017-09-15 15:15:42,348 [noc.core.dcs.base] [mongo] Starting resolver
  6. 2017-09-15 15:15:42,351 [noc.core.dcs.base] [mongo] Set active services to: mongo: 10.0.4.111:27017
  7. 2017-09-15 15:15:42,352 [noc.lib.nosql] Connecting to MongoDB {'username': 'noc', 'authentication_source': 'noc', 'readPreference': 'secondaryPreferred', 'replicaSet': 'noc', 'db': 'noc', 'socketKeepAlive': True, 'host': 'mongodb://noc:noc@10.0.4.111:27017/noc', 'password': '********'}
  8. Apply fix_platform_full_name ...
  9. 2017-09-15 15:15:42,569 [noc.core.debug] UNHANDLED EXCEPTION (2017-09-15 15:15:42.413897)
  10. BRANCH: feature/microservices TIP: 8b63c103d656
  11. PROCESS: ./commands/fix.py
  12. ERROR FINGERPRINT: 1f089e0c-1de6-5ddc-a713-c2cd2f12d097
  13. WORKING DIRECTORY: /opt/noc
  14. EXCEPTION: <class 'pymongo.errors.DuplicateKeyError'> E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }
  15. START OF TRACEBACK
  16. ------------------------------------------------------------------------
  17. File: lib/python2.7/site-packages/pymongo/helpers.py (Line: 203)
  18. Function: _check_command_response
  19.   196                                            details.get("assertionCode"),
  20.   197                                            response)
  21.   198    
  22.   199                 # Other errors
  23.   200                 code = details.get("code")
  24.   201                 # findAndModify with upsert can raise duplicate key error
  25.   202                 if code in (11000, 11001, 12582):
  26.   203 ==>                 raise DuplicateKeyError(errmsg, code, response)
  27.   204                 elif code == 50:
  28.   205                     raise ExecutionTimeout(errmsg, code, response)
  29.   206                 elif code == 43:
  30.   207                     raise CursorNotFound(errmsg, code, response)
  31.   208    
  32.   209                 msg = msg or "%s"
  33. Variables:
  34. parse_write_concern_error = True
  35.                 code = 11000
  36.     allowable_errors = None
  37.              details =
  38. {u'code': 11000,
  39.  u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
  40.  u'ok': 0.0}
  41.                  msg = None
  42.             response =
  43. {u'code': 11000,
  44.  u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
  45.  u'ok': 0.0}
  46.               errmsg =
  47. u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }'
  48. ------------------------------------------------------------------------
  49. File: lib/python2.7/site-packages/pymongo/network.py (Line: 116)
  50. Function: command
  51.   109             unpacked = helpers._unpack_response(
  52.   110                 response, codec_options=codec_options)
  53.   111    
  54.   112             response_doc = unpacked['data'][0]
  55.   113             if check:
  56.   114                 helpers._check_command_response(
  57.   115                     response_doc, None, allowable_errors,
  58.   116 ==>                 parse_write_concern_error=parse_write_concern_error)
  59.   117         except Exception as exc:
  60.   118             if publish:
  61.   119                 duration = (datetime.datetime.now() - start) + encoding_duration
  62.   120                 if isinstance(exc, (NotMasterError, OperationFailure)):
  63.   121                     failure = exc.details
  64.   122                 else:
  65. Variables:
  66.                 size = 138
  67.        max_bson_size = 16777216
  68.        codec_options =
  69. CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
  70.                check = True
  71.                 orig =
  72. SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
  73. parse_write_concern_error = True
  74.     allowable_errors = None
  75.                 sock = <socket._socketobject object at 0x2f7ede0>
  76.              publish = False
  77.                 name = 'createIndexes'
  78.         read_concern = ReadConcern()
  79.      read_preference = Primary()
  80.                  msg =
  81. '\xaf\x00\x00\x00\xecXUb\x00\x00\x00\x00\xd4\x07\x00\x00\x00\x00\x00\x00noc.$cmd\x00\x00\x00\x00\x00\xff\xff\xff\xff\x8a\x00\x00\x00\x02createIndexes\x00\x0e\x00\x00\x00noc.platforms\x00\x04indexes\x00[\x00\x00\x00\x030\x00S\x00\x00\x00\x08unique\x00\x01\x08background\x00\x00\x08sparse\x00\x00\x03key\x00\x14\x00\x00\x00\x10full_name\x00\x01\x00\x00\x00\x00\x02name\x00\x0c\x00\x00\x00full_name_1\x00\x00\x00\x00'
  82.                   ns = u'noc.$cmd'
  83.            is_mongos = False
  84.               dbname = u'noc'
  85.         response_doc =
  86. {u'code': 11000,
  87.  u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
  88.  u'ok': 0.0}
  89.             slave_ok = False
  90.              address = (u'noc', 27017)
  91.            collation = None
  92.             response =
  93. '\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x87\x00\x00\x00\x01ok\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02errmsg\x00`\x00\x00\x00E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }\x00\x10code\x00\xf8*\x00\x00\x00'
  94.           check_keys = False
  95.                  exc =
  96. DuplicateKeyError(u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',)
  97.             unpacked =
  98. {'cursor_id': 0,
  99.  'data': [{u'code': 11000,
  100.            u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
  101.            u'ok': 0.0}],
  102.  'number_returned': 1,
  103.  'starting_from': 0}
  104.                 spec =
  105. SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
  106.            listeners = <pymongo.monitoring._EventListeners object at 0x2fd5110>
  107.                flags = 0
  108.           request_id = 1649760492
  109. ------------------------------------------------------------------------
  110. File: lib/python2.7/site-packages/pymongo/pool.py (Line: 477)
  111. Function: command
  112.   470             try:
  113.   471                 return command(self.sock, dbname, spec, slave_ok,
  114.   472                                self.is_mongos, read_preference, codec_options,
  115.   473                                check, allowable_errors, self.address,
  116.   474                                check_keys, self.listeners, self.max_bson_size,
  117.   475                                read_concern,
  118.   476                                parse_write_concern_error=parse_write_concern_error,
  119.   477 ==>                            collation=collation)
  120.   478             except OperationFailure:
  121.   479                 raise
  122.   480             # Catch socket.error, KeyboardInterrupt, etc. and close ourselves.
  123.   481             except BaseException as error:
  124.   482                 self._raise_connection_failure(error)
  125.   483    
  126. Variables:
  127. parse_write_concern_error = True
  128.           check_keys = False
  129.     allowable_errors = None
  130.                 self = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
  131.        codec_options =
  132. CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
  133.               dbname = u'noc'
  134.                 spec =
  135. SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
  136.         read_concern = ReadConcern()
  137.             slave_ok = False
  138.        write_concern = WriteConcern()
  139.      read_preference = Primary()
  140.            collation = None
  141.                check = True
  142. ------------------------------------------------------------------------
  143. File: lib/python2.7/site-packages/pymongo/collection.py (Line: 232)
  144. Function: _command
  145.   225                 read_preference or self.read_preference,
  146.   226                 codec_options or self.codec_options,
  147.   227                 check,
  148.   228                 allowable_errors,
  149.   229                 read_concern=read_concern,
  150.   230                 write_concern=write_concern,
  151.   231                 parse_write_concern_error=parse_write_concern_error,
  152.   232 ==>             collation=collation)
  153.   233    
  154.   234         def __create(self, options, collation):
  155.   235             """Sends a create command with the given options.
  156.  236             """
  157.   237             cmd = SON([("create", self.__name)])
  158.   238             if options:
  159. Variables:
  160. parse_write_concern_error = True
  161.     allowable_errors = None
  162.                 self =
  163. Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
  164.        codec_options =
  165. CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
  166.         read_concern = ReadConcern()
  167.             slave_ok = False
  168.              command =
  169. SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
  170.        write_concern = WriteConcern()
  171.      read_preference = Primary()
  172.            collation = None
  173.                check = True
  174.            sock_info = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
  175. ------------------------------------------------------------------------
  176. File: lib/python2.7/site-packages/pymongo/collection.py (Line: 1472)
  177. Function: __create_index
  178.  1465                         index['collation'] = collation
  179.  1466                 cmd = SON([('createIndexes', self.name), ('indexes', [index])])
  180.  1467                 try:
  181.  1468                     self._command(
  182.  1469                         sock_info, cmd, read_preference=ReadPreference.PRIMARY,
  183.  1470                         codec_options=_UNICODE_REPLACE_CODEC_OPTIONS,
  184.  1471                         write_concern=self.write_concern,
  185.  1472 ==>                     parse_write_concern_error=True)
  186.  1473                 except OperationFailure as exc:
  187.  1474                     if exc.code in common.COMMAND_NOT_FOUND_CODES:
  188.  1475                         index["ns"] = self.__full_name
  189.  1476                         wcn = (self.write_concern if
  190.  1477                                self.write_concern.acknowledged else WriteConcern())
  191.  1478                         self.__database.system.indexes._insert(
  192. Variables:
  193.                index =
  194. {'background': False,
  195.  'key': SON([('full_name', 1)]),
  196.  'name': u'full_name_1',
  197.  'sparse': False,
  198.  'unique': True}
  199.            index_doc = SON([('full_name', 1)])
  200.                  exc =
  201. DuplicateKeyError(u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',)
  202.        index_options =
  203. {'background': False, 'name': u'full_name_1', 'sparse': False, 'unique': True}
  204.                 keys = [('full_name', 1)]
  205.                 self =
  206. Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
  207.                  cmd =
  208. SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
  209.            collation = None
  210.            sock_info = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
  211. ------------------------------------------------------------------------
  212. File: lib/python2.7/site-packages/pymongo/collection.py (Line: 1571)
  213. Function: create_index
  214.  1564                 :meth:`create_index` no longer caches index names. Removed support
  215.  1565                 for the drop_dups and bucket_size aliases.
  216.  1566    
  217.  1567             .. mongodoc:: indexes
  218.  1568             """
  219. 1569             keys = helpers._index_list(keys)
  220. 1570             name = kwargs.setdefault("name", helpers._gen_index_name(keys))
  221. 1571 ==>         self.__create_index(keys, kwargs)
  222. 1572             return name
  223. 1573    
  224. 1574         def ensure_index(self, key_or_list, cache_for=300, **kwargs):
  225. 1575             """**DEPRECATED** - Ensures that an index exists on this collection.
  226.  1576    
  227.  1577             .. versionchanged:: 3.0
  228. Variables:
  229.                 keys = [('full_name', 1)]
  230.                 self =
  231. Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
  232.                 name = u'full_name_1'
  233.               kwargs =
  234. {'background': False, 'name': u'full_name_1', 'sparse': False, 'unique': True}
  235. ------------------------------------------------------------------------
  236. File: lib/python2.7/site-packages/mongoengine/document.py (Line: 836)
  237. Function: ensure_indexes
  238.   829    
  239.   830                     # we shouldn't pass 'cls' to the collection.ensureIndex options
  240.   831                     # because of https://jira.mongodb.org/browse/SERVER-769
  241.   832                     if 'cls' in opts:
  242.   833                         del opts['cls']
  243.   834    
  244.   835                     if IS_PYMONGO_3:
  245.   836 ==>                     collection.create_index(fields, background=background, **opts)
  246.   837                     else:
  247.   838                         collection.ensure_index(fields, background=background,
  248.   839                                                 drop_dups=drop_dups, **opts)
  249.   840    
  250.   841             # If _cls is being used (for polymorphism), it needs an index,
  251.   842             # only if another index doesn't begin with _cls
  252. Variables:
  253.           index_spec =
  254. [{'fields': [('vendor', 1), ('name', 1)], 'unique': True},
  255.  {'fields': [('full_name', 1)], 'sparse': False, 'unique': True}]
  256.               fields = [('full_name', 1)]
  257.           collection =
  258. Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
  259.            drop_dups = False
  260.           background = False
  261.          cls_indexed = False
  262.                  cls = <class 'noc.inv.models.platform.Platform'>
  263.            index_cls = True
  264.                 spec = {'unique': True, 'sparse': False}
  265.                 opts = {'unique': True, 'sparse': False}
  266.           index_opts = {}
  267. ------------------------------------------------------------------------
  268. File: lib/python2.7/site-packages/mongoengine/document.py (Line: 206)
  269. Function: _get_collection
  270.   199                             opts['max'] = max_documents
  271.   200                         cls._collection = db.create_collection(
  272.   201                             collection_name, **opts
  273.   202                         )
  274.   203                 else:
  275.   204                     cls._collection = db[collection_name]
  276.   205                 if cls._meta.get('auto_create_index', True):
  277.   206 ==>                 cls.ensure_indexes()
  278.   207             return cls._collection
  279.   208    
  280.   209         def to_mongo(self, *args, **kwargs):
  281.   210             data = super(Document, self).to_mongo(*args, **kwargs)
  282.   211    
  283.   212             # If '_id' is None, try and set it from self._data. If that
  284. Variables:
  285.      collection_name = 'noc.platforms'
  286.                   db =
  287. Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc')
  288.                  cls = <class 'noc.inv.models.platform.Platform'>
  289. ------------------------------------------------------------------------
  290. File: lib/python2.7/site-packages/mongoengine/queryset/manager.py (Line: 37)
  291. Function: __get__
  292.    30             """
  293.   31             if instance is not None:
  294.   32                 # Document object being used rather than a document class
  295.   33                 return self
  296.   34    
  297.   35             # owner is the document that contains the QuerySetManager
  298.   36             queryset_class = owner._meta.get('queryset_class', self.default)
  299.   37 ==>         queryset = queryset_class(owner, owner._get_collection())
  300.   38             if self.get_queryset:
  301.   39                 arg_count = self.get_queryset.func_code.co_argcount
  302.   40                 if arg_count == 1:
  303.   41                     queryset = self.get_queryset(queryset)
  304.   42                 elif arg_count == 2:
  305.   43                     queryset = self.get_queryset(owner, queryset)
  306. Variables:
  307.               owner = <class 'noc.inv.models.platform.Platform'>
  308.            instance = None
  309.                self = <mongoengine.queryset.manager.QuerySetManager object at 0x2ffa350>
  310.      queryset_class = <class 'mongoengine.queryset.queryset.QuerySet'>
  311. ------------------------------------------------------------------------
  312. File: fixes/fix_platform_full_name.py (Line: 14)
  313. Function: fix
  314.    7     # ----------------------------------------------------------------------
  315.    8    
  316.    9     # NOC modules
  317.   10     from noc.inv.models.platform import Platform
  318.   11    
  319.   12    
  320.   13     def fix():
  321.   14 ==>     for p in Platform.objects.all():
  322.   15             p.save()
  323. Variables:
  324. ------------------------------------------------------------------------
  325. File: commands/fix.py (Line: 74)
  326. Function: handle_apply
  327.   67                 return
  328.   68             import noc.lib.nosql  # Connect to mongo
  329.   69             for f in fixes:
  330.   70                 fix = self.get_fix(f)
  331.   71                 if not fix:
  332.   72                     self.die("Invalid fix '%s'" % f)
  333.   73                 print("Apply %s ..." % f, file=self.stdout)
  334.   74 ==>             fix()
  335.   75                 print("... done", file=self.stdout)
  336.   76    
  337.   77    
  338.   78     if __name__ == "__main__":
  339.   79         Command().run()
  340. Variables:
  341.                   f = 'fix_platform_full_name'
  342.                 fix = <function fix at 0x2ff9758>
  343.                args = ()
  344.               fixes = ['fix_platform_full_name']
  345.                 noc = <module 'noc' from '/opt/noc/__init__.pyc'>
  346.                self = <__main__.Command object at 0x7f5cd95c7ed0>
  347.             options = {}
  348. ------------------------------------------------------------------------
  349. File: commands/fix.py (Line: 34)
  350. Function: handle
  351.   27             apply_parser.add_argument(
  352.   28                 "fixes",
  353.   29                 nargs=argparse.REMAINDER,
  354.   30                 help="Apply named fixes"
  355.   31             )
  356.   32    
  357.   33         def handle(self, cmd, *args, **options):
  358.   34 ==>         return getattr(self, "handle_%s" % cmd)(*args, **options)
  359.   35    
  360.   36         def handle_list(self, *args, **options):
  361.   37             fixes = set()
  362.   38             for d in self.FIX_DIRS:
  363.   39                 if not os.path.isdir(d):
  364.   40                     continue
  365. Variables:
  366.                 cmd = 'apply'
  367.                self = <__main__.Command object at 0x7f5cd95c7ed0>
  368.                args = ()
  369.             options = {'fixes': ['fix_platform_full_name']}
  370. ------------------------------------------------------------------------
  371. File: core/management/base.py (Line: 75)
  372. Function: run_from_argv
  373.   68             enable_profiling = cmd_options.pop("enable_profiling", False)
  374.   69             show_metrics = cmd_options.pop("show_metrics", False)
  375.   70             if enable_profiling:
  376.   71                 # Start profiler
  377.   72                 import yappi
  378.   73                 yappi.start()
  379.   74             try:
  380.   75 ==>             return self.handle(*args, **cmd_options) or 0
  381.   76             except CommandError as e:
  382.   77                 self.print(str(e))
  383.   78                 return 1
  384.   79             except KeyboardInterrupt:
  385.   80                 self.print("Ctrl+C")
  386.   81                 return 3
  387. Variables:
  388.              parser =
  389. ArgumentParser(prog='fix.py', usage=None, description=None, version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
  390.            loglevel = 'info'
  391.    enable_profiling = False
  392.                args = ()
  393.         cmd_options = {'cmd': 'apply', 'fixes': ['fix_platform_full_name']}
  394.                argv = ['apply', 'fix_platform_full_name']
  395.                self = <__main__.Command object at 0x7f5cd95c7ed0>
  396.        show_metrics = False
  397.             options = Namespace(cmd='apply', fixes=['fix_platform_full_name'])
  398. ------------------------------------------------------------------------
  399. END OF TRACEBACK
Add Comment
Please, Sign In to add comment