Skip to content

Commit

Permalink
logging_revamp: removing timer,daemon log files mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvoM committed Aug 9, 2023
1 parent 07fe958 commit e3d9592
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 118 deletions.
4 changes: 0 additions & 4 deletions apport/source_ubuntu-advantage-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ def add_info(report, ui=None):
"livepatch-status.txt-error",
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)
7 changes: 2 additions & 5 deletions features/attached_commands.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ 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
Then stdout matches regexp:
"""
/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
Expand Down Expand Up @@ -751,8 +748,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 verify that the timer interval for `update_messaging` is `21600`
Then I verify that running `sh -c journalctl -t ubuntu-pro-client-timer | grep "Invalid value for update_messaging interval found in config."` `with sudo` exits `0`
Then 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:
"""
Expand Down
10 changes: 0 additions & 10 deletions features/collect_logs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,9 +34,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 |
Expand All @@ -59,8 +54,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
Expand All @@ -87,9 +80,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
"""
Expand Down
65 changes: 29 additions & 36 deletions features/daemon.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<release>` 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
"""
Expand All @@ -94,7 +94,6 @@ 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
When I run `systemctl restart ubuntu-advantage.service` with sudo

# wait to get memory after it has settled/after startup checks
Expand All @@ -110,12 +109,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
"""
Expand Down Expand Up @@ -147,19 +146,18 @@ 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 `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
"""
Expand All @@ -169,12 +167,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
"""
Expand Down Expand Up @@ -214,16 +212,16 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary
Scenario Outline: daemon should run when appropriate on azure generic lts
Given a `<release>` 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
"""
Expand All @@ -246,16 +244,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
"""
Expand Down Expand Up @@ -283,16 +281,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 `<release>` 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
"""
Expand All @@ -313,7 +311,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
Expand All @@ -323,7 +320,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 |
Expand Down Expand Up @@ -351,15 +347,13 @@ 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:
"""
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 |
Expand All @@ -379,7 +373,6 @@ 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 `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:
Expand All @@ -388,8 +381,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
"""
Expand All @@ -401,8 +394,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
"""
Expand Down
3 changes: 0 additions & 3 deletions features/schemas/ua_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@
"log_file": {
"type": "string"
},
"timer_log_file": {
"type": "string"
},
"license_check_log_file": {
"type": "string"
},
Expand Down
6 changes: 0 additions & 6 deletions lib/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@

from systemd.daemon import notify # type: ignore

from uaclient import defaults, http
from systemd import journal # type: ignore
from uaclient.config import UAConfig
from uaclient.daemon import poll_for_pro_license, retry_auto_attach

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:
Expand Down
2 changes: 0 additions & 2 deletions lib/migrate_user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 1 addition & 9 deletions lib/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -24,10 +20,6 @@

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
Expand Down
2 changes: 0 additions & 2 deletions uaclient-devel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions uaclient/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,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,
*(
Expand Down
14 changes: 0 additions & 14 deletions uaclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
"log_level",
"security_url",
"settings_overrides",
"timer_log_file",
"daemon_log_file",
"ua_config",
"livepatch_url",
)
Expand Down Expand Up @@ -379,18 +377,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."""
Expand Down
Loading

0 comments on commit e3d9592

Please sign in to comment.