MG-RAST/Shock

Possible regression re inserting admins from conf on startup

Closed this issue · 2 comments

There was a bug in Shock prior to version 0.8.24 such that administrators listed in the Shock conf files were not added to the database, and therefore had no admin privs, if the Users collection was empty. This was fixed in ab571f8, but 0.9.6 appears to have a regression:

kbtestuser@dev03:~$ /kb/deployment/bin/shock-server --conf /kb/deployment/services/shock_service/conf/shock.cfg
The ACL schema version in your database needs updating.  Would you like the update to run? (y/n): y
Updating ACL's to version: 2
ACL schema version update complete.
The Node schema version in your database needs updating.  Would you like the update to run? (y/n): y
Updating Nodes to version: 2
Node schema version update complete.

 +-------------+  +----+    +----+  +--------------+  +--------------+  +----+      +----+
 |             |  |    |    |    |  |              |  |              |  |    |      |    |
 |    +--------+  |    |    |    |  |    +----+    |  |    +---------+  |    |      |    |
 |    |           |    +----+    |  |    |    |    |  |    |            |    |     |    |
 |    +--------+  |              |  |    |    |    |  |    |            |    |    |    |
 |             |  |    +----+    |  |    |    |    |  |    |            |    |   |    |
 +--------+    |  |    |    |    |  |    |    |    |  |    |            |    +---+    +-+
          |    |  |    |    |    |  |    |    |    |  |    |            |               |
 +--------+    |  |    |    |    |  |    +----+    |  |    +---------+  |    +-----+    |
 |             |  |    |    |    |  |              |  |              |  |    |     |    |
 +-------------+  +----+    +----+  +--------------+  +--------------+  +----+     +----+
####### Anonymous ######
read:   false
write:  false
delete: false

##### Auth #####
type:   globus
token_url:  https://nexus.api.globusonline.org/goauth/token?grant_type=client_credentials
profile_url:    https://nexus.api.globusonline.org/users

##### Admin #####
users:  lolcatservice

##### Paths #####
site:   /mnt/Shock/site
data:   /mnt/Shock/data
logs:   /mnt/Shock/logs
local_paths:    

##### SSL disabled #####

##### Mongodb #####
host(s):    localhost
database:   ShockDB

##### Address #####
ip: 0.0.0.0
port:   7044

##### Log rotation disabled #####

##### Versions ####
name: ACL   version number: 2
name: Auth  version number: 1
name: Node  version number: 2

##### Procs #####
Number of available CPUs = 4
Running Shock server with GOMAXPROCS = 2

kbtestuser@dev03:~$ curl http://localhost:7044
{"attribute_indexes":[""],"contact":"shock-admin@kbase.us","documentation":"http://localhost:7044/wiki/","id":"Shock","auth":["globus"],"anonymous_permissions":{"read":false,"write":false,"delete":false},"resources":["node"],"server_time":"2015-11-21T13:56:27-08:00","type":"Shock","url":"http://localhost:7044/","version":"0.9.6"}

kbtestuser@dev03:~$ /kb/runtime/bin/mongo
MongoDB shell version: 2.4.3
connecting to: test
> show dbs
ShockDB 0.203125GB
local   0.078125GB
workspace   0.203125GB
workspace_types 0.203125GB
> use ShockDB
switched to db ShockDB
> db.getCollectionNames()
[ "Nodes", "PreAuth", "Users", "Versions", "system.indexes" ]
> db.Users.find()
> exit
bye

Prior to starting Shock, I dropped the ShockDB database from MongoDB.

Shock only adds users to the the Users collection when an auth header is authenticated and the user information is obtained. On startup Shock does add admin status to any existing users that are in the DB, but can not if the Users collection is empty, as in your case.

Looking at the code, it appears Shock does not add the admin status to a new user that is listed in the config as an admin when that user is first added to mongoDB, Shock would need to be stopped and then restarted for that to happen.

I will add this minor fix to our todo list.

This is fixed with version 0.9.13.