Skip to content

Commit

Permalink
17221 FIX omd update: Do not trigger conflicts during stateful update
Browse files Browse the repository at this point in the history
SUP-21895
CMK-20945

Change-Id: I7641aa27cac2dd5ce083f681bb1dbf24b2889412
  • Loading branch information
SoloJacobs committed Jan 14, 2025
1 parent 9931cc1 commit a19f62d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .werks/17221.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[//]: # (werk v2)
# omd update: Do not trigger conflicts during stateful update

key | value
---------- | ---
date | 2025-01-13T08:16:03+00:00
version | 2.4.0b1
class | fix
edition | cre
component | omd
level | 2
compatible | yes

This change affects users, who run into conflicts while updating their site.

With this Werk, `omd` will automatically choose to continue the update once it is no longer safe to abort the update.

**Background**

In [#Werk 16408](https://checkmk.com/werk/16408), it was made possible to safely abort the update if a conflict occurs.
A conflict can occur due to different reasons, for example:

* An enabled MKPs raises an exception during the update.
* A ruleset is present, which cannot be loaded anymore.
* Files are installed in `local/lib/check_mk/plugins/agent_based`, and they will no longer be loaded in 2.4.0.

These conflicts need to be resolved, and will prompt the user on whether to continue the update (this behaviour can be changed by selecting a conflict mode).

However, the update should only be aborted, before the following message is shown:
```
Completed verifying site configuration. Your site now has version {version}.
```
This message marks the beginning of the stateful update.
If such a stateful update does not complete, it creates a broken site.

The verification steps, which detect conflicts, are executed a second time during the stateful update.

Previously, the verification steps would offer to abort the update.
This would happen even if the user confirmed to continue the update previously and despite the fact that it was no longer safe to abort the update.
3 changes: 2 additions & 1 deletion cmk/update_config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def _parse_arguments(args: Sequence[str]) -> argparse.Namespace:
type=ConflictMode,
help=(
f"If you choose '{ConflictMode.ASK}', you will need to manually answer all upcoming questions. "
f"With '{ConflictMode.INSTALL}' or '{ConflictMode.KEEP_OLD}' no interaction is needed. "
f"With '{ConflictMode.FORCE}', '{ConflictMode.INSTALL}' or '{ConflictMode.KEEP_OLD}' no interaction is needed. "
f"'{ConflictMode.FORCE}' continues the update even if errors occur during the pre-flight checks. "
f"If you choose '{ConflictMode.ABORT}', the update will be aborted if interaction is needed."
),
)
Expand Down
2 changes: 2 additions & 0 deletions cmk/update_config/plugins/lib/pagetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __call__(self, logger: Logger, conflict_mode: ConflictMode) -> None:

def _continue_per_users_choice(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
2 changes: 2 additions & 0 deletions cmk/update_config/plugins/pre_actions/agent_based_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def __call__(self, logger: Logger, conflict_mode: ConflictMode) -> None:

def _continue_per_users_choice(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
2 changes: 2 additions & 0 deletions cmk/update_config/plugins/pre_actions/legacy_check_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def __call__(self, logger: Logger, conflict_mode: ConflictMode) -> None:

def _continue_on_incomp_legacy_check(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
6 changes: 6 additions & 0 deletions cmk/update_config/plugins/pre_actions/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __call__(self, logger: Logger, conflict_mode: ConflictMode) -> None:

def _continue_on_broken_ruleset(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.UPDATE
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand All @@ -84,6 +86,8 @@ def _continue_on_broken_ruleset(conflict_mode: ConflictMode) -> Resume:

def _continue_on_invalid_rule(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand All @@ -96,6 +100,8 @@ def _continue_on_invalid_rule(conflict_mode: ConflictMode) -> Resume:

def _continue_on_ruleset_exception(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
2 changes: 2 additions & 0 deletions cmk/update_config/plugins/pre_actions/ui_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def __call__(self, logger: Logger, conflict_mode: ConflictMode) -> None:

def _continue_on_incomp_local_file(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
3 changes: 3 additions & 0 deletions cmk/update_config/plugins/pre_actions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ConflictMode(enum.StrEnum):
INSTALL = "install"
KEEP_OLD = "keepold"
ABORT = "abort"
FORCE = "force"


_USER_INPUT_ABORT: Final = ("a", "abort")
Expand Down Expand Up @@ -134,6 +135,8 @@ def disable_incomp_mkp(

def _request_user_input_on_incompatible_file(conflict_mode: ConflictMode) -> Resume:
match conflict_mode:
case ConflictMode.FORCE:
return Resume.UPDATE
case ConflictMode.ABORT:
return Resume.ABORT
case ConflictMode.INSTALL | ConflictMode.KEEP_OLD:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
cmk-update-config "--conflict" "$OMD_CONFLICT_MODE"
cmk-update-config "--conflict" force

0 comments on commit a19f62d

Please sign in to comment.