Creation of ds in 2.0.0 fails with an exception


#1

After installing v2.0.0 I tried to add a DS as shown in bootstrap script but it fails.
The redash_reader user has proper permissions to postgres database as per this:

sudo -u postgres psql -c "CREATE ROLE redash_reader WITH PASSWORD '*******' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN;"
sudo -u redash psql -c "grant select(id,name,type) ON data_sources to redash_reader;" redash
sudo -u redash psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash

Error:

root@6e7ad9e526a6:/# cd /opt/redash/current
root@6e7ad9e526a6:/opt/redash/current# sudo -u redash bin/run ./manage.py ds new "Redash Metadata" --type "pg" --options "{\"user\": \"redash_reader\", \"password\": \"************\", \"host\": \"postgres\", \"dbname\": \"redash\"}"
[2017-08-14 21:23:16,662][PID:303][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2017-08-14 21:23:16,683][PID:303][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Creating pg data source (Redash Metadata) with options:
{"dbname": "redash", "host": "postgres", "password": "**********", "user": "redash_reader"}
Traceback (most recent call last):
  File "/opt/redash/redash-2.0.0/manage.py", line 9, in <module>
    manager()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/flask/cli.py", line 345, in main
    return AppGroup.main(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/flask/cli.py", line 229, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/opt/redash/redash-2.0.0/redash/cli/data_sources.py", line 141, in new
    org=models.Organization.get_by_slug(organization))
  File "/opt/redash/redash-2.0.0/redash/models.py", line 503, in create_with_group
    group=data_source.org.default_group)
AttributeError: 'NoneType' object has no attribute 'default_group'

Any clue why this happens ?

Thanks in advance,
Constantin


#2

If you check a recent version of the bootstrap script you will notice that we no longer create a data source at this stage.

There is a setup process when you first open the app now, which creates the organization and admin user. Until it’s completed you can’t add a data source.

I guess it will be friendlier to check for org existence and print a friendly message if it doesn’t exist yet.


#3

You are right it’s not in bootstrap for ubuntu but it’s still in for amazon.
After entering the Admin user details during setup process and pressing OK button I got “Internal Server error” message in the browser. Though I see the user created:

root@b4f9b675769e:/opt/redash/current# sudo -u redash bin/run ./manage.py users list
[2017-08-15 08:26:01,978][PID:644][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2017-08-15 08:26:01,995][PID:644][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Id: 1
Name: Constantin ...
Email: constantin.*****@***********.com
Organization: *** Global

and organisation too:

root@b4f9b675769e:/opt/redash/current# sudo -u redash bin/run ./manage.py org list
[2017-08-15 08:31:48,748][PID:673][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2017-08-15 08:31:48,766][PID:673][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Id: 1
Name: *** Global
Slug: default