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

Fix history rollback command does not meet the expected result #2042

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dnf/cli/commands/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,26 @@ def _hcmd_rollback(self, extcmds):
else:
merged_trans.merge(trans)

tm = dnf.util.normalize_time(old.beg_timestamp)
print("Rollback to transaction %u, from %s" % (old.tid, tm))
print(self.output.fmtKeyValFill(" Undoing the following transactions: ",
", ".join((str(x) for x in merged_trans.tids()))))
self.output.historyInfoCmdPkgsAltered(merged_trans)
self._revert_transaction(merged_trans)

def _revert_transaction(self, trans):
action_map = {
"Install": "Removed",
"Removed": "Install",
"Upgrade": "Downgraded",
"Upgrade": None,
"Upgraded": "Downgrade",
"Downgrade": "Upgraded",
"Downgrade": None,
"Downgraded": "Upgrade",
"Reinstalled": "Reinstall",
"Reinstall": "Reinstalled",
"Reinstalled": None,
"Reinstall": None,
"Obsoleted": "Install",
"Obsolete": "Obsoleted",
"Reason Change": "Reason Change",
"Obsolete": None,
"Reason Change": None,
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I don't think this is right. It breaks the workflow when rolling back group and environment upgrades while reviewing test results. While the actual action appears to be executed, the group and environment reasons are not recorded in the history database. We need to rather investigate the root cause of the reproducer outlined in the issue.

}

data = serialize_transaction(trans)
Expand Down
7 changes: 7 additions & 0 deletions dnf/transaction_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,18 @@ def run(self):

for pkg_data in self._rpms:
try:
action = pkg_data["action"]
if action is None:
continue
Copy link
Member

Choose a reason for hiding this comment

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

This is also not correct, we would miss logging the unexpected state transitions.

self._replay_pkg_action(pkg_data)
except TransactionError as e:
errors.append(e)

for group_data in self._groups:
try:
action = group_data["action"]
if action is None:
continue
group_id = group_data["id"]

try:
Expand Down Expand Up @@ -576,6 +581,8 @@ def run(self):
for env_data in self._environments:
try:
action = env_data["action"]
if action is None:
continue
env_id = env_data["id"]

try:
Expand Down
Loading