Skip to content

Commit cb3c9be

Browse files
authored
Merge pull request #5043 from StackStorm/py2_warning_logs
Add warning messages to logs if StackStorm running with python 2
2 parents f17e0b0 + d7ce519 commit cb3c9be

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Added
2323
Python 2. (new feature) #5037
2424

2525
Contributed by @amanda11
26+
* Added deprecation warning to each StackStorm service log, if service is running with
27+
Python 2. (new feature) #5043
28+
29+
Contributed by @amanda11
30+
2631

2732
Changed
2833
~~~~~~~

st2common/st2common/constants/error_messages.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
__all__ = [
1717
'PACK_VIRTUALENV_DOESNT_EXIST',
18-
'PACK_VIRTUALENV_USES_PYTHON3'
18+
'PACK_VIRTUALENV_USES_PYTHON3',
19+
'PYTHON2_DEPRECATION'
1920
]
2021

2122
PACK_VIRTUALENV_DOESNT_EXIST = '''
@@ -32,3 +33,10 @@
3233
virtual environment with python2 binary:
3334
"st2 run packs.setup_virtualenv packs=%(pack)s python3=false"
3435
'''
36+
37+
PYTHON2_DEPRECATION = 'DEPRECATION WARNING. Support for python 2 will be removed in future ' \
38+
'StackStorm releases. Please ensure that all packs used are python ' \
39+
'3 compatible. Your StackStorm installation may be upgraded from ' \
40+
'python 2 to python 3 in future platform releases. It is recommended ' \
41+
'to plan the manual migration to a python 3 native platform, e.g. ' \
42+
'Ubuntu 18.04 LTS or CentOS/RHEL 8.'

st2common/st2common/service_setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from st2common.util import system_info
4343
from st2common.services import coordination
4444
from st2common.logging.misc import add_global_filters_for_all_loggers
45+
from st2common.constants.error_messages import PYTHON2_DEPRECATION
4546

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

190+
if sys.version_info[0] == 2:
191+
LOG.warning(PYTHON2_DEPRECATION)
192+
189193

190194
def teardown():
191195
"""

0 commit comments

Comments
 (0)