Skip to content

TypeError: 'NoneType' object is not subscriptable when attempting to start two sharded clusters on the same ports #314

@ShaneHarvey

Description

@ShaneHarvey

We’re seeing test runs where mongo-orchestration sends this back to the client in an HTTP 500 response:

Traceback (most recent call last):
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/apps/__init__.py", line 66, in wrap
    return f(*arg, **kwd)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/apps/sharded_clusters.py", line 147, in sh_create_by_id
    result = _sh_create(data)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/apps/sharded_clusters.py", line 44, in _sh_create
    cluster_id = ShardedClusters().create(params)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 533, in create
    cluster = ShardedCluster(params)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 103, in __init__
    f.result()
  File "/opt/mongodbtoolchain/revisions/69f4f0673ffcb290ce2307560a4883ecf2ad138c/stow/python3-v4.hzp/lib/python3.10/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/opt/mongodbtoolchain/revisions/69f4f0673ffcb290ce2307560a4883ecf2ad138c/stow/python3-v4.hzp/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/opt/mongodbtoolchain/revisions/69f4f0673ffcb290ce2307560a4883ecf2ad138c/stow/python3-v4.hzp/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 96, in add_shard
    info = self.member_add(cfg.get('id', None), shard_params)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 400, in member_add
    result = self._add(cfgs, member_id)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 377, in _add
    return self.router_command("addShard", (shard_uri, {"name": name}), is_eval=False)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 366, in router_command
    result = getattr(self.connection().admin, mode)(command, name, **d)
  File "/data/mci/09d9293805bba164c02aa32f53e57a72/src/github.com/10gen/mongosync/venv/lib/python3.10/site-packages/mongo_orchestration/sharded_clusters.py", line 334, in connection
    return self.create_connection(self.router['hostname'])
TypeError: 'NoneType' object is not subscriptable

This happens when attempting to start two sharded clusters on the same ports, or more exactly, when starting a mongos on port X but something else is already running on port X, most likely another mongo server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions