92 Commits

Author SHA1 Message Date
Tsuneo Yoshioka
74de676bdf Allow HTTP request line more than 4096 bytes (#7506) 2025-09-04 18:05:05 +00:00
Eric Radman
de49b73855 Replace ptvsd with debugpy to match modern VS Code (#7234) 2024-11-27 08:19:05 +10:00
Eric Radman
58cc49bc88 Revert build (2 of 2) (#6967) 2024-05-14 12:30:48 +00:00
Justin Clift
b9875a231b Improve the text displayed when using the command line (#6884)
This removes some debugging output, and makes an unexpected text
string useful by explaining what's happening.
2024-04-13 11:51:15 +10:00
Andrii Chubatiuk
3f19534301 reuse built frontend in ci, merge compose files (#6674)
* reuse built frontend in ci, merge compose files

* pr comments

* added make create_db alias to create_database

* fixed lint

---------

Co-authored-by: Andrii Chubatiuk <wachy@Andriis-MBP-2.lan>
2024-04-10 19:53:14 +10:00
Guido Petri
0993f68fa0 Poetry conversion followup (#6440)
* change author and add maintainers

* remove bin/upgrade

* update project author/maintainers

* comment on how to get added/removed from the mailing list
2023-09-11 22:25:54 -04:00
Will Lachance
ca900769c2 Replace flake8/isort with ruff (#6441)
There's a few advantages of using ruff over these tools:

* It's way faster
* It's easier to configure
* It includes support for a bunch of other linters (for example bugbear)
  right out of the box, which catches some things and makes our code
  more consistent.

Ruff works great with black, which I'd recommend we continue using.

Fixed a few minor issues that the new linter combo picked up.
2023-09-11 06:41:08 -04:00
Konstantin Smirnov
0d1ce4d98c Incomplete URL substring sanitization (#6342)
* Incomplete URL substring sanitization

* fix hostname

* Only match on the exact host name

---------

Co-authored-by: Justin Clift <justin@postgresql.org>
2023-08-02 21:31:18 +00:00
Jun
9b2f635692 format code by black and isort (#6167)
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2023-07-11 19:13:54 +10:00
須藤大輔 (SUDO Daisuke)
64c24b77f9 fix comparison operator (#5945) 2023-04-20 09:13:20 -07:00
Shubham Jain
5b9fd40dc7 Add liveness check for workers (#5886)
* Add liveness check script for workers

closes #5885

* delete extra script

* Rename worker_healthcheck -> workers_healthcheck

---------

Co-authored-by: Arik Fraimovich <arik@arikfr.com>
2023-03-27 13:11:18 -07:00
Arik Fraimovich
28b0a2379d Remove extensions mechanism (#5895)
* Remove extensions mechanism.

* Missing change.
2023-03-20 07:39:21 -07:00
tsbkw
82361e7054 fix: Support importlib_metadata v5.0.0 (#5840)
* fix: Support importlib_metadata v5.0.0

importlib_metadata removed compatibility shims for deprecated entry point interfaces.
see: https://github.com/python/importlib_metadata/blob/main/CHANGES.rst#v500

Filter result of entry_points function by group parameter.
see: https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.entry_points

* fix: Enable to run in older python version

In circleci frontend-unit-tests, old node image is used and python 3.5 is used.
Support both old version and latest version by checking ijmportlib_metadata version
2023-02-16 13:47:56 +11:00
Jacek Jabłoński
3624f8f2be Feature: allow configuration / increase of gunicorn timeout (#5783) 2022-07-06 16:00:56 -05:00
Josh Bohde
e2e8714155 Enable graceful shutdown of rq workers (#5214)
* Enable graceful shutdown of rq workers

* Use `exec` in the `worker` command of the entrypoint to propagate
  the `TERM` signal
* Allow rq processes managed by supervisor to exit without restart on
  expected status codes
* Allow supervisorctl to contact the running supervisor
* Add a `shutdown_worker` command that will send `TERM` to all running
  worker processes and then sleep. This allows orchestration systems
  to initiate a graceful shutdown before sending `SIGTERM` to
  supervisord

* Use Heroku worker as the BaseWorker

This implements a graceful shutdown on SIGTERM, which simplifies
external shutdown procedures.

* Fix imports based upon review

* Remove supervisorctl config
2020-11-05 11:49:45 +02:00
Jannis Leidel
41a691328a Fix bundle-extensions script to work on recent importlib-resources. (#5050)
Also adds a test case for running the script.
2020-07-16 23:05:22 +03:00
Gabriel Dutra
d12691dc2a Databricks Schema Browser: Allow eventlet worker instead of RQ (#5045)
* Add loading button in UI

* Handle databricks schema requests without RQ

* Don't use gevent worker

* Revert "Don't use gevent worker"

This reverts commit 9704c70a94.

* Use eventlet

* Use first column instead of 'namespace' one

* Revert "Add loading button in UI"

This reverts commit c0e4dfb966.

* Remove databricks tasks

* Update eventlet

* Add libevent

* Display logs on failure

* Revert "Add libevent"

This reverts commit a00d067cb7.

* Test updating gunicorn

* Don't set eventlet as the default for Redash

Co-authored-by: Arik Fraimovich <arik@arikfr.com>

* Remove fetchDataFromJob usage

Co-authored-by: Arik Fraimovich <arik@arikfr.com>
2020-07-15 17:35:59 +03:00
Rob Hudson
8597b727a7 Update requirements_bundles versions and comment (#4939) 2020-06-09 13:38:29 +02:00
Gianni Moschini
3661d6cbc5 Remove heroku bin/pre_compile file (#4900) 2020-05-20 13:02:39 +03:00
Omer Lachish
b0f1cdd194 remove rq_healthcheck entrypoint and deprecate celery_healthcheck (#4574) 2020-02-27 17:55:04 +02:00
Omer Lachish
aa17681af2 Nuke Celery (#4521)
* enforce hard limits on non-responsive work horses by workers

* move differences from Worker to helper methods to help make the specialization clearer

* move HardLimitingWorker to redash/tasks

* move schedule.py to /tasks

* explain the motivation for HardLimitingWorker

* pleasing CodeClimate

* pleasing CodeClimate

* port query execution to RQ

* get rid of argsrepr

* avoid star imports

* allow queries to be cancelled in RQ

* return QueryExecutionErrors as job results

* fix TestTaskEnqueue and QueryExecutorTests

* remove Celery monitoring

* get rid of QueryTask and use RQ jobs directly (with a job serializer)

* Revert "remove Celery monitoring"

This reverts commit 37a74ea403.

* reduce occurences of the word 'task'

* use Worker, Queue and Job instead of spreading names that share behavior details

* remove locks for failed jobs as well

* did I not commit that colon? oh my

* push the redis connection to RQ's stack on every request to avoid verbose connection setting

* use a connection context for tests

* remove Celery monitoring

* 👋 Celery

* remove Celery from Cypress

* black it up

* some more black

* return all started/queued job ids (for future monitoring

* Restyled by prettier (#4522)

* remove celery.py

* remove some frontend residuals that reappeared after a merge

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
2020-01-12 22:36:48 +02:00
Omer Lachish
260bfca767 Multiprocess RQ workers (using supervisor) (#4371)
* launch and monitor multiple workers using supervisor

* run supervisord in non-daemon mode

* redirect all output to stdout/stderr

* no need to log supervisord's output because it is redirected to stdout anyway

* updated and less brittle healthcheck

* add supervisor healthchecks

* remove redundant supervisor installation as it is installed by pip

* add a 5 minute check gate
2020-01-01 15:32:29 +02: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 016bd1a93e.

* show docker-compose logs at Cypress shutdown

* Revert "DRY up Cypress docker-compose"

This reverts commit 43abac7084.

* 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
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
Jannis Leidel
7b5696dc75 Fix loading of periodic tasks and clean up extension loading. (#4064)
* Fix loading of periodic tasks and clean up extension loading.

This does a few things:

- add tests for extension loading
- refactor the extension and periodic task loading
- better handle assertions raised by extensions (e.g. when an extension tries to override an already registered view)
- attach exception traceback to error log during loading for improved debugging

* Use site.addsitedir instead of calling pip.

* Use sys.path instead of site.addsitedir and also the setup.py egg_info command.
2019-08-13 13:11:59 +03:00
Omer Lachish
f165168860 recycle gunicorn workers (#4013) 2019-07-28 11:39:14 +03:00
Omer Lachish
c83e40b047 Celery doesn't auto reload in development (#3898)
* pick up *.py file changes and restart scheduler

* only watch /redash in order to avoid reloading on other file changes (e.g. tests)

* add dev_scheduler entrypoint

* use exec

* Update bin/docker-entrypoint

* rename dev_scheduler to dev_worker

* use same defaults as worker
2019-07-17 10:38:56 +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
1933dee8ca Fix Celery worker --max-tasks-per-child for Celery 4.x. (#3625)
* Fix Celery worker CLI parameter name that was changed in Celery 4.x.

* Set Celery worker --max-memory-per-child to 1/4th of total system memory.

* Review fixes.

* Review fixes.
2019-03-27 21:08:20 +02:00
Arik Fraimovich
9de676acee Fix: make sure that only the top level node_modules directory is excluded (#3600)
* Fix: make sure that only the top level node_modules directory is excluded

* Remove old unused packing script
2019-03-18 11:13:42 +02:00
Arik Fraimovich
8737e8032e Add: Docker entrypoint to do Celery healthchecks. (#3548) 2019-03-07 22:32:27 +02:00
MURAOKA Taro
8fe1d33068 monitor "schemas" queue to run refresh_schema (#3459)
* monitor "schemas" queue to run refresh_schema

`refresh_schema` tasks won't run because "schemas" queue isn't consumed
with default settings.
and it cause leaking redis storage, a "schemas" list is growing with time.

this PR fix it, adds "schemas" queue to monitor by celery.

* use scheduled_worker for "schemas" queue

instead of "adhoc_worker"
2019-02-21 12:06:25 +02:00
Omer Lachish
330c5a85f1 Enable remote debugging with ptvsd (#3419)
* open port 3000 for remote debugging

* add ptvsd

* use port 5678 to avoid changes in VSCode's default config

* attach to ptvsd

* no need to wait for attach

* actually, --debugger seems to be working

* create a new docker entry point for remote debugging

* alternative method to switch to debugging
2019-02-12 09:10:18 +02:00
Vincentoo
fc368ee425 Support overriding the default Celery schedule database file via SCHEDULE_DB environment variable. (#3056)
By default Celery will use a file celerybeat-schedule in the current directory.
This is an issue in a Kubernetes/Openshift environment as the file may be lost or even impossible to write.
2019-01-03 20:51:18 +02:00
koooge
c2bd8518a6 Makefile: Add make targets for test (#3032) 2018-11-12 09:06:25 +01:00
Marina Samuel
02e919c39b Closes #2565: Add frontend extension capability. (#2799) 2018-10-14 15:53:39 +03:00
Jannis Leidel
c2429e92d2 Consistently use simplejson to loading and dumping JSON. (#2817)
* Consistently use simplejson to loading and dumping JSON.

This introduces the new functions redash.utils.json_dumps and redash.utils.json_loads and simplifies the custom encoder setup.

UUIDs are now handled by the default encoder, too.

Fixes #2807.

Use string comparison in parse_boolean instead of the (simple)json module.
2018-10-09 15:38:06 +02:00
cclauss
da6d456f6f CircleCI: Flake8 tests passing on Legacy Python and Python 3 (#2881) 2018-10-05 13:48:01 +03:00
Arik Fraimovich
a6d501a394 More improvements to CircleCI configuration (#2777)
* Moved configuration to `.circleci/config.yml` as the documentation for V2 suggests.
* Created a dedicated Docker Compose configuration (in `.circleci/docker-compose.yml`) to remove volumes configuration as this is not supported with CircleCI's Docker executer.
* Fix the Docker image build and tarball packing jobs to work and use correct version.
2018-08-30 20:19:52 +03:00
Benjamin Forehand Jr
99dd4ddca2 Initial update to circleci v2 config. (#2672) 2018-08-29 11:19:25 +03:00
Valentin Ouvrard
0982e56ed0 fix entrypoint create_table() func. 2018-03-26 10:01:58 +11:00
Valentin Ouvrard
452904398f Fix docker-entrypoint broke for Other name than "postgres" 2018-03-08 10:04:29 +11:00
Arik Fraimovich
33aa7b72b7 Enable debug mode for Flask. 2018-02-27 23:09:00 +02:00
Arik Fraimovich
927599cf00 Mark current version as v4-beta 2018-02-14 17:06:51 +02:00
Arik Fraimovich
aa06e44ff8 Merge pull request #2099 from ariarijp/fix/create_db
Fix create_db command of docker-entrypoint
2018-02-11 15:48:56 +02:00
Arik Fraimovich
5e97834b80 Fix upgrade script to support CI builds 2018-02-08 11:35:12 +02:00
Arik Fraimovich
ba0b9da09f Fix syntax errors. 2018-01-25 12:39:47 +02:00
Arik Fraimovich
2f51df3435 Allow passing options to tests Docker command. 2018-01-02 13:30:06 +02:00
Arik Fraimovich
6c4989d8a0 Replace Makefile with scripts 2017-12-31 14:34:41 +02:00