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

Add warning messages to logs if StackStorm running with python 2 #5043

Merged
merged 6 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Added
Python 2. (new feature) #5037

Contributed by @amanda11
* Added deprecation warning to each StackStorm service log, if service is running with
Python 2. (new feature) #5043

Contributed by @amanda11


Changed
~~~~~~~
Expand Down
8 changes: 7 additions & 1 deletion st2common/st2common/constants/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

__all__ = [
'PACK_VIRTUALENV_DOESNT_EXIST',
'PACK_VIRTUALENV_USES_PYTHON3'
'PACK_VIRTUALENV_USES_PYTHON3',
'PYTHON2_DEPRECATION'
]

PACK_VIRTUALENV_DOESNT_EXIST = '''
Expand All @@ -32,3 +33,8 @@
virtual environment with python2 binary:
"st2 run packs.setup_virtualenv packs=%(pack)s python3=false"
'''

PYTHON2_DEPRECATION = 'DEPRECATION WARNING. Support for python 2 will be removed in future ' \
'StackStorm release(s). Please ensure that all packs used are python ' \
'3 compatible. Python 3 will already be used if you upgrade to a newer ' \
' OS release.'
4 changes: 4 additions & 0 deletions st2common/st2common/service_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from st2common.util import system_info
from st2common.services import coordination
from st2common.logging.misc import add_global_filters_for_all_loggers
from st2common.constants.error_messages import PYTHON2_DEPRECATION

# Note: This is here for backward compatibility.
# Function has been moved in a standalone module to avoid expensive in-direct
Expand Down Expand Up @@ -186,6 +187,9 @@ def setup(service, config, setup_db=True, register_mq_exchanges=True,
register_service_in_service_registry(service=service, capabilities=capabilities,
start_heart=True)

if sys.version_info[0] == 2:
LOG.warning(PYTHON2_DEPRECATION)


def teardown():
"""
Expand Down