From c52cab84be6e55f72297e309766f40503e488154 Mon Sep 17 00:00:00 2001 From: Amanda McGuinness Date: Thu, 17 Sep 2020 14:23:32 +0000 Subject: [PATCH 1/6] Add warning messages to logs if StackStorm running with python 2 --- st2common/st2common/constants/error_messages.py | 7 ++++++- st2common/st2common/service_setup.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/st2common/st2common/constants/error_messages.py b/st2common/st2common/constants/error_messages.py index 0845de0ad2..3f054e739e 100644 --- a/st2common/st2common/constants/error_messages.py +++ b/st2common/st2common/constants/error_messages.py @@ -15,7 +15,8 @@ __all__ = [ 'PACK_VIRTUALENV_DOESNT_EXIST', - 'PACK_VIRTUALENV_USES_PYTHON3' + 'PACK_VIRTUALENV_USES_PYTHON3', + 'PYTHON2_DEPREATION' ] PACK_VIRTUALENV_DOESNT_EXIST = ''' @@ -32,3 +33,7 @@ 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.' diff --git a/st2common/st2common/service_setup.py b/st2common/st2common/service_setup.py index eb1577c630..d978f3a4a1 100644 --- a/st2common/st2common/service_setup.py +++ b/st2common/st2common/service_setup.py @@ -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 @@ -186,6 +187,10 @@ 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(): """ From 883ebedc599d71ac32250d929d1dc7a52875d92e Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 17 Sep 2020 19:59:30 +0100 Subject: [PATCH 2/6] Fix typo --- st2common/st2common/constants/error_messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st2common/st2common/constants/error_messages.py b/st2common/st2common/constants/error_messages.py index 3f054e739e..4f62aa05a7 100644 --- a/st2common/st2common/constants/error_messages.py +++ b/st2common/st2common/constants/error_messages.py @@ -16,7 +16,7 @@ __all__ = [ 'PACK_VIRTUALENV_DOESNT_EXIST', 'PACK_VIRTUALENV_USES_PYTHON3', - 'PYTHON2_DEPREATION' + 'PYTHON2_DEPRECATION' ] PACK_VIRTUALENV_DOESNT_EXIST = ''' From ccb16f2681eb8898a162626763de77971a468c43 Mon Sep 17 00:00:00 2001 From: Amanda McGuinness Date: Thu, 17 Sep 2020 19:28:26 +0000 Subject: [PATCH 3/6] Fix flake8 errors --- st2common/st2common/constants/error_messages.py | 7 ++++--- st2common/st2common/service_setup.py | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/st2common/st2common/constants/error_messages.py b/st2common/st2common/constants/error_messages.py index 4f62aa05a7..f7ba51b511 100644 --- a/st2common/st2common/constants/error_messages.py +++ b/st2common/st2common/constants/error_messages.py @@ -34,6 +34,7 @@ "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.' +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.' diff --git a/st2common/st2common/service_setup.py b/st2common/st2common/service_setup.py index d978f3a4a1..14cd708cca 100644 --- a/st2common/st2common/service_setup.py +++ b/st2common/st2common/service_setup.py @@ -191,7 +191,6 @@ def setup(service, config, setup_db=True, register_mq_exchanges=True, LOG.warning(PYTHON2_DEPRECATION) - def teardown(): """ Common teardown function. From 8d0ede99f9cb8def6fefd888816bca882203671d Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 17 Sep 2020 21:32:40 +0100 Subject: [PATCH 4/6] Add CHANGELOG --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 08619814cd..24bb091860 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ~~~~~~~ From 82b3279bff864233dce5b2fb6399c1a4b32ec75d Mon Sep 17 00:00:00 2001 From: Amanda McGuinness Date: Thu, 17 Sep 2020 22:19:15 +0100 Subject: [PATCH 5/6] Update error_messages.py --- st2common/st2common/constants/error_messages.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/st2common/st2common/constants/error_messages.py b/st2common/st2common/constants/error_messages.py index f7ba51b511..053ea71542 100644 --- a/st2common/st2common/constants/error_messages.py +++ b/st2common/st2common/constants/error_messages.py @@ -35,6 +35,9 @@ ''' 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.' + 'StackStorm releases. Please ensure that all packs used are python ' \ + '3 compatible. Your StackStorm installation may be upgraded from ' \ + 'python 2 to python 3 in future platform releases. It is recommended ' \ + 'to plan the manual migration to a python 3 native platform, e.g. ' \ + 'Ubuntu 18.04 LTS or CentOS/RHEL 8.' + From d7ce519249519f62b256d0350c728634ed139398 Mon Sep 17 00:00:00 2001 From: Amanda McGuinness Date: Thu, 17 Sep 2020 22:50:18 +0100 Subject: [PATCH 6/6] Fix Flake8 error --- st2common/st2common/constants/error_messages.py | 1 - 1 file changed, 1 deletion(-) diff --git a/st2common/st2common/constants/error_messages.py b/st2common/st2common/constants/error_messages.py index 053ea71542..749f7df659 100644 --- a/st2common/st2common/constants/error_messages.py +++ b/st2common/st2common/constants/error_messages.py @@ -40,4 +40,3 @@ 'python 2 to python 3 in future platform releases. It is recommended ' \ 'to plan the manual migration to a python 3 native platform, e.g. ' \ 'Ubuntu 18.04 LTS or CentOS/RHEL 8.' -