Skip to content

Commit

Permalink
Remove repeated activation call to prevent confusing log message
Browse files Browse the repository at this point in the history
The previous logic triggered the activation twice, even when no issue
occured. This lead to this message in the log:

```
rest-session:openapi_session.py:126 < [422] {"title": "The operation has
failed.", "status": 422, "detail": "Currently there are no changes to
activate."}
```

Change-Id: I273f7044ff6c7086909a7140845d676c25cc9fb7
  • Loading branch information
LarsMichelsen committed Jul 11, 2024
1 parent 7390be3 commit c5269f9
Showing 1 changed file with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

import time
from contextlib import suppress
from pathlib import Path

Expand All @@ -15,23 +14,6 @@
from cmk.utils.hostaddress import HostName


def _activate_changes_and_wait_for_completion_with_retries(site: Site) -> None:
"""The CMC might be started, but not quite ready. Retry a couple of times.
Since we added valgrind in c024fd3ebcc the initialization of the core takes longer.
Livestatus might not be available for an "activate changes" shortly after a core restart (as during host renaming).
"""
for _atempt in range(10):
try:
site.openapi.activate_changes_and_wait_for_completion()
return
except UnexpectedResponse: # kind of 'expected' after all
time.sleep(1)

# try once more to reveal the exception
site.openapi.activate_changes_and_wait_for_completion()


def _test_rename_preserves_registration(
*,
central_site: Site,
Expand Down Expand Up @@ -59,7 +41,7 @@ def _test_rename_preserves_registration(
hostname_new=new_hostname,
etag=response_create.headers["ETag"],
)
_activate_changes_and_wait_for_completion_with_retries(central_site)
central_site.openapi.activate_changes_and_wait_for_completion()
controller_status = controller_status_json(agent_ctl)
try:
assert (
Expand Down

0 comments on commit c5269f9

Please sign in to comment.