Skip to content

Commit

Permalink
EC: add micro type fixes found by pyright
Browse files Browse the repository at this point in the history
Change-Id: I7fa31a3e206d469606283aa3c9c64e3d6dc8094f
  • Loading branch information
Konstantin Baikov committed May 16, 2024
1 parent d2133ef commit c24a8fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmk/ec/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3219,6 +3219,7 @@ def get_state_from_master(config: Config, slave_status: SlaveStatus) -> Any:
repl_settings = config["replication"]
if repl_settings is None:
raise ValueError("no replication settings")
response_text = b""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(repl_settings["connect_timeout"])
Expand All @@ -3228,7 +3229,6 @@ def get_state_from_master(config: Config, slave_status: SlaveStatus) -> Any:
)
sock.shutdown(socket.SHUT_WR)

response_text = b""
while True:
chunk = sock.recv(8192)
response_text += chunk
Expand Down
17 changes: 10 additions & 7 deletions cmk/ec/rule_packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@

from .config import (
ConfigFromWATO,
ContactGroups,
ECRulePack,
ECRulePackSpec,
LogConfig,
MkpRulePackBindingError,
MkpRulePackProxy,
ServiceLevel,
)
from .defaults import default_config, default_rule_pack
from .settings import create_paths, Settings
Expand Down Expand Up @@ -134,17 +137,17 @@ def _load_config( # pylint: disable=too-many-branches
for rule in rule_pack["rules"]:
# Convert old contact_groups config
if isinstance(rule.get("contact_groups"), list):
rule["contact_groups"] = {
"groups": rule["contact_groups"],
"notify": False,
"precedence": "host",
}
rule["contact_groups"] = ContactGroups(
groups=rule["contact_groups"],
notify=False,
precedence="host",
)
# Old configs only have a naked service level without a precedence.
if isinstance(rule["sl"], int):
rule["sl"] = {"value": rule["sl"], "precedence": "message"}
rule["sl"] = ServiceLevel(value=rule["sl"], precedence="message")

# Convert old logging configurations
levels = config["log_level"]
levels: LogConfig = config["log_level"]
if isinstance(levels, int): # TODO: Move this to upgrade time
level = logging.INFO if levels == 0 else cmk.utils.log.VERBOSE # type: ignore[unreachable]
levels = {
Expand Down

0 comments on commit c24a8fb

Please sign in to comment.