Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle guest logs #3602

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Handle guest logs #3602

wants to merge 5 commits into from

Conversation

skycastlelily
Copy link
Collaborator

@skycastlelily skycastlelily commented Mar 14, 2025

Fetch log content,save it to provided location or current dir

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

@skycastlelily skycastlelily mentioned this pull request Mar 14, 2025
8 tasks
@skycastlelily skycastlelily added the ci | full test Pull request is ready for the full test execution label Mar 17, 2025
@skycastlelily skycastlelily added this to the 1.45 milestone Mar 17, 2025
@skycastlelily skycastlelily self-assigned this Mar 17, 2025
content = tmt.utils.get_url_content(self.url)
except Exception:
content = None
return content
Copy link
Collaborator

@happz happz Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the exception silently disappears. At least logging it as a waring would be nice (yep, that means we need to pass a logger to fetch() methods, which is fine).
  • content does not need to exist as a variable:
    try:
      return ...
    except Exception:
      return None

@@ -1285,6 +1285,14 @@ def get_new_state() -> GuestInspectType:
raise ProvisionError('Failed to create, provisioning failed.')

if state == 'Reserved':
for key in response["logs"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the key always exist? reponse.get('logs', []) might be safer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you could tell from the mrack code ,
we will always get logs, even if it is an empty list.
But just in case: )3630473

)
# console.log contains dmesg, and accessible even when the system is dead.
self.guest_logs.append(
GuestLogBeaker('dmesg', self, response["logs"]["console.log"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, is it guaranteed logs and console.log will always be present? Maybe we should be more defensive, check whether the keys exist, and emit warning if they don't.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated: 3630473

@@ -231,6 +231,7 @@ def go(self, force: bool = False) -> None:

# Stop and remove provisioned guests, even the partially provisioned ones.
for guest in self.plan.provision.guests:
guest.fetch_logs(logger=self._logger, guest_logs=guest.guest_logs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can omit guest_logs here, we want whatever logs the guest can offer, and self.guest_logs is the default list used by fetch_logs().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated: 3630473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci | full test Pull request is ready for the full test execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants