Commit Graph

128 Commits

Author SHA1 Message Date
Arik Fraimovich
d3feba69b2
Downgrade Kombu version to 4.6.3 (#4406)
It was accidentally upgraded as part of the dependencies upgrade we did recently, but 4.6.5 has a bug...
2019-11-27 18:08:47 +02:00
Gabriel Dutra
0aebb37317
Remove Chrome Logger and update Cypress and Percy (#4354) 2019-11-14 15:23:00 -03:00
Nicolas Le Manchet
246eca1121 Migrate the application to Python 3 (#4251)
* Make core app compatible with Python 3

No backward compatibility with Python 2.7 is kept.
This commit mostly contains changes made with 2to3 and manual
tweaking when necessary.

* Use Python 3.7 as base docker image

Since it is not possible to change redash/base:debian to Python 3
without breaking future relases, its Dockerfile is temporarly
copied here.

* Upgrade some requirements to newest versions

Some of the older versions were not compatible with Python 3.

* Migrate tests to Python 3

* Build frontend on Python 3

* Make the HMAC sign function compatible with Python 3

In Python 3, HMAC only works with bytes so the strings and the
float used in the sign function need to be encoded.
Hopefully this is still backward compatible with already generated
signatures.

* Use assertCountEqual instead of assertItemsEqual

The latter is not available in Python 3.
See https://bugs.python.org/issue17866

* Remove redundant encoding header for Python 3 modules

* Remove redundant string encoding in CLI

* Rename list() functions in CLI

These functions shadow the builtin list function which is
problematic since 2to3 adds a fair amount of calls to the builtin
list when it finds dict.keys() and dict.values().

Only the Python function is renamed, from the perspective of the
CLI nothing changes.

* Replace usage of Exception.message in CLI

`message` is not available anymore, instead use the string
representation of the exception.

* Adapt test handlers to Python 3

* Fix test that relied on dict ordering

* Make sure test results are always uploaded (#4215)

* Support encoding memoryview to JSON

psycopg2 returns `buffer` objects in Python 2.7 and `memoryview`
in Python 3. See #3156

* Fix test relying on object address ordering

* Decode bytes returned from Redis

* Stop using e.message for most exceptions

Exception.message is not available in Python 3 anymore, except
for some exceptions defined by third-party libraries.

* Fix writing XLSX files in Python 3

The buffer for the file should be made of bytes and the actual
content written to it strings.

Note: I do not know why the diff is so large as it's only a two
lines change. Probably a white space or file encoding issue.

* Fix test by comparing strings to strings

* Fix another exception message unavailable in Python 3

* Fix export to CSV in Python 3

The UnicodeWriter is not used anymore. In Python 3, the interface
provided by the CSV module only deals with strings, in and out.
The encoding of the output is left to the user, in our case
it is given to Flask via `make_response`.

* (Python 3) Use Redis' decode_responses=True option (#4232)

* Fix test_outdated_queries_works_scheduled_queries_tracker (use utcnow)

* Make sure Redis connection uses decoded_responses option

* Remove unused imports.

* Use Redis' decode_responses option

* Remove cases of explicit Redis decoding

* Rename helper function and make sure it doesn't apply twice.

* Don't add decode_responses to Celery Redis connection URL

* Fix displaying error while connecting to SQLite

The exception message is always a string in Python 3, so no
need to try to decode things.

* Fix another missing exception message

* Handle JSON encoding for datasources returning bytes

SimpleJSON assumes the bytes it receives contain text data, so it
tries to UTF-8 encode them. It is sometimes not true, for instance
the SQLite datasource returns bytes for BLOB types, which typically
do not contain text but truly binary data.

This commit disables SimpleJSON auto encoding of bytes to str and
instead uses the same method as for memoryviews: generating a
hex representation of the data.

* Fix Python 3 compatibility with RQ

* Revert some changes 2to3 tends to do (#4261)

- Revert some changes 2to3 tends to do when it errs on the side of caution regarding dict view objects.

- Also fixed some naming issues with one character variables in list comprehensions.

- Fix Flask warning.

* Upgrade dependencies

* Remove useless `iter` added by 2to3

* Fix get_next_path tests (#4280)

* Removed setting SERVER_NAME in tests setup to avoid a warning.

* Change get_next_path to not return empty string in case of a domain only value.

* Fix redirect tests:

Since version 0.15 of Werkzeug it uses full path for fixing the location header instead of the root path.

* Remove explicit dependency for Werkzeug

* Switched pytz and certifi to unbinded versions.

* Switch to new library for getting country from IP

`python-geoip-geolite2` is not compatible with Python 3, instead
use `maxminddb-geolite2` which is very similar as it includes
the geolite2 database in the package .

* Python 3 RQ modifications (#4281)

* show current worker job (alongside with minor cosmetic column tweaks)

* avoid loading entire job data for queued jobs

* track general RQ queues (default, periodic and schemas)

* get all active RQ queues

* call get_celery_queues in another place

* merge dicts the Python 3 way

* extend the result_ttl of refresh_queries to 600 seconds to allow it to continue running periodically even after longer executions

* Remove legacy Python flake8 tests
2019-10-24 12:42:13 +03:00
Omer Lachish
5a5fdecdde
Replace Celery with RQ (except for execute_query tasks) (#4093)
* add rq and an rq_worker service

* add rq_scheduler and an rq_scheduler service

* move beat schedule to periodic_jobs queue

* move version checks to RQ

* move query result cleanup to RQ

* use timedelta and DRY up a bit

* move custom tasks to RQ

* do actual schema refreshes in rq

* rename 'period_jobs' to 'periodic', as it obviously holds jobs

* move send_email to rq

* DRY up enqueues

* ditch  and use a partially applied  decorator

* move subscribe to rq

* move check_alerts_for_query to rq

* move record_event to rq

* make tests play nicely with rq

* 👋 beat

* rename rq_scheduler to plain scheduler, now that there's no Celery scheduler entrypoint

* add some color to rq-worker's output

* add logging context to rq jobs (while keeping execute_query context via get_task_logger for now)

* move schedule to its own module

* cancel previously scheduled periodic jobs. not sure this is a good idea.

* rename redash.scheduler to redash.schedule

* allow custom dynamic jobs to be added decleratively

* add basic monitoring to rq queues

* add worker monitoring

* pleasing the CodeClimate overlords

* adjust cypress docker-compose.yml to include rq changes

* DRY up Cypress docker-compose

* add rq dependencies to cypress docker-compose service

* an odd attempt at watching docker-compose logs when running with Cypress

* Revert "an odd attempt at watching docker-compose logs when running with Cypress"

This reverts commit 016bd1a93e3efa84a9f27d0f2acb972ce1957bcd.

* show docker-compose logs at Cypress shutdown

* Revert "DRY up Cypress docker-compose"

This reverts commit 43abac7084c207ab9e39192ac79d520448c2c527.

* minimal version for binding is 3.2

* remove unneccesary code reloads on cypress

* add a  command which errors if any of the workers running inside the current machine haven't been active in the last minute

* SCHEMAS_REFRESH_QUEUE is no longer a required setting

* split tasks/queries.py to execution.py and maintenance.py

* fix tests after query execution split

* pleasing the CodeClimate overlords

* rename worker to celery_worker and rq_worker to worker

* use /rq_status instead of /jobs

* show started jobs' time ago according to UTC

* replace all spaces in column names

* fix query tests after execution split

* exit with an int

* general lint

* add an entrypoint for rq_healthcheck

* fix indentation

* delete all existing periodic jobs before scheduling them

* remove some unrequired requires

* move schedule example to redash.schedule

* add RQ integration to Sentry's setup

* pleasing the CodeClimate overlords

* remove replication settings from docker-compose - a proper way to scale using docker-compose would be the --scale CLI option, which will be described in the knowledge based

* revert to calling a function in dynamic settings to allow periodic jobs to be scheduled after app has been loaded

* don't need to depend on context when templating failure reports

* set the timeout_ttl to double the interval to avoid job results from expiring and having periodic jobs not reschedule

* whoops, bad merge

* describe custom jobs and don't actually schedule them

* fix merge
2019-10-15 23:59:22 +03:00
Arik Fraimovich
ff041b77cf
Update Sentry-SDK (#4169) 2019-09-23 09:54:10 +03:00
Arik Fraimovich
e048a69392
Upgrade Sentry-SDK and enable additional integratoins (#4127)
* Update sentry-sdk version

* Add additional Sentry integrations
2019-09-09 10:00:09 +03:00
Gleb Lesnikov
ef9a4d5eed [Data Sources] Add: Azure Data Explorer (Kusto) query runner (#4091)
* [Data Sources] Add: Azure Data Explorer (Kusto) query runner

* CodeClimate fixes

* Remove TODO

* Fixed configuration properties names for Azure Kusto

* Azure Kusto: get_schema in one query

* azure-kusto-data update to 0.0.32

* Add Kusto to the default query runners list
2019-08-26 10:17:49 +03:00
Christian Clauss
d38ca803c5 Add more flake8 tests and fail build if any test fails (#4055)
* Add more flake8 tests and fail build if any test fails

Run all flake8 E9xx + F63x + F7xx + F82x tests.

* long = long in Python 2
2019-08-18 11:27:44 +03:00
Arik Fraimovich
e5e926bac5
Pin kombu version (#4075)
kombu is a dependency of Celery and usually we let them declare the version, but their version is pinned and the most recent release (4.6.4) has a severe regression where workers stop responding to inspect commands.
2019-08-16 19:27:24 +03:00
Arik Fraimovich
c793b5dd11
Remove explicit kombu dependency (#3978)
We used an explicit kombu dependency to target the correct Redis version, but current version of Celery supposed to use it by default.
2019-07-14 08:47:15 +03:00
Mike Nason
4e0a251034 Add support ssl connections to redis (#3848)
* Add support ssl connections to redis

* Fix line length

* Update redash/__init__.py w suggestion

Co-Authored-By: Omer Lachish <omer@rauchy.net>

* Cleanup init after suggestion

* Move redis SSL config to settings

* Do not pass celery SSL config unless necessary

* Fix typo
2019-06-12 13:04:34 +03:00
dependabot[bot]
3faed0fdfe Bump pyopenssl from 16.2.0 to 17.5.0 (#3872)
Bumps [pyopenssl](https://github.com/pyca/pyopenssl) from 16.2.0 to 17.5.0.
- [Release notes](https://github.com/pyca/pyopenssl/releases)
- [Changelog](https://github.com/pyca/pyopenssl/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/pyopenssl/compare/16.2.0...17.5.0)
2019-06-12 11:38:47 +03:00
dependabot[bot]
e45f49b86e Bump cryptography from 2.0.2 to 2.3 (#3870)
Bumps [cryptography](https://github.com/pyca/cryptography) from 2.0.2 to 2.3.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/2.0.2...2.3)
2019-06-12 11:38:38 +03:00
dependabot[bot]
e433efebc4 Bump flask from 0.11.1 to 0.12.3 (#3871)
* Bump flask from 0.11.1 to 0.12.3

Bumps [flask](https://github.com/pallets/flask) from 0.11.1 to 0.12.3.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/master/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/0.11.1...0.12.3)

* Bump to Flask 0.12.4 to fix an issue
2019-06-03 18:04:43 +03:00
Jannis Leidel
07c9530984 Decouple extensions from Flask app. (#3569)
* Decouple extensions from Flask app.

This separates the extension registry from the Flask app and also introduces a separate registry for preriodic tasks.

Fix #3466.

* Address review feedback.

* Update redash/extensions.py

Co-Authored-By: jezdez <jannis@leidel.info>

* Minor comment in requirements.

* Refactoring after getting feedback.

* Uncoupled bin/bundle-extensions from Flas app instance.

* Load bundles in bundle script and don’t rely on Flask.

* Upgraded to importlib-metadata 0.9.

* Add missing requirement.

* Fix TypeError.

* Added requirements for bundle_extension script.

* Install bundles requirement file correctly.

* Decouple bundle loading code from Redash.

* Install bundle requirements from requirements.txt.

* Use circleci/node for build-docker-image step, too.
2019-05-26 14:56:02 +03:00
Jannis Leidel
712fc63f93 Use flask-talisman for handling backend response headers (#3404)
* Normalize Flask initialization API use.

* Use Flask-Talisman.

* Enable HSTS when HTTPS is enforced.

* More details about how CSP is formatted and write CSP directives as a string.

* Use CSP frame-ancestors directive and not X-Frame-Options for embedable endpoints.

* Add link to flask-talisman docs.

* set remember_token cookie to be HTTP-Only and Secure

* Reorganize secret key configuration to be forward thinking and backward compatible.
2019-03-27 17:24:15 +02:00
Jannis Leidel
4e7d16b642 Remove Flask-Admin. (#3532) 2019-03-06 08:36:46 +02:00
ialeinikov
fbaded4548 adding gevent worker in requirements.txt, adding some gunicorn config… (#3333)
* adding gevent worker in requirements.txt, adding some gunicorn configurable parameters with defaults

* reverting the change as it's going to be set via env variable(s)
2019-02-27 11:15:31 +02:00
Arik Fraimovich
b56cc1cd16 Pin SQLAlchemy-Utils version (#3490)
Pin the version of SQLAlchemy-Utils following the discussion in #2970.
2019-02-25 11:22:48 +01:00
Omer Lachish
71fb1442f1
Upgrade Sentry SDK (#3418)
* replace raven with sentry-sdk

* use sentry-sdk in celery

* use sentry-sdk with flask

* unify Flask and Celery initializations for Sentry

* extract sentry stuff to own module

* it's time for Sentry 0.7.2
2019-02-10 21:56:16 +02:00
Jannis Leidel
bd559b6eeb Fix some incompatible dependencies (#3348)
* Pin requests-oauthlib to work around incompatible deptree.

* Update boto3/botocore to fix incompatible deptree.
2019-01-31 09:50:47 +02:00
Arik Fraimovich
d68a4dce5f
Pin version of pyparsing (#3282) 2019-01-14 17:17:23 +02:00
Omer Lachish
a29136037c
update Flask-OAuthLib (#3262) 2019-01-09 13:48:21 +02:00
Arik Fraimovich
08953cc919
Redis based implementation of user active_at timestamp update (#3256)
* Switch to simpler implementation
* Fix active_at update code
* Fix sync test
2019-01-08 14:03:49 +02:00
Jannis Leidel
44dff83046 Add "Active at" column to user list. (#3026)
* add last_active_at to users page

* Use our JSON encoder as the SQLAlchemy JSON serializer.

* Fixed some inconsistencies in the user query class methods.

* Minor cosmetic fixes.

* Add some make tasks for easier development.

* Add user detail sync system based on Redis backend.

There is a periodic Celery task that updates a new “details” JSONB column in the “user” table with the data from Redis.

Currently this is only used for tracking the date of last activity of a user but can be extended with other user information later.

Updates a few dependencies.

* Normalize a few Flask extension API names.

* Reduce implementation complexity of JSONEncoder.

* Use request_started signal to make sure we have a request context.

Otherwise loading the user based on the request won’t work.

* Fix test that checks if disabled users can login.

This correctly uses a URL path that includes the current organization and checks for the error message.

The previous test seems to have been a red herring.

* Minor cosmetic fixes.

* Remove needs_sync in favor of just deleting things.

* Misc review fixes.

* Ignore line length.

* Split redash.models import several modules.

* Move walrus UTC DateTimeField into redash.models.types.

* Restore distinctly loading dashboards.

* Simplify default values for user details.

* Define __repr__ methods generically.

* Consistently have underscore methods at the top of model methods.

* Fix tests.

* Split redash.models import several modules.

* Update to latest walrus and redis-py.

* Update kombu to 4.2.2 for redis-py 3.x compatibility.

* Remove redis-cli container after running Make task.

* Move buffer condition after datetime/time conditions.

* Update walrus to 0.7.1.

* Refactor some query APIs.

This uses the flask-sqlalchemy helpers consistently and makes more use of mixins.

* Post rebase fixes.

* Use correct kombu version

* Fix migration down revision
2019-01-07 10:30:42 +02:00
YOSHIDA Katsuhiko
7a2e08c3eb Upgrade requests package (#3245) 2019-01-03 18:59:58 +02:00
yoavbls
46941d3aa1 Update Flask-Admin to 1.5.2 (#3036)
I don't know if someone uses flask-admin but I upgraded it because of this bug:
https://github.com/flask-admin/flask-admin/issues/1588
In 1.4.2 you cant add and edit records/
2018-11-01 15:58:50 +02:00
Alexander Leibzon
e97a5cbb29 add PagerDuty as an Alert Destination (#2903) 2018-10-14 10:35:39 +03:00
Arik Fraimovich
bfef7fae93
Remove unused dependencies. (#2907)
Closes #2782
2018-10-08 09:39:57 +03:00
cclauss
da6d456f6f CircleCI: Flake8 tests passing on Legacy Python and Python 3 (#2881) 2018-10-05 13:48:01 +03:00
Marina Samuel
b765693879 Upgrade Celery to 4.2.1. (#2773) 2018-09-28 21:28:30 +02:00
Alexey Korobkov
ea1c4ca85c Add auth via JWT providers (#2768)
* authentication via JWT providers
* add support for IAP JWT auth
* remove jwt_auth Blueprint and /headers endpoint
* fix pep8: imports
2018-09-26 21:17:48 +03:00
Arik Fraimovich
a014df36d8
Merge pull request #2686 from jezdez/serverside
Implement server side pagination and sorting for queries lists
2018-08-01 16:55:40 +03:00
Arik Fraimovich
3c7dd064ef Block users with temporary domains 2018-07-25 13:06:26 +03:00
Jannis Leidel
486a6068ac
Update SQLAlchemy. 2018-07-18 21:44:55 +02:00
Arik Fraimovich
20261d0632 Add support for ChromeLogger extension 2018-07-12 11:37:35 +03:00
Vladislav Denisov
8cd8650119 requirements: added pyyaml 2018-06-20 12:03:46 +03:00
ariarijp
f5d4ca85d8 Upgrade sqlparse to 0.2.4
Add test case for /api/queries/format
2018-02-23 01:24:34 +09:00
Arik Fraimovich
7e4cb4c543 Add: API to return events 2018-02-11 11:56:10 +02:00
Jannis Leidel
7b82203fb1
Upgrade to Celery 3.1.25 in preparation to Celery 4.
To prepare for a future Celery upgrade to verson 4.x this upgrades
Redash to 3.1.25 which includes support for Celery's task protocol 2.
It's the first of two steps to get Redash upgraded to Celery 4.x.

3.1.4 release notes: http://docs.celeryproject.org/en/3.1/changelog.html#version-3-1-24
4.0 release notes regarding the two-step-upgrade approach: http://docs.celeryproject.org/en/latest/whatsnew-4.0.html#step-1-upgrade-to-celery-3-1-25
2018-01-30 19:22:33 +01:00
Jannis Leidel
9f6b4fbdf2
Add full text search for queries based on the Postgres tsvector type. 2018-01-08 22:46:53 +01:00
Arik Fraimovich
7602599738 Update pysaml2 version to latest release. 2018-01-02 10:48:33 +02:00
Ronald Crooy
80a74934f0 fixing issue #2150 2017-12-12 11:37:24 +01:00
Katsuhiko YOSHIDA
f4c4e18bf7 Upgrade psycopg2 latest version 2017-12-02 09:11:43 +09:00
Katsuhiko YOSHIDA
e17a1a1378 Upgrade psycopg2 for support PostgreSQL 10.0 as a library 2017-12-01 19:31:05 +09:00
Arik Fraimovich
0b0ec90987 Update gunicorn to latest version 2017-10-16 09:19:13 +03:00
Arik Fraimovich
3af9b333a8 Merge pull request #1898 from StantonVentures/security_lib_updates_7_27_2017
update libraries
2017-08-16 16:19:57 +03:00
Amar Ramachandran
588c868060 Make ldap3 requirement optional 2017-08-09 10:32:44 -07:00
Alison
1bc8d586c3 update libraries
Based on pyup auto-PR httplib2 and cryptography needed updating which
necessitated updating pyOpenSSL as well.
2017-07-27 21:15:39 -05:00
Amar Ramachandran
9ea4784f87 Add ldap3 requirement 2017-06-20 15:33:32 -07:00