-
Notifications
You must be signed in to change notification settings - Fork 145
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
base: main
Are you sure you want to change the base?
Handle guest logs #3602
Conversation
7c5376d
to
4a94317
Compare
tmt/steps/provision/mrack.py
Outdated
content = tmt.utils.get_url_content(self.url) | ||
except Exception: | ||
content = None | ||
return content |
There was a problem hiding this comment.
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
tmt/steps/provision/mrack.py
Outdated
@@ -1285,6 +1285,14 @@ def get_new_state() -> GuestInspectType: | |||
raise ProvisionError('Failed to create, provisioning failed.') | |||
|
|||
if state == 'Reserved': | |||
for key in response["logs"]: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
tmt/steps/provision/mrack.py
Outdated
) | ||
# console.log contains dmesg, and accessible even when the system is dead. | ||
self.guest_logs.append( | ||
GuestLogBeaker('dmesg', self, response["logs"]["console.log"]) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated: 3630473
tmt/steps/finish/__init__.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated: 3630473
Fetch log content,save it to provided location or current dir
4d93675
to
3630473
Compare
Fetch log content,save it to provided location or current dir
Pull Request Checklist