InvalidReplicaSetConfig: Our replica set config is invalid or we are not a member of it

Sometimes, kubernetes cluster restart. And comes the problem. Just reconig by using the same cofig and force it.

Solution

rs.reconfig(rs.config(),{force:true})

Problems

InvalidReplicaSetConfig

configReplSet:OTHER> rs.status()
{
"operationTime" : Timestamp(1558623903, 1),
"ok" : 0,
"errmsg" : "Our replica set config is invalid or we are not a member of it",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig",
"$gleStats" : {
"lastOpTime" : Timestamp(0, 0),
"electionId" : ObjectId("000000000000000000000000")
},
"lastCommittedOpTime" : Timestamp(0, 0),
"$clusterTime" : {
"clusterTime" : Timestamp(1558623903, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}

AlreadyInitialized

configReplSet:OTHER> rs.initiate(
... {
... _id: "configReplSet",
... configsvr: true,
... members: [
... { _id : 0, host : "mongo-configsvr-0.mongo-configsvr:27019" },
... { _id : 1, host : "mongo-configsvr-1.mongo-configsvr:27019" },
... { _id : 2, host : "mongo-configsvr-2.mongo-configsvr:27019" }
... ]
... }
... )
{
"operationTime" : Timestamp(1558612647, 1),
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23,
"codeName" : "AlreadyInitialized",
"$gleStats" : {
"lastOpTime" : Timestamp(0, 0),
"electionId" : ObjectId("000000000000000000000000")
},
"lastCommittedOpTime" : Timestamp(0, 0),
"$clusterTime" : {
"clusterTime" : Timestamp(1558623903, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}