0

To improve resiliency, I converted my standalone redis deployment to a cluster of three Redis sentinels. I was able to connect Celery to the Redis Sentinel setup by modifying my Celery config to include

BROKER_URL = 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1.1.3:26379/0'

BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 32400, 'master_name': 'mymaster'}

The key to getting Celery to connect was to add the BROKER_TRANSPORT_OPTIONS and define the master_name as it was setup in my redis config.

I am also using Flower to monitor my Celery queues by running something like this:

celery flower --basic_auth=user1:pass123 --port=5555 --broker=redis://localhost:6379/0

But now that I have a Redis Sentinel deployment I think I need a way to pass the transport options for it connect successfully, otherwise if I do this:

celery flower --basic_auth=user1:pass123 --port=5555 -b 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1.1.3:26379/0' --debug

It simply hangs:

    [I 200427 13:01:36 command:139] Visit me at http://localhost:5555
[I 200427 13:01:36 command:144] Broker: sentinel://10.1.1.1:26379/0
[I 200427 13:01:36 command:147] Registered tasks:
    [u'celery.accumulate',
     u'celery.backend_cleanup',
     u'celery.chain',
     u'celery.chord',
     u'celery.chord_unlock',
     u'celery.chunks',
     u'celery.group',
     u'celery.map',
     u'celery.starmap']
[D 200427 13:01:36 command:149] Settings: {'cookie_secret': 'W0UNu/+hQLCUYD2smFhIBMo9nrJqn0ZimgrxxroGeSI=',
     'debug': True,
     'login_url': '/login',
     'static_path': '/usr/local/lib/python2.7/dist-packages/flower/static',
     'static_url_prefix': '/static/',
     'template_path': '/usr/local/lib/python2.7/dist-packages/flower/templates'}
[D 200427 13:01:36 control:29] Updating all worker's cache...

I understand that the BROKER_TRANSPORT_OPTIONS is a celery concept not flower, I tried the --conf option to pass in config with TRANSPORT config but it doesn't seem to pick it up.

Any help on this would be greatly appreciated. I scoured the celery and flower documentation to see how I can address this with no luck.

Amro Younes
  • 1,261
  • 2
  • 16
  • 34

1 Answers1

1

I resolved this issue by running flower from my Django directory where celery and flower are initiated and I was able to then use -A in my flower command line as such:

celery flower --basic_auth=user1:pass123 --port=5555 -b 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1.1.3:26379/0' --debug -A myappname

Once I did that, Flower was able to connect to my sentinels and I could see my tasks and queues.

Amro Younes
  • 1,261
  • 2
  • 16
  • 34