Mercurial > hg > thermostat-ng > agent
changeset 2474:ff7e92342414
Windows - fsync mongodb after creating user
For MongoDB V 3, adds the hostManager role to thermostat-admin (required for fsync),
and, after creating the users, performs an fsync to ensure the database is on disk
Reviewed-by: sgehwolf
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-October/021251.html
author | Simon Tooke <stooke@redhat.com> |
---|---|
date | Thu, 13 Oct 2016 14:51:30 -0400 |
parents | 7659652d08ea |
children | 404613dd8275 |
files | distribution/libs/create-user.js |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/distribution/libs/create-user.js Thu Oct 13 14:03:45 2016 -0400 +++ b/distribution/libs/create-user.js Thu Oct 13 14:51:30 2016 -0400 @@ -14,10 +14,15 @@ db.createUser({ user: "$USERNAME", pwd: "$PASSWORD", roles: [ "readWrite" ] }) } else if ( majorVersion == 3 ) { db = db.getSiblingDB("admin") - db.createUser({ user: "thermostat-admin", pwd: "$PASSWORD", roles: [ "dbOwner", "userAdminAnyDatabase" ] }) + // role 'hostManager' is required to permit the fsync operation after creating the users + db.createUser({ user: "thermostat-admin", pwd: "$PASSWORD", roles: [ "dbOwner", "userAdminAnyDatabase", "hostManager" ] }) db.auth("thermostat-admin", "$PASSWORD") db = db.getSiblingDB("thermostat") db.createUser({ user: "$USERNAME", pwd: "$PASSWORD", roles: [ "readWrite" ] }) + // on Windows (which is mongodb 3 and up only), ensure the new users are written to disk + // (Windows has a hard shutdown sometimes) + db = db.getSiblingDB("admin") + db.runCommand({ fsync: 1, async: false }) } else { throw "Unknown mongo version: " + v }