Kubernetes Node condition EtcdIsVoter

CMK version: Checkmk Enterprise Edition 2.2.0p21
OS version: Debian 12

Error message:

In K3s a new node condition has been added: EtcdIsVoter. It exposes the state of the node-local etcd instance.
CheckMK handles ETCDISVOTER: NodeConditionStatus.TRUE has a critical error, which is wrong as being a voter is the default case.

grafik

I tried to adapt the check, but only a fixed set of conditions can be reclassified:

I suggest to parse ETCDISVOTER: NodeConditionStatus.TRUE as success or allow custom node conditions to be changed via rules.

References:

We also raised it here. Its an inconsistent feature.
The only workaround is to ignore this condition which is not possible out of the box in 2.2.x.

You could try something like this:

Make a local copy of the kube_node_conditions.py file like this:

cp ~/lib/python3/cmk/base/plugins/agent_based/kube_node_conditions.py ~/local/lib/python3/cmk/base/plugins/agent_based/kube_node_conditions.py

Replace the parse_node_custom_conditions function completely:

def parse_node_custom_conditions(string_table: StringTable) -> NodeCustomConditions:
    """Parses `string_table` into a NodeCustomConditions instance"""
    return NodeCustomConditions(**json.loads(string_table[0][0]))

with the following:

def parse_node_custom_conditions(string_table: StringTable) -> NodeCustomConditions:
    """Parses `string_table` into a NodeCustomConditions instance"""
    node_custom_conditions = NodeCustomConditions(**json.loads(string_table[0][0]))
    return NodeCustomConditions(custom_conditions=[c for c in node_custom_conditions.custom_conditions if c.type_ != "EtcdIsVoter"])

followed by “omd reload apache” and let me know if this incosistent condition is ignored.

In 2.3, this is handled in a better way:

2 Likes

Thanks, that worked for me :+1: