From 279114c76cf6132e01d8e9393f7463678b96697d Mon Sep 17 00:00:00 2001 From: calvinmwadime Date: Mon, 31 Jul 2023 13:28:44 +0300 Subject: [PATCH] logging_revamp: removing timer,daemon log files mentions --- apport/source_ubuntu-advantage-tools.py | 5 +- features/attached_commands.feature | 7 +-- features/collect_logs.feature | 16 ++---- features/daemon.feature | 73 +++++++++++++------------ features/schemas/ua_status.json | 6 -- lib/daemon.py | 23 +++----- lib/migrate_user_config.py | 2 - lib/timer.py | 23 +++----- uaclient-devel.conf | 2 - uaclient/actions.py | 15 ++--- uaclient/config.py | 14 ----- uaclient/conftest.py | 5 -- uaclient/defaults.py | 4 -- uaclient/log.py | 9 +++ uaclient/tests/test_cli_collect_logs.py | 24 +++++--- uaclient/tests/test_config.py | 6 -- ubuntu-advantage.1 | 12 +--- 17 files changed, 94 insertions(+), 152 deletions(-) diff --git a/apport/source_ubuntu-advantage-tools.py b/apport/source_ubuntu-advantage-tools.py index f2c4f1aaef..6489d1db33 100644 --- a/apport/source_ubuntu-advantage-tools.py +++ b/apport/source_ubuntu-advantage-tools.py @@ -20,14 +20,11 @@ def add_info(report, ui=None): "ua-status.json-error", "livepatch-status.txt", "livepatch-status.txt-error", + "pro-journal.txt", os.path.basename(cfg.cfg_path), os.path.basename(cfg.log_file), - os.path.basename(cfg.timer_log_file), - os.path.basename(cfg.daemon_log_file), os.path.basename(cfg.data_path("jobs-status")), os.path.basename(defaults.CONFIG_DEFAULTS["log_file"]), - os.path.basename(defaults.CONFIG_DEFAULTS["timer_log_file"]), - os.path.basename(defaults.CONFIG_DEFAULTS["daemon_log_file"]), } for f in auto_include_log_files: attach_file_if_exists(report, os.path.join(output_dir, f), key=f) diff --git a/features/attached_commands.feature b/features/attached_commands.feature index e070270d5f..73a8041a34 100644 --- a/features/attached_commands.feature +++ b/features/attached_commands.feature @@ -38,7 +38,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription Then stdout matches regexp: """ /var/log/ubuntu-advantage.log - /var/log/ubuntu-advantage-timer.log """ When I run `logrotate --force /etc/logrotate.d/ubuntu-advantage-tools` with sudo And I run `sh -c "ls /var/log/ubuntu-advantage* | sort -d"` as non-root @@ -46,8 +45,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription """ /var/log/ubuntu-advantage.log /var/log/ubuntu-advantage.log.1 - /var/log/ubuntu-advantage-timer.log - /var/log/ubuntu-advantage-timer.log.1 """ Examples: ubuntu release @@ -744,8 +741,8 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription """ { "metering_timer": "notanumber", "update_messaging_timer": -10 } """ - And I run `python3 /usr/lib/ubuntu-advantage/timer.py` with sudo - Then I verify that running `grep "Invalid value for update_messaging interval found in config." /var/log/ubuntu-advantage-timer.log` `with sudo` exits `0` + And I run `systemctl start ua-timer.service` with sudo + Then I verify that running `sh -c 'journalctl -u ua-timer.service | grep "Invalid value for update_messaging interval found in config."'` `with sudo` exits `0` And I verify that the timer interval for `update_messaging` is `21600` And I verify that the timer interval for `metering` is `14400` When I create the file `/var/lib/ubuntu-advantage/jobs-status.json` with the following: diff --git a/features/collect_logs.feature b/features/collect_logs.feature index 4b4a9db3d8..89e4c58ba4 100644 --- a/features/collect_logs.feature +++ b/features/collect_logs.feature @@ -8,8 +8,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription # simulate logrotate When I run `touch /var/log/ubuntu-advantage.log.1` with sudo When I run `touch /var/log/ubuntu-advantage.log.2.gz` with sudo - When I run `touch /var/log/ubuntu-advantage-timer.log.1` with sudo - When I run `touch /var/log/ubuntu-advantage-timer.log.2.gz` with sudo When I run `pro collect-logs` with sudo Then I verify that files exist matching `ua_logs.tar.gz` When I run `tar zxf ua_logs.tar.gz` as non-root @@ -21,9 +19,10 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription """ build.info cloud-id.txt + cloud-init-journal.txt jobs-status.json - journalctl.txt livepatch-status.txt-error + pro-journal.txt systemd-timers.txt ua-auto-attach.path.txt(-error)? ua-auto-attach.service.txt(-error)? @@ -36,9 +35,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription ubuntu-advantage.log.1 ubuntu-advantage.log.2.gz ubuntu-advantage.service.txt - ubuntu-advantage-timer.log - ubuntu-advantage-timer.log.1 - ubuntu-advantage-timer.log.2.gz """ Examples: ubuntu release | release | @@ -59,8 +55,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription # simulate logrotate When I run `touch /var/log/ubuntu-advantage.log.1` with sudo When I run `touch /var/log/ubuntu-advantage.log.2.gz` with sudo - When I run `touch /var/log/ubuntu-advantage-timer.log.1` with sudo - When I run `touch /var/log/ubuntu-advantage-timer.log.2.gz` with sudo When I run `pro collect-logs` with sudo Then I verify that files exist matching `ua_logs.tar.gz` When I run `tar zxf ua_logs.tar.gz` as non-root @@ -72,9 +66,10 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription """ build.info cloud-id.txt + cloud-init-journal.txt jobs-status.json - journalctl.txt livepatch-status.txt-error + pro-journal.txt systemd-timers.txt ua-auto-attach.path.txt(-error)? ua-auto-attach.service.txt(-error)? @@ -87,9 +82,6 @@ Feature: Command behaviour when attached to an Ubuntu Pro subscription ubuntu-advantage.log.1 ubuntu-advantage.log.2.gz ubuntu-advantage.service.txt - ubuntu-advantage-timer.log - ubuntu-advantage-timer.log.1 - ubuntu-advantage-timer.log.2.gz ubuntu-esm-apps.list ubuntu-esm-infra.list """ diff --git a/features/daemon.feature b/features/daemon.feature index a5fc3276e7..3b52932d1b 100644 --- a/features/daemon.feature +++ b/features/daemon.feature @@ -61,16 +61,16 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Scenario Outline: daemon should run when appropriate on gcp generic lts Given a `` machine with ubuntu-advantage-tools installed # verify its enabled, but stops itself when not configured to poll - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout matches regexp: + Then stdout contains substring: """ Configured to not poll for pro license, shutting down """ - Then stdout matches regexp: + Then stdout contains substring: """ daemon ending """ @@ -94,7 +94,10 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary When I run `sed -i s/#DefaultMemoryAccounting=no/DefaultMemoryAccounting=yes/ /etc/systemd/system.conf` with sudo When I run `systemctl daemon-reexec` with sudo - When I run `truncate -s 0 /var/log/ubuntu-advantage-daemon.log` with sudo + # on bionic, systemd version=237; which does not allow for log rotation + vacuum in same line e.g. + # journalctl --flush --rotate --vacuum-time=1s + When I run `journalctl --flush --rotate` with sudo + When I run `journalctl --vacuum-time=1s` with sudo When I run `systemctl restart ubuntu-advantage.service` with sudo # wait to get memory after it has settled/after startup checks @@ -110,12 +113,12 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Then on `focal`, systemd status output says memory usage is less than `13` MB Then on `jammy`, systemd status output says memory usage is less than `14` MB - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout does not match regexp: + Then stdout does not contain substring: """ daemon ending """ @@ -147,19 +150,20 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary """ # verify detach starts it and it starts again after reboot - When I run `truncate -s 0 /var/log/ubuntu-advantage-daemon.log` with sudo + When I run `journalctl --flush --rotate` with sudo + When I run `journalctl --vacuum-time=1s` with sudo When I run `pro detach --assume-yes` with sudo Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `0` Then stdout matches regexp: """ Active: active \(running\) """ - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout does not match regexp: + Then stdout does not contain substring: """ daemon ending """ @@ -169,12 +173,12 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary """ Active: active \(running\) """ - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout does not match regexp: + Then stdout does not contain substring: """ daemon ending """ @@ -214,16 +218,16 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Scenario Outline: daemon should run when appropriate on azure generic lts Given a `` machine with ubuntu-advantage-tools installed # verify its enabled, but stops itself when not configured to poll - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout matches regexp: + Then stdout contains substring: """ Configured to not poll for pro license, shutting down """ - Then stdout matches regexp: + Then stdout contains substring: """ daemon ending """ @@ -246,16 +250,16 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary When I run `systemctl restart ubuntu-advantage.service` with sudo # give it time to get past the initial request When I wait `5` seconds - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout matches regexp: + Then stdout contains substring: """ Cancelling polling """ - Then stdout matches regexp: + Then stdout contains substring: """ daemon ending """ @@ -283,16 +287,16 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Scenario Outline: daemon does not start on gcp,azure generic non lts Given a `` machine with ubuntu-advantage-tools installed When I wait `1` seconds - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout matches regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout contains substring: """ daemon starting """ - Then stdout matches regexp: + Then stdout contains substring: """ Not on LTS, shutting down """ - Then stdout matches regexp: + Then stdout contains substring: """ daemon ending """ @@ -313,7 +317,6 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Active: inactive \(dead\) \s*Condition: start condition failed.* """ - Then I verify that running `cat /var/log/ubuntu-advantage-daemon.log` `with sudo` exits `1` When I attach `contract_token` with sudo When I run `pro detach --assume-yes` with sudo When I reboot the machine @@ -323,7 +326,6 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Active: inactive \(dead\) \s*Condition: start condition failed.* """ - Then I verify that running `cat /var/log/ubuntu-advantage-daemon.log` `with sudo` exits `1` Examples: version | release | | xenial | @@ -351,7 +353,6 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Active: inactive \(dead\) \s*Condition: start condition failed.* """ - Then I verify that running `cat /var/log/ubuntu-advantage-daemon.log` `with sudo` exits `1` When I reboot the machine Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `3` Then stdout matches regexp: @@ -359,7 +360,6 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary Active: inactive \(dead\) \s*Condition: start condition failed.* """ - Then I verify that running `cat /var/log/ubuntu-advantage-daemon.log` `with sudo` exits `1` Examples: version | release | | xenial | @@ -379,7 +379,8 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary log_file: /var/log/ubuntu-advantage.log """ When I run `pro auto-attach` with sudo - When I run `truncate -s 0 /var/log/ubuntu-advantage-daemon.log` with sudo + When I run `journalctl --flush --rotate` with sudo + When I run `journalctl --vacuum-time=1s` with sudo When I run `systemctl restart ubuntu-advantage.service` with sudo Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `3` Then stdout matches regexp: @@ -388,8 +389,8 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary \s*Condition: start condition failed.* .*ConditionPathExists=!/var/lib/ubuntu-advantage/private/machine-token.json was not met """ - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout does not match regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout does not contain substring: """ daemon starting """ @@ -401,8 +402,8 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary \s*Condition: start condition failed.* .*ConditionPathExists=!/var/lib/ubuntu-advantage/private/machine-token.json was not met """ - When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo - Then stdout does not match regexp: + When I run `journalctl -o cat -u ubuntu-advantage.service` with sudo + Then stdout does not contain substring: """ daemon starting """ diff --git a/features/schemas/ua_status.json b/features/schemas/ua_status.json index 4fe2695285..98c1dc18c6 100644 --- a/features/schemas/ua_status.json +++ b/features/schemas/ua_status.json @@ -209,12 +209,6 @@ "log_file": { "type": "string" }, - "timer_log_file": { - "type": "string" - }, - "license_check_log_file": { - "type": "string" - }, "ua_config": { "type": "object", "properties": { diff --git a/lib/daemon.py b/lib/daemon.py index d8aecda62c..2fccfd4289 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -4,28 +4,23 @@ from systemd.daemon import notify # type: ignore -from uaclient import defaults, http -from systemd import journal # type: ignore +from uaclient import http from uaclient.config import UAConfig from uaclient.daemon import poll_for_pro_license, retry_auto_attach +from uaclient.log import setup_journald_logging LOG = logging.getLogger("ubuntupro.daemon") -root_logger = logging.getLogger("ubuntupro") -LOG.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER="ubuntu-pro-client")) -root_logger.addHandler( - journal.JournalHandler(SYSLOG_IDENTIFIER="ubuntu-pro-client") -) def main() -> int: - LOG.setLevel(logging.DEBUG) - cfg = UAConfig() - LOG.setLevel(logging.DEBUG) - # The ua-daemon logger should log everything to its file - # Make sure the ua-daemon logger does not generate double logging - # by propagating to the root logger + setup_journald_logging(logging.DEBUG, LOG) + # Make sure the ubuntupro.daemon logger does not generate double logging LOG.propagate = False - root_logger.setLevel(logging.ERROR) + setup_journald_logging(logging.ERROR, logging.getLogger("ubuntupro")) + + cfg = UAConfig() + + http.configure_web_proxy(cfg.http_proxy, cfg.https_proxy) LOG.debug("daemon starting") diff --git a/lib/migrate_user_config.py b/lib/migrate_user_config.py index 3c12cb8383..cadd692c32 100644 --- a/lib/migrate_user_config.py +++ b/lib/migrate_user_config.py @@ -112,8 +112,6 @@ def create_new_uaclient_conffile(old_uaclient_conf): "data_dir", "log_file", "security_url", - "timer_log_file", - "daemon_log_file", ): old_val = old_uaclient_conf.get(field) if old_val is not None and old_val != defaults.CONFIG_DEFAULTS.get( diff --git a/lib/timer.py b/lib/timer.py index 5c98646659..9c9917e945 100644 --- a/lib/timer.py +++ b/lib/timer.py @@ -6,11 +6,7 @@ from datetime import datetime, timedelta, timezone from typing import Callable, Optional -from uaclient import defaults, http -from uaclient.cli import setup_logging - -from systemd import journal # type: ignore - +from uaclient import http from uaclient.config import UAConfig from uaclient.exceptions import InvalidFileFormatError from uaclient.files.state_files import ( @@ -18,16 +14,12 @@ TimerJobState, timer_jobs_state_file, ) +from uaclient.log import setup_journald_logging from uaclient.timer.metering import metering_enabled_resources from uaclient.timer.update_contract_info import update_contract_info from uaclient.timer.update_messaging import update_motd_messages LOG = logging.getLogger("ubuntupro.timer") -root_logger = logging.getLogger("ubuntupro") -LOG.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER="ubuntu-pro-client")) -root_logger.addHandler( - journal.JournalHandler(SYSLOG_IDENTIFIER="ubuntu-pro-client") -) UPDATE_MESSAGING_INTERVAL = 21600 # 6 hours METERING_INTERVAL = 14400 # 4 hours UPDATE_CONTRACT_INFO_INTERVAL = 86400 # 24 hours @@ -188,15 +180,14 @@ def run_jobs(cfg: UAConfig, current_time: datetime): if __name__ == "__main__": - LOG.setLevel(logging.DEBUG) + setup_journald_logging(logging.DEBUG, LOG) + # Make sure the ubuntupro.timer logger does not generate double logging + LOG.propagate = False + setup_journald_logging(logging.ERROR, logging.getLogger("ubuntupro")) + cfg = UAConfig() current_time = datetime.now(timezone.utc) - LOG.setLevel(logging.DEBUG) - # Make sure the ua-timer logger does not generate double logging - LOG.propagate = False - # The root logger should log any error to the timer log file http.configure_web_proxy(cfg.http_proxy, cfg.https_proxy) - root_logger.setLevel(logging.ERROR) run_jobs(cfg=cfg, current_time=current_time) diff --git a/uaclient-devel.conf b/uaclient-devel.conf index 8c04a02de9..05f7dc4e3c 100644 --- a/uaclient-devel.conf +++ b/uaclient-devel.conf @@ -4,5 +4,3 @@ data_dir: /var/tmp/uaclient log_file: ubuntu-advantage-devel.log log_level: debug security_url: https://ubuntu.com/security -timer_log_file: ubuntu-advantage-timer-devel.log -daemon_log_file: ubuntu-advantage-daemon-devel.log diff --git a/uaclient/actions.py b/uaclient/actions.py index 1e80981d18..ecb7c29d74 100644 --- a/uaclient/actions.py +++ b/uaclient/actions.py @@ -194,8 +194,6 @@ def _get_state_files(cfg: config.UAConfig): return [ cfg.cfg_path or DEFAULT_CONFIG_FILE, cfg.log_file, - cfg.timer_log_file, - cfg.daemon_log_file, timer_jobs_state_file.ua_file.path, CLOUD_BUILD_INFO, *( @@ -227,17 +225,20 @@ def collect_logs(cfg: config.UAConfig, output_dir: str): _write_command_output_to_file( ( "journalctl --boot=0 -o short-precise " - "{} " "-u cloud-init-local.service " - "-u cloud-init-config.service -u cloud-config.service" - ).format( + "-u cloud-init-config.service " + "-u cloud-config.service" + ), + "{}/cloud-init-journal.txt".format(output_dir), + ) + _write_command_output_to_file( + ("journalctl -o short-precise " "{}").format( " ".join( ["-u {}".format(s) for s in UA_SERVICES if ".service" in s] ) ), - "{}/journalctl.txt".format(output_dir), + "{}/pro-journal.txt".format(output_dir), ) - for service in UA_SERVICES: _write_command_output_to_file( "systemctl status {}".format(service), diff --git a/uaclient/config.py b/uaclient/config.py index 2e4cde583e..f9ea5e8ee4 100644 --- a/uaclient/config.py +++ b/uaclient/config.py @@ -65,8 +65,6 @@ "log_level", "security_url", "settings_overrides", - "timer_log_file", - "daemon_log_file", "ua_config", "livepatch_url", ) @@ -378,18 +376,6 @@ def log_level(self): def log_file(self) -> str: return self.cfg.get("log_file", CONFIG_DEFAULTS["log_file"]) - @property - def timer_log_file(self) -> str: - return self.cfg.get( - "timer_log_file", CONFIG_DEFAULTS["timer_log_file"] - ) - - @property - def daemon_log_file(self): - return self.cfg.get( - "daemon_log_file", CONFIG_DEFAULTS["daemon_log_file"] - ) - @property def features(self): """Return a dictionary of any features provided in uaclient.conf.""" diff --git a/uaclient/conftest.py b/uaclient/conftest.py index 4d30509bd5..95ee9a0f39 100644 --- a/uaclient/conftest.py +++ b/uaclient/conftest.py @@ -13,13 +13,8 @@ # Those need to be mocked here, before importing our modules, so the pytest # virtualenv doesn't cry because it can't find the modules m_apt_pkg = mock.MagicMock() -m_systemd_pkg = mock.MagicMock() -m_systemd_pkg.journal = mock.MagicMock() -m_systemd_pkg.journal.JournalHandler = mock.MagicMock() -m_systemd_pkg.journal.JournalHandler.return_value.level = logging.DEBUG sys.modules["apt"] = mock.MagicMock() sys.modules["apt_pkg"] = m_apt_pkg -sys.modules["systemd"] = m_systemd_pkg # Useless try/except to make flake8 happy \_("/)_/ try: diff --git a/uaclient/defaults.py b/uaclient/defaults.py index 3263073253..ca9be0ccf0 100644 --- a/uaclient/defaults.py +++ b/uaclient/defaults.py @@ -51,15 +51,11 @@ "data_dir": DEFAULT_DATA_DIR, "log_level": "debug", "log_file": "/var/log/ubuntu-advantage.log", - "timer_log_file": "/var/log/ubuntu-advantage-timer.log", - "daemon_log_file": "/var/log/ubuntu-advantage-daemon.log", } CONFIG_FIELD_ENVVAR_ALLOWLIST = [ "ua_data_dir", "ua_log_file", - "ua_timer_log_file", - "ua_daemon_log_file", "ua_log_level", "ua_security_url", ] diff --git a/uaclient/log.py b/uaclient/log.py index 0174f29472..05e658af2b 100644 --- a/uaclient/log.py +++ b/uaclient/log.py @@ -84,3 +84,12 @@ def get_all_user_log_files() -> List[str]: if os.path.isfile(user_path): log_files.append(user_path) return log_files + + +def setup_journald_logging(log_level, logger): + logger.setLevel(log_level) + logger.addFilter(RedactionFilter()) + console_handler = logging.StreamHandler() + console_handler.setFormatter(JsonArrayFormatter()) + console_handler.setLevel(log_level) + logger.addHandler(console_handler) diff --git a/uaclient/tests/test_cli_collect_logs.py b/uaclient/tests/test_cli_collect_logs.py index 9eb5feca3c..10d54c1d09 100644 --- a/uaclient/tests/test_cli_collect_logs.py +++ b/uaclient/tests/test_cli_collect_logs.py @@ -92,7 +92,7 @@ def test_collect_logs( tmpdir.join("user1-log").strpath, tmpdir.join("user2-log").strpath, ] - is_file_calls = 18 + is_file_calls = 16 user_log_files = [mock.call(m_get_user())] if util_we_are_currently_root(): user_log_files = [ @@ -115,6 +115,20 @@ def test_collect_logs( "-o", "short-precise", "-u", + "cloud-init-local.service", + "-u", + "cloud-init-config.service", + "-u", + "cloud-config.service", + ], + rcs=None, + ), + mock.call( + [ + "journalctl", + "-o", + "short-precise", + "-u", "ua-timer.service", "-u", "ua-auto-attach.service", @@ -122,12 +136,6 @@ def test_collect_logs( "ua-reboot-cmds.service", "-u", "ubuntu-advantage.service", - "-u", - "cloud-init-local.service", - "-u", - "cloud-init-config.service", - "-u", - "cloud-config.service", ], rcs=None, ), @@ -151,8 +159,6 @@ def test_collect_logs( assert m_isfile.call_args_list == [ mock.call("/etc/ubuntu-advantage/uaclient.conf"), mock.call(cfg.log_file), - mock.call("/var/log/ubuntu-advantage-timer.log"), - mock.call("/var/log/ubuntu-advantage-daemon.log"), mock.call("/var/lib/ubuntu-advantage/jobs-status.json"), mock.call("/etc/cloud/build.info"), mock.call("/etc/apt/sources.list.d/ubuntu-anbox-cloud.list"), diff --git a/uaclient/tests/test_config.py b/uaclient/tests/test_config.py index 0333ad2ecd..fa213d8f24 100644 --- a/uaclient/tests/test_config.py +++ b/uaclient/tests/test_config.py @@ -311,12 +311,10 @@ def test_data_path_returns_public_path_for_public_datapath( # picked up by Ubuntu Pro client. contract_url: https://contracts.canonical.com -daemon_log_file: /var/log/ubuntu-advantage-daemon.log data_dir: /var/lib/ubuntu-advantage log_file: /var/log/ubuntu-advantage.log log_level: debug security_url: https://ubuntu.com/security -timer_log_file: /var/log/ubuntu-advantage-timer.log """ CFG_FEATURES_CONTENT = """\ @@ -325,7 +323,6 @@ def test_data_path_returns_public_path_for_public_datapath( # picked up by Ubuntu Pro client. contract_url: https://contracts.canonical.com -daemon_log_file: /var/log/ubuntu-advantage-daemon.log data_dir: /var/lib/ubuntu-advantage features: extra_security_params: @@ -338,7 +335,6 @@ def test_data_path_returns_public_path_for_public_datapath( settings_overrides: c: 1 d: 2 -timer_log_file: /var/log/ubuntu-advantage-timer.log """ USER_CFG_DICT = { @@ -1004,8 +1000,6 @@ def test_parse_config_uses_defaults_when_no_config_present( "security_url": "https://ubuntu.com/security", "data_dir": "/var/lib/ubuntu-advantage", "log_file": "/var/log/ubuntu-advantage.log", - "timer_log_file": "/var/log/ubuntu-advantage-timer.log", - "daemon_log_file": "/var/log/ubuntu-advantage-daemon.log", # noqa: E501 "log_level": "debug", } assert expected_default_config == config diff --git a/ubuntu-advantage.1 b/ubuntu-advantage.1 index 4c7f435610..cda09fe759 100644 --- a/ubuntu-advantage.1 +++ b/ubuntu-advantage.1 @@ -197,14 +197,6 @@ The logging level used when writing to \fBlog_file\fP .B \fBlog_file\fP The log file for the Ubuntu Pro client cli -.TP -.B -\fBtimer_log_file\fP -The log file for the Ubuntu Pro timer and timer jobs -.TP -.B -\fBdaemon_log_file\fP -The log file for the Ubuntu Pro daemon .P \fBThe following options are set using the `pro config set` subcommand:\fP @@ -271,8 +263,8 @@ username and password in the URL itself, as in: Additionally, some configuration options can be overridden in the environment by setting an environment variable prefaced by \fBUA_\fP. Both uppercase and lowercase environment variables are allowed. The configuration -options that support this are: data_dir, log_file, timer_log_file, -daemon_log_file, log_level, and security_url. +options that support this are: data_dir, log_file, log_level, +and security_url. For example, the following overrides the log_level found in uaclient.conf: .PP