Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure pach_all for gevent worker happens before everything else #27546

Commits on Nov 7, 2022

  1. Make sure pach_all for gevent worker happens before everything else

    This change makes sure that gevent performs monkey_patching before
    everything else. Gevent should make sure to patch all the classes
    that are non-cooperative via gevent into cooperative ones and it
    should be done as the first thing in the forked gunicorn process.
    
    Usually GeventWorker does it automatically, however this happens
    after the configuration of gunicorn gets imported. In our case it
    means that it happens after airflow setting are loaded - and for
    example it means that if S3 remote logging is configured, then boto
    is initialzed before patch_all() and it breaks ssl that is patched
    by boto itself. Reversing the sequence and making gevent patches
    the ssl connection first, fixes the problem.
    
    We could convert airflow settings to local imports, but this
    does not guarantee a success because some of the initilization
    methods might be executed before GeventWorker starts and it is
    also prone to mistakes (adding top-level import to settings
    broke it at some point in time and it went unnoticed).
    
    This change does it slightly differently - in case of gevent
    worker, we use a different configuration for gunicorn and make
    sure that patch_all() is always executed first before any other
    import and initialization. This should fix the problem and be
    future-proof.
    
    Fixes: apache#8212
    potiuk committed Nov 7, 2022
    Configuration menu
    Copy the full SHA
    fb119b0 View commit details
    Browse the repository at this point in the history