diff options
author | Alberto Contreras <alberto.contreras@canonical.com> | 2023-03-02 05:02:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 21:02:17 -0700 |
commit | 635b5a52590922668c13549d087723597a5cce7e (patch) | |
tree | 77ff1c7929f37a35435b6bb413ed86da8b0d0ece /cloudinit/config | |
parent | d781e14cd86cd85900a3c289ae5671ec6e77916f (diff) | |
download | cloud-init-git-635b5a52590922668c13549d087723597a5cce7e.tar.gz |
cc_ubuntu_advantage: improve UA logs discovery
- Use log_time context manager to wrap log UA-API calls
- Add a log msg pointing to UA logs
Diffstat (limited to 'cloudinit/config')
-rw-r--r-- | cloudinit/config/cc_ubuntu_advantage.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/cloudinit/config/cc_ubuntu_advantage.py b/cloudinit/config/cc_ubuntu_advantage.py index 9dd8f3a2..e4840a73 100644 --- a/cloudinit/config/cc_ubuntu_advantage.py +++ b/cloudinit/config/cc_ubuntu_advantage.py @@ -398,7 +398,11 @@ def _should_auto_attach(ua_section: dict) -> bool: # pylint: enable=import-error try: - result = should_auto_attach() + result = util.log_time( + logfunc=LOG.debug, + msg="Checking if the instance can be attached to Ubuntu Pro", + func=should_auto_attach, + ) except UserFacingError as ex: LOG.debug("Error during `should_auto_attach`: %s", ex) LOG.warning(ERROR_MSG_SHOULD_AUTO_ATTACH) @@ -440,7 +444,12 @@ def _auto_attach(ua_section: dict): enable_beta=enable_beta, ) try: - full_auto_attach(options=options) + util.log_time( + logfunc=LOG.debug, + msg="Attaching to Ubuntu Pro", + func=full_auto_attach, + kwargs={"options": options}, + ) except AlreadyAttachedError: if enable_beta is not None or enable is not None: # Only warn if the user defined some service to enable/disable. @@ -495,6 +504,9 @@ def handle( # ua-auto-attach.service had noop-ed as ua_section is not empty validate_schema_features(ua_section) + LOG.debug( + "To discover more log info, please check /var/log/ubuntu-advantage.log" + ) if _should_auto_attach(ua_section): _auto_attach(ua_section) |