Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-2645] POC Add shards to cluster #260

Merged
merged 51 commits into from
Oct 5, 2023
Merged

[DPE-2645] POC Add shards to cluster #260

merged 51 commits into from
Oct 5, 2023

Conversation

MiaAltieri
Copy link
Contributor

Issue

Shards are not currently added to cluster

Solution

Add shards to cluster.

Limitations

This does limit the number of shards added to a cluster at a given time. This should be done by checking the Primary shard, and basing the number of shards added on the number of secondaries in the Primary shard. There is no MongoDB Command to retrieve the primary shard, but there is a mongosh one. This can be implemented, but might be tricky. This should be saved for a future epic.

Testing

As a POC there are not tests included in this PR. Testing was performed by hand by hand:

[direct: mongos] admin> sh.status()
shardingVersion
{ _id: 1, clusterId: ObjectId("65152d236139b01f40f20c7d") }
---
shards
[
  {
    _id: 'shard-one',
    host: 'shard-one/10.61.64.125:27017',
    state: 1,
    topologyTime: Timestamp({ t: 1695886769, i: 4 })
  }
]
---
active mongoses
[ { '6.0.6-5': 1 } ]
---
autosplit
{ 'Currently enabled': 'yes' }
---
balancer
{
  'Currently running': 'no',
  'Currently enabled': 'yes',
  'Failed balancer rounds in last 5 attempts': 0,
  'Migration Results for the last 24 hours': 'No recent migrations'
}
---
databases
[
  {
    database: { _id: 'config', primary: 'config', partitioned: true },
    collections: {
      'config.system.sessions': {
        shardKey: { _id: 1 },
        unique: false,
        balancing: true,
        chunkMetadata: [ { shard: 'shard-one', nChunks: 1024 } ],
        chunks: [
          'too many chunks to print, use verbose if you want to force print'
        ],
        tags: []
      }
    }
  }
]

[direct: mongos] admin> use test_db
[direct: mongos] admin> db.createCollection("cool_animals")
[direct: mongos] admin> db.cool_animals.insertOne({"horses":"unicorn"})
[direct: mongos] admin> sh.enableSharding("test_db")
{
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1695887676, i: 1 }),
    signature: {
      hash: Binary.createFromBase64("/dNkOmzElTKr0AiBFTYgUWrxu24=", 0),
      keyId: Long("7283777600688750617")
    }
  },
  operationTime: Timestamp({ t: 1695887676, i: 1 })
}


# then on shard
shard-one [primary] admin> show dbs
admin    208.00 KiB
config   620.00 KiB
local    564.00 KiB
test_db   40.00 KiB

@MiaAltieri MiaAltieri changed the title [DPE-] POC Add shards to cluster [DPE-2645] POC Add shards to cluster Sep 29, 2023
Base automatically changed from share-secrets to 6/edge September 29, 2023 10:36
src/charm.py Outdated Show resolved Hide resolved
lib/charms/mongodb/v0/mongos.py Outdated Show resolved Hide resolved
lib/charms/mongodb/v0/mongos.py Outdated Show resolved Hide resolved
lib/charms/mongodb/v0/shards_interface.py Show resolved Hide resolved
lib/charms/mongodb/v0/shards_interface.py Outdated Show resolved Hide resolved
@MiaAltieri MiaAltieri merged commit 2dc0d72 into 6/edge Oct 5, 2023
13 of 14 checks passed
@MiaAltieri MiaAltieri deleted the add-shards branch October 5, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants