From a4c715c0ec1ae1158ce86fd56fcd0621e4cdeb7d Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Thu, 23 May 2024 15:24:39 -0500 Subject: [PATCH 1/4] Ensure tests that use logging.conf files have the required st2common code --- pants-plugins/macros.py | 31 +++++++++++++++++++++++++++ st2actions/conf/BUILD | 6 +++--- st2api/conf/BUILD | 8 +++---- st2auth/conf/BUILD | 8 +++---- st2reactor/conf/BUILD | 6 +++--- st2stream/conf/BUILD | 8 +++---- st2tests/conf/BUILD | 4 ++-- st2tests/st2tests/fixtures/conf/BUILD | 7 +++++- 8 files changed, 57 insertions(+), 21 deletions(-) diff --git a/pants-plugins/macros.py b/pants-plugins/macros.py index bc346a057b..c41d9b1f33 100644 --- a/pants-plugins/macros.py +++ b/pants-plugins/macros.py @@ -125,3 +125,34 @@ def st2_shell_sources_and_resources(**kwargs): kwargs["name"] += "_resources" resources(**kwargs) # noqa: F821 + + +# these are referenced by the logging.*.conf files. +_st2common_logging_deps = ( + "//st2common/st2common/log.py", + "//st2common/st2common/logging/formatters.py", +) + + +def st2_logging_conf_files(**kwargs): + """This creates a files target with logging dependencies.""" + deps = kwargs.pop("dependencies", []) or [] + deps = list(deps) + list(_st2common_logging_deps) + kwargs["dependencies"] = tuple(deps) + files(**kwargs) + + +def st2_logging_conf_file(**kwargs): + """This creates a file target with logging dependencies.""" + deps = kwargs.pop("dependencies", []) or [] + deps = list(deps) + list(_st2common_logging_deps) + kwargs["dependencies"] = tuple(deps) + file(**kwargs) + + +def st2_logging_conf_resources(**kwargs): + """This creates a resources target with logging dependencies.""" + deps = kwargs.pop("dependencies", []) or [] + deps = list(deps) + list(_st2common_logging_deps) + kwargs["dependencies"] = tuple(deps) + resources(**kwargs) diff --git a/st2actions/conf/BUILD b/st2actions/conf/BUILD index 42e57e0d5a..ee9257725e 100644 --- a/st2actions/conf/BUILD +++ b/st2actions/conf/BUILD @@ -1,9 +1,9 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -files( +st2_logging_conf_files( name="logging", sources=["logging*.conf"], overrides={ @@ -15,7 +15,7 @@ files( }, ) -files( +st2_logging_conf_files( name="logging_syslog", sources=["syslog*.conf"], ) diff --git a/st2api/conf/BUILD b/st2api/conf/BUILD index 9c3668885c..df77688843 100644 --- a/st2api/conf/BUILD +++ b/st2api/conf/BUILD @@ -1,19 +1,19 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -file( +st2_logging_conf_file( name="logging", source="logging.conf", ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", ) -file( +st2_logging_conf_file( name="logging_syslog", source="syslog.conf", ) diff --git a/st2auth/conf/BUILD b/st2auth/conf/BUILD index 8fd094d9fa..c1adc35ceb 100644 --- a/st2auth/conf/BUILD +++ b/st2auth/conf/BUILD @@ -8,22 +8,22 @@ file( source="htpasswd_dev", ) -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -file( +st2_logging_conf_file( name="logging", source="logging.conf", ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", ) -file( +st2_logging_conf_file( name="logging_syslog", source="syslog.conf", ) diff --git a/st2reactor/conf/BUILD b/st2reactor/conf/BUILD index 57246fe48d..8418a76e23 100644 --- a/st2reactor/conf/BUILD +++ b/st2reactor/conf/BUILD @@ -1,14 +1,14 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -files( +st2_logging_conf_files( name="logging", sources=["logging*.conf"], ) -files( +st2_logging_conf_files( name="logging_syslog", sources=["syslog*.conf"], ) diff --git a/st2stream/conf/BUILD b/st2stream/conf/BUILD index 9c3668885c..df77688843 100644 --- a/st2stream/conf/BUILD +++ b/st2stream/conf/BUILD @@ -1,19 +1,19 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -file( +st2_logging_conf_file( name="logging", source="logging.conf", ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", ) -file( +st2_logging_conf_file( name="logging_syslog", source="syslog.conf", ) diff --git a/st2tests/conf/BUILD b/st2tests/conf/BUILD index 72352b12b1..23af9ef7c9 100644 --- a/st2tests/conf/BUILD +++ b/st2tests/conf/BUILD @@ -8,12 +8,12 @@ file( source="st2_kvstore_tests.crypto.key.json", ) -file( +st2_logging_conf_file( name="logging.conf", source="logging.conf", ) -files( +st2_logging_conf_files( name="other_logging_conf", sources=["logging.*.conf"], ) diff --git a/st2tests/st2tests/fixtures/conf/BUILD b/st2tests/st2tests/fixtures/conf/BUILD index 5674cea485..545508803f 100644 --- a/st2tests/st2tests/fixtures/conf/BUILD +++ b/st2tests/st2tests/fixtures/conf/BUILD @@ -1,10 +1,15 @@ +st2_logging_conf_resources( + name="logging", + sources=["logging.*.conf"], +) + resources( name="st2.tests.conf", sources=[ "st2.tests*.conf", - "logging.*.conf", # used by st2.tests*.conf ], dependencies=[ + ":logging", # used by st2.tests*.conf "st2tests/conf:other_logging_conf", # depending on st2auth from st2tests is not nice. "st2auth/conf:htpasswd", From f478aba0afb7844dd4766abfbd047904c0da5de2 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Thu, 23 May 2024 23:41:48 -0500 Subject: [PATCH 2/4] satisfy pylint --- pants-plugins/macros.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pants-plugins/macros.py b/pants-plugins/macros.py index c41d9b1f33..11131f20ee 100644 --- a/pants-plugins/macros.py +++ b/pants-plugins/macros.py @@ -139,7 +139,7 @@ def st2_logging_conf_files(**kwargs): deps = kwargs.pop("dependencies", []) or [] deps = list(deps) + list(_st2common_logging_deps) kwargs["dependencies"] = tuple(deps) - files(**kwargs) + files(**kwargs) # noqa: F821 def st2_logging_conf_file(**kwargs): @@ -147,7 +147,7 @@ def st2_logging_conf_file(**kwargs): deps = kwargs.pop("dependencies", []) or [] deps = list(deps) + list(_st2common_logging_deps) kwargs["dependencies"] = tuple(deps) - file(**kwargs) + file(**kwargs) # noqa: F821 def st2_logging_conf_resources(**kwargs): @@ -155,4 +155,4 @@ def st2_logging_conf_resources(**kwargs): deps = kwargs.pop("dependencies", []) or [] deps = list(deps) + list(_st2common_logging_deps) kwargs["dependencies"] = tuple(deps) - resources(**kwargs) + resources(**kwargs) # noqa: F821 From 81e4bbfce758385179d1b0f35b544c2573a7fbd4 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Fri, 24 May 2024 12:29:57 -0500 Subject: [PATCH 3/4] pants: record logging conf (dev) dep on logs/ directory --- BUILD | 5 +++++ st2actions/conf/BUILD | 2 ++ st2api/conf/BUILD | 2 ++ st2auth/conf/BUILD | 2 ++ st2reactor/conf/BUILD | 1 + st2stream/conf/BUILD | 2 ++ 6 files changed, 14 insertions(+) diff --git a/BUILD b/BUILD index f8b1f03a4d..b2d06d15f9 100644 --- a/BUILD +++ b/BUILD @@ -51,3 +51,8 @@ file( shell_sources( name="root", ) + +file( + name="logs_directory", + source="logs/.gitignore", +) diff --git a/st2actions/conf/BUILD b/st2actions/conf/BUILD index ee9257725e..9d1bf2cc2b 100644 --- a/st2actions/conf/BUILD +++ b/st2actions/conf/BUILD @@ -6,9 +6,11 @@ st2_logging_conf_file( st2_logging_conf_files( name="logging", sources=["logging*.conf"], + dependencies=["//:logs_directory"], overrides={ "logging.conf": dict( dependencies=[ + "//:logs_directory", "//:reqs#python-json-logger", ], ), diff --git a/st2api/conf/BUILD b/st2api/conf/BUILD index df77688843..5fc903fd3b 100644 --- a/st2api/conf/BUILD +++ b/st2api/conf/BUILD @@ -6,11 +6,13 @@ st2_logging_conf_file( st2_logging_conf_file( name="logging", source="logging.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( diff --git a/st2auth/conf/BUILD b/st2auth/conf/BUILD index c1adc35ceb..3300d41753 100644 --- a/st2auth/conf/BUILD +++ b/st2auth/conf/BUILD @@ -16,11 +16,13 @@ st2_logging_conf_file( st2_logging_conf_file( name="logging", source="logging.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( diff --git a/st2reactor/conf/BUILD b/st2reactor/conf/BUILD index 8418a76e23..4f07917387 100644 --- a/st2reactor/conf/BUILD +++ b/st2reactor/conf/BUILD @@ -6,6 +6,7 @@ st2_logging_conf_file( st2_logging_conf_files( name="logging", sources=["logging*.conf"], + dependencies=["//:logs_directory"], ) st2_logging_conf_files( diff --git a/st2stream/conf/BUILD b/st2stream/conf/BUILD index df77688843..5fc903fd3b 100644 --- a/st2stream/conf/BUILD +++ b/st2stream/conf/BUILD @@ -6,11 +6,13 @@ st2_logging_conf_file( st2_logging_conf_file( name="logging", source="logging.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) st2_logging_conf_file( From 1180d1a81595f5ff6b69413994365fbea7c56a48 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 24 Sep 2024 20:51:40 -0500 Subject: [PATCH 4/4] update changelog entry --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29ebb59719..873f0e0757 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -56,7 +56,7 @@ Added * Continue introducing `pants `_ to improve DX (Developer Experience) working on StackStorm, improve our security posture, and improve CI reliability thanks in part to pants' use of PEX lockfiles. This is not a user-facing addition. - #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 + #6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 Contributed by @cognifloyd * Build of ST2 EL9 packages #6153 Contributed by @amanda11