Commit Graph

120 Commits

Author SHA1 Message Date
Matus Valo 58975b2a95
Ensure that restore is atomic in redis transport (#1444)
* Ensure that restore is atomic in redis transport

* Fix wrong variable

* Added integration tests

* Update unittests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix integration tests

* Fix flake8

* Fix queue name in int. tests

* Cosmetic clean up of integration tests

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-12-10 23:53:40 +01:00
n0061q 081e9e6cff
SQS transport: detect FIFO queue properly by checking queue URL (#1450)
* SQS: detect FIFO queue properly

* SQS: validate predefined queues

Co-authored-by: Yaroslav Litus <Yaroslav.Litus@F-Secure.com>
2021-12-03 09:46:41 +01:00
Matus Valo 73b10a9346 Return empty list instead of InconsistencyError when exchange table is empty
Missing redis key containg set of queues bound to queue is caused
by removal all queues from the exchange. Hence, we should not raise an
exception but just return empty list of queues instead. This commit
fixes e.g. case publishing message against empty exchange:

import kombu
conn = kombu.Connection('redis://')
exchange = kombu.Exchange('name', type='direct')
exchange.declare(channel=conn.default_channel)

producer = conn.Producer()
producer.publish(
     {'hello': 'world'},
     exchange=exchange,
     routing_key='queue1'
)

But it also fixes the case when last queue is unbound from exchange and
after publishing to this exchange:

import kombu
conn = kombu.Connection('redis://')
exchange = kombu.Exchange('name', type='direct')
queue1 = kombu.Queue('queue1', exchange=exchange, routing_key='queue1')
exchange.declare(channel=conn.default_channel)
queue1 = queue1.bind(channel=conn.default_channel)
queue1.declare()

producer = conn.Producer()
producer.publish(
     {'hello': 'world'},
     exchange=exchange,
     routing_key='queue1'
)

queue1.delete()

producer.publish(
     {'hello': 'world'},
     exchange=exchange,
     routing_key='queue1'
)
2021-10-25 07:28:10 +06:00
pre-commit-ci[bot] ee99595232
[pre-commit.ci] pre-commit autoupdate (#1393)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v2.26.0 → v2.28.0](https://github.com/asottile/pyupgrade/compare/v2.26.0...v2.28.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-09-27 21:35:17 +03:00
kaiix 580b5219cc Fix: check redis response type 2021-09-16 20:50:28 +06:00
Matus Valo 07bab02bc3
Remove dependency to case (#1389)
* Remove dependency to case

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix flake8 errors

* Remove unused code

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-09-15 21:00:08 +06:00
Matus Valo ef6ec99154 Use ANY from unittest instead of case.mock 2021-09-12 01:03:09 +02:00
Matus Valo 7230665e5c Make BrokerState Transport specific 2021-08-30 14:02:20 +06:00
Gábor Boros 24b0820d0b fix: add missing commands to prefix
Add missing DEL, RPUSH, RPOP and SREM commands to the list of commands to prefix.

Also, this commit refactors the prefixing logic a bit to make it simpler.
2021-08-27 16:35:35 +06:00
Gábor Boros 39584a1940
Add global key prefix for keys set by Redis transporter (#1349)
* Introduce global key prefix for redis transport

Co-authored-by: Matus Valo <matusvalo@users.noreply.github.com>

* refactor: use a custom redis client

As per the suggestions, refactor the redis key prefixing to use a custom
redis client that prefixes the keys it uses.

The custom client implementation does not prefix every key by default as
the way of prefixing keys may differ for some redis commands, instead it
lists those keys that will be prefixed. In case of commands, where
multiple keys can be passed as an argument, the custom client defines
where the arg positions are starting and ending for the given command.

* test: fix unit tests by moving import statement

* fix: wrap redis.parse_response to remove key prefixes

Co-authored-by: Matus Valo <matusvalo@users.noreply.github.com>

* fix: typo

* fix: lint

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
Co-authored-by: Matus Valo <matusvalo@users.noreply.github.com>
Co-authored-by: Jillian Vogel <jill@opencraft.com>
2021-08-25 14:08:17 +02:00
Brad Smith 9a91e8b780 SQS Channel.predefined_queues should be `{}` if not defined
Previously, calling `reject` when `predefined_queues` was not configured would cause `AttributeError` to be raised from `_extract_backoff_policy_configuration_and_message`. That exception could crash the whole Celery worker and force it to exit early because `AttributeError` is not excepted in the nearby call stack.
2021-08-21 16:22:41 +06:00
pre-commit-ci[bot] 1a512ffac9 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-08-05 20:05:25 +06:00
Matus Valo c0f2b847f0 Use hostname from URI when server_host is None 2021-08-05 20:05:25 +06:00
Thomas Grainger 241b5dcff8
enable pre-commit (#1355)
* enable pre-commit

* use extend-ignore for flake8

* manual flake8 fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update kombu/__init__.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-07-20 19:07:49 +06:00
Gábor Boros 2d036f54b6
Add support for setting redis username (#1351)
* feat: add support for setting redis username

* tests: add redis connparams credentials tests
2021-07-08 23:27:05 +02:00
Felix Yan e5dbfed8ae
Move pytest.importorskip to run earlier (#1346)
* Move pytest.importorskip to run earlier

Currently pytest fails to collect tests when `azure` is not present. Moving the pytest.importorskip clause before `from kombu.transport import azureservicebus` fixes it.

```
==================================== ERRORS ====================================
__________ ERROR collecting t/unit/transport/test_azureservicebus.py ___________
ImportError while importing test module '/build/python-kombu/src/kombu-5.1.0/t/unit/transport/test_azureservicebus.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
t/unit/transport/test_azureservicebus.py:12: in <module>
    from kombu.transport import azureservicebus
kombu/transport/azureservicebus.py:66: in <module>
    import azure.core.exceptions
E   ModuleNotFoundError: No module named 'azure'
```

* Add # noqa to make linter happy
2021-06-11 09:21:09 +02:00
Matus Valo a920bb0365
Revert "chore: Refactor code quality issues (#1320)" (#1342)
This reverts commit 3b6cd13d3b.
2021-05-19 14:05:14 +02:00
Aksh Gupta 3b6cd13d3b
chore: Refactor code quality issues (#1320)
* chore: refactor code quality issues

* remove .deepsource.toml config file
2021-04-28 18:40:37 +03:00
Matus Valo c35fd1d9b4
Make flake8 and pydocstyle happy (#1333)
* Make flake8 happy

* Make pydocstyle happy
2021-04-13 23:20:31 +02:00
Tomasz Niedziela-Brach 44dcc33a74
Azure Service Bus - versatile queue names fix (#1324)
* fixed character replace table according to the comment above - dots replaced by dashes, other punctuations replaced by underscores

* optimised with precalculated punctuation set - according to @thedrow suggestion

* queue name tests

* cleanup
2021-04-04 18:02:03 +03:00
gal cohen b5a1edde48
SQS Broker - handle STS authentication with AWS (#1322)
* handle sqs sts

* add doc

* use string format

* improve docs

* Update kombu/transport/SQS.py

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* add helper method and tests

* changer to private

Co-authored-by: galcohen <gal.cohen@autodesk.com>
Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Omer Katz <omer.drow@gmail.com>
2021-03-29 11:35:49 +03:00
Max Nikitenko 2a704e3585
fix: non kombu json message decoding in SQS transport (#1306)
* fix: non kombu json message decoding in SQS transport

* fix: non kombu json message decoding in SQS transport - add tests

Co-authored-by: Max Nikitenko <max.nikitenko@namecheap.com>
2021-03-07 14:35:55 +06:00
Matus Valo d3ded0069c
Revert "Port of redis code improvements from prior revision (#1132)" (#1307)
This reverts commit 753f4ec174.
2021-03-06 20:36:59 +01:00
Matt Davis 753f4ec174
Port of redis code improvements from prior revision (#1132)
* Port of redis code improvements from prior revision

Add fakeredis requirement

* refine variable naming based on PR feedback.

* Remove python2 code style and remove unittest.Testcase from test_redis.py

* Code refactor of redis.py and test_redis.py

Co-authored-by: Matus Valo <matusvalo@gmail.com>
2021-03-03 22:40:37 +01:00
gal cohen 2e9856023c
SQS back-off policy (#1301)
* sqs retry policy

* add test

* method definition

* add validation

* rename policy

* add kombu doc

* improve docstring

* add test and doc

* test fix

* test fixes

* add doc

* Update docs/reference/kombu.transport.SQS.rst

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* Update docs/reference/kombu.transport.SQS.rst

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* Update kombu/transport/SQS.py

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* Update kombu/transport/SQS.py

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* Update kombu/transport/SQS.py

Co-authored-by: Omer Katz <omer.drow@gmail.com>

* review improvements

* improvements

* add improvements

* rename

Co-authored-by: galcohen <gal.cohen@autodesk.com>
Co-authored-by: Omer Katz <omer.drow@gmail.com>
Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
2021-03-02 12:22:47 +02:00
Terry Cain 90c6ac706e Fix issues with parsing URL with an extra / in it. 2021-01-06 21:57:40 +06:00
Terry Cain 3d41ab1389
Support for Azure Service Bus 7.0.0 (#1284)
* Started servicebus refactor

* Cleaned up, handle service bus SAS token parsing
2021-01-04 14:14:39 +01:00
AbdealiJK 6cb9d6639e redis: Support Sentinel with SSL
Use the SentinelManagedSSLConnection when SSL is enabled for the
transport. The redis-py project doesn't have a connection class for
SSL+Sentinel yet. So, create a class in redis.py to add that
functionality.
2020-12-03 12:50:15 +06:00
Vinay Karanam c70c115c2b Revert "on worker restart - restore visible regardless to time (#905)"
This reverts commit a307726faa.
2020-10-15 15:29:47 +06:00
Matus Valo faa1d86b52
Redis Transport: Small improvements of `SentinelChannel` (#1253)
* Redis Sentinel connection string now supports default sentinel port

* Raise ValueError when SentinelChannel is missing master_name transport option
2020-09-24 12:41:21 +03:00
Matus Valo 5b072fb171 Make flake8 happy 2020-08-17 10:16:05 +06:00
Matus Valo 1512c5d609 Removed case.skip 2020-08-17 10:16:05 +06:00
Matus Valo bd1a71215e Replace case.skip.if_win32 with pytest 2020-08-17 10:16:05 +06:00
Matus Valo f054205a5c Replace case.skip.SkipTest with pytest.skip 2020-08-17 10:16:05 +06:00
Matus Valo 410c815e44 Replaced case.skip.if_pypy and case.skip.if_python3 2020-08-17 10:16:05 +06:00
Matus Valo 20e2c45892 Use unittest.mock instead of case 2020-08-16 20:39:26 +06:00
Omer Katz 85578afc4f autopep8. 2020-08-04 17:37:29 +03:00
Omer Katz 2c75db39e0 Remove five usage from tests. 2020-07-23 16:33:40 +03:00
Omer Katz 7a6e7cc45b pyupgrade 2020-07-13 16:58:06 +03:00
Krzysztof Jagiello 016f4accb6 Add an SQS transport option for custom botocore config 2020-07-01 21:31:40 +06:00
Matus Valo 75027490c7
Revert incompatible changes in #1193 and additional improvements (#1211)
* Revert incompatible changes introduced in #1193

* Improved integration tests covering connection

* Fix unittests on python2 + flake8 fixes
2020-06-10 15:14:47 +06:00
Matus Valo 25a0266651 Ensure connection when connecting to broker 2020-06-01 12:56:32 +06:00
Ihar Nauros 5cc4a76882
Fix for issue #1198: Celery crashes in cases where there aren’t enough available workers to start acting on “in-flight” messages in the SQS queue (#1199)
* Fix for the issue #1172

* Unit test for the fix relating to the issue #1172

* Fix for issue #1198: Celery crashes in cases where there aren’t enough available workers to start acting on “in-flight” messages in the SQS queue

* Fix for issue #1198: fixed lint issues

* Fix for issue #1198: added unit tests

Co-authored-by: inauros <inauros@copyright.com>
2020-05-27 16:18:31 +06:00
Vinay Karanam 7fefb6fe9a Modified Mutex to use redis LuaLock implementation
Fixes #1190
2020-05-17 11:15:19 +06:00
Christian Clauss cca00b1c9d
Travis CI: Fix travis validation issues (#1159)
* Travis CI: Fix travis validation issues

* Whitespace fix for flake8 issue

* Whitespace fix for flake8 issue
2020-03-03 20:10:02 +06:00
Piyush Agarwal b22cb507a1
#1149 Enabled ssl certificate verification against ca certificates when amqps is used for pyamqp transport (#1151)
* enabled ssl certificate verification when amqps is used for pyamqp transport

* unit tests
2020-02-28 22:00:38 +06:00
Jonathan Ingram 5780f1e70b
Add predefined_queues option to SQS transport (#1156) 2020-02-26 09:09:38 +06:00
Shai Berger 16531285d5
Issue 701 (#1141)
* Make Redis-Mutex test fail as it should (#701)

See https://github.com/celery/kombu/issues/701

* Fix issue #701 - decode lock_id returned from Redis

Thanks @zaro
2020-02-02 21:10:56 +06:00
Konstantin Seleznev e1dcfaef4b
Adding retry_on_timeout parameter (#1150)
* added retry_on_timeout connparam

* added retry_on_timeout to tests

* updated Pyro4

* revert Pyro4 in requirements

* Trigger notification

* Trigger rebuild
2020-02-02 21:01:56 +06:00
Kevin Fox cbd327dc3b Add support for health_check_interval option in broker_transport_options. (#1145)
* Add support for health_check_interval option in broker_transport_options. #1114

* Added Keivn Fox to authors.

* Do not use default arg for pop() method.

* Add dedicated test case for configurable health_check

* Add test case for when health_check_interval is not supported by connection_class in redis.

* Fix Flake8

* Added more test cases for redis.

* Updated tests.
2020-01-11 11:20:31 +06:00