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/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 diff --git a/pants-plugins/macros.py b/pants-plugins/macros.py index bc346a057b..11131f20ee 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) # noqa: F821 + + +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) # noqa: F821 + + +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) # noqa: F821 diff --git a/st2actions/conf/BUILD b/st2actions/conf/BUILD index 42e57e0d5a..9d1bf2cc2b 100644 --- a/st2actions/conf/BUILD +++ b/st2actions/conf/BUILD @@ -1,21 +1,23 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -files( +st2_logging_conf_files( name="logging", sources=["logging*.conf"], + dependencies=["//:logs_directory"], overrides={ "logging.conf": dict( dependencies=[ + "//:logs_directory", "//:reqs#python-json-logger", ], ), }, ) -files( +st2_logging_conf_files( name="logging_syslog", sources=["syslog*.conf"], ) diff --git a/st2api/conf/BUILD b/st2api/conf/BUILD index 9c3668885c..5fc903fd3b 100644 --- a/st2api/conf/BUILD +++ b/st2api/conf/BUILD @@ -1,19 +1,21 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -file( +st2_logging_conf_file( name="logging", source="logging.conf", + dependencies=["//:logs_directory"], ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) -file( +st2_logging_conf_file( name="logging_syslog", source="syslog.conf", ) diff --git a/st2auth/conf/BUILD b/st2auth/conf/BUILD index 8fd094d9fa..3300d41753 100644 --- a/st2auth/conf/BUILD +++ b/st2auth/conf/BUILD @@ -8,22 +8,24 @@ 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", + dependencies=["//:logs_directory"], ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) -file( +st2_logging_conf_file( name="logging_syslog", source="syslog.conf", ) diff --git a/st2reactor/conf/BUILD b/st2reactor/conf/BUILD index 57246fe48d..4f07917387 100644 --- a/st2reactor/conf/BUILD +++ b/st2reactor/conf/BUILD @@ -1,14 +1,15 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -files( +st2_logging_conf_files( name="logging", sources=["logging*.conf"], + dependencies=["//:logs_directory"], ) -files( +st2_logging_conf_files( name="logging_syslog", sources=["syslog*.conf"], ) diff --git a/st2stream/conf/BUILD b/st2stream/conf/BUILD index 9c3668885c..5fc903fd3b 100644 --- a/st2stream/conf/BUILD +++ b/st2stream/conf/BUILD @@ -1,19 +1,21 @@ -file( +st2_logging_conf_file( name="logging_console", source="console.conf", ) -file( +st2_logging_conf_file( name="logging", source="logging.conf", + dependencies=["//:logs_directory"], ) -file( +st2_logging_conf_file( name="logging_gunicorn", source="logging.gunicorn.conf", + dependencies=["//:logs_directory"], ) -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",