Skip to content

Commit

Permalink
Turn reverting of comps upgrade into a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura committed Jun 5, 2024
1 parent 9eac7df commit 73647b7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
3 changes: 2 additions & 1 deletion include/libdnf5/base/goal_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ enum class GoalAction {
REPLAY_UPGRADE,
REPLAY_REINSTALL,
REPLAY_REASON_CHANGE,
REPLAY_REASON_OVERRIDE
REPLAY_REASON_OVERRIDE,
REVERT_COMPS_UPGRADE
};

/// Convert GoalAction enum to user-readable string
Expand Down
32 changes: 24 additions & 8 deletions libdnf5/base/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ GoalProblem Goal::Impl::add_specs_to_goal(base::Transaction & transaction) {
case GoalAction::REPLAY_REASON_OVERRIDE: {
libdnf_throw_assertion("Unsupported action \"REPLAY REASON OVERRIDE\"");
}
case GoalAction::REVERT_COMPS_UPGRADE: {
libdnf_throw_assertion("Unsupported action \"REVERT_COMPS_UPGRADE\"");
}
}
}
return ret;
Expand Down Expand Up @@ -2548,9 +2551,7 @@ GoalProblem Goal::Impl::resolve_reverted_transactions(base::Transaction & transa
group_replay.group_id = group.to_string();
// Do not revert UPGRADE for groups. Groups don't have an upgrade path so they cannot be
// upgraded or downgraded. The UPGRADE action is basically a synchronization with
// current group definition. Reverting synchronization is again synchronization but
// with the older group definition, this happens automatically by reverting the rpm
// actions. We only have to keep the UPGRADE action to have a record of the operation.
// current group definition. Revert happens automatically by reverting the rpm actions.
if (group.get_action() != transaction::TransactionItemAction::UPGRADE) {
auto reverted_action = REVERT_ACTION.find(group.get_action());
if (reverted_action == REVERT_ACTION.end()) {
Expand All @@ -2559,7 +2560,15 @@ GoalProblem Goal::Impl::resolve_reverted_transactions(base::Transaction & transa
}
group_replay.action = reverted_action->second;
} else {
group_replay.action = transaction::TransactionItemAction::UPGRADE;
transaction.p_impl->add_resolve_log(
GoalAction::REVERT_COMPS_UPGRADE,
libdnf5::GoalProblem::UNSUPPORTED_ACTION,
settings,
libdnf5::transaction::TransactionItemType::GROUP,
group_replay.group_id,
{},
libdnf5::Logger::Level::WARNING);
continue;
}

if (group_replay.action == Action::INSTALL && group.get_reason() == Reason::CLEAN) {
Expand All @@ -2578,9 +2587,8 @@ GoalProblem Goal::Impl::resolve_reverted_transactions(base::Transaction & transa
env_replay.environment_id = env.to_string();
// Do not revert UPGRADE for environments. Environments don't have an upgrade path so they cannot be
// upgraded or downgraded. The UPGRADE action is basically a synchronization with
// current environment definition. Reverting synchronization is again synchronization but
// with the older environment definition, this happens automatically by reverting the rpm
// actions. We only have to keep the UPGRADE action to have a record of the operation.
// current environment definition. Revert happens automatically by reverting the rpm
// actions.
if (env.get_action() != transaction::TransactionItemAction::UPGRADE) {
auto reverted_action = REVERT_ACTION.find(env.get_action());
if (reverted_action == REVERT_ACTION.end()) {
Expand All @@ -2589,7 +2597,15 @@ GoalProblem Goal::Impl::resolve_reverted_transactions(base::Transaction & transa
}
env_replay.action = reverted_action->second;
} else {
env_replay.action = transaction::TransactionItemAction::UPGRADE;
transaction.p_impl->add_resolve_log(
GoalAction::REVERT_COMPS_UPGRADE,
libdnf5::GoalProblem::UNSUPPORTED_ACTION,
settings,
libdnf5::transaction::TransactionItemType::ENVIRONMENT,
env_replay.environment_id,
{},
libdnf5::Logger::Level::WARNING);
continue;
}

replay.environments.push_back(env_replay);
Expand Down
2 changes: 2 additions & 0 deletions libdnf5/base/goal_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ std::string goal_action_to_string(GoalAction action) {
return "Reason change action";
case GoalAction::REPLAY_REASON_OVERRIDE:
return "Reason override";
case GoalAction::REVERT_COMPS_UPGRADE:
return "Revert comps upgrade";
}
return "";
}
Expand Down
7 changes: 7 additions & 0 deletions libdnf5/base/log_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ std::string LogEvent::to_string(
case GoalProblem::WRITE_DEBUG:
return ret.append(utils::sformat(_("Debug data written to \"{}\""), *additional_data.begin()));
case GoalProblem::UNSUPPORTED_ACTION:
if (action == GoalAction::REVERT_COMPS_UPGRADE) {
return ret.append(utils::sformat(
_("{} upgrade cannot be reverted, however associated package actions will be. ({} id: '{}') ."),
transaction_item_type_to_string(*spec_type),
transaction_item_type_to_string(*spec_type),
*spec));
}
return ret.append(utils::sformat(
_("{} action for argument \"{}\" is not supported."), goal_action_to_string(action), *spec));
case GoalProblem::MULTIPLE_STREAMS: {
Expand Down

0 comments on commit 73647b7

Please sign in to comment.