Skip to content

Commit 5bb3715

Browse files
committed
19304 kube_pod_conditions: Support PodResizePending and PodResizeInProgress PodConditions
The Kubernetes check plugin `kube_pod_conditions` now supports two additional PodConditions: - `PodResizePending` - `PodResizeInProgress` Information about these conditions can be found in the upstream Kubernetes [documentation](https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#pod-resize-status). Levels for these can be set in the ruleset "Kubernetes pod conditions". In constrast to the monitored PodConditions up until now, alerting will happen when these new conditions are _true_ for too long, rather than when they are _false_ for too long. -- End of Werk text -- CMK-28951 Change-Id: I4b58c372450a5a8c2c41483e2ac65b6999ad49dc
1 parent 92608d0 commit 5bb3715

File tree

8 files changed

+232
-68
lines changed

8 files changed

+232
-68
lines changed

.werks/19304.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[//]: # (werk v3)
2+
# kube_pod_conditions: Support PodResizePending and PodResizeInProgress PodConditions
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-02-13T12:02:26+00:00
7+
version | 2.5.0b1
8+
class | feature
9+
edition | community
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
The Kubernetes check plugin `kube_pod_conditions` now supports two additional
15+
PodConditions:
16+
17+
- `PodResizePending`
18+
- `PodResizeInProgress`
19+
20+
Information about these conditions can be found in the upstream Kubernetes
21+
[documentation](https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#pod-resize-status).
22+
23+
Levels for these can be set in the ruleset "Kubernetes pod conditions".
24+
25+
In contrast to the monitored PodConditions up until now, alerting will happen
26+
when these new conditions are _true_ for too long, rather than when they are
27+
_false_ for too long.
28+
29+
This allows you to be notified when a resize has been ongoing for an extended
30+
period of time, or when it cannot be carried out for some reason.

cmk/gui/plugins/wato/check_parameters/kube_pod_conditions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,23 @@ def _parameter_valuespec():
4848
"ready",
4949
age_levels_dropdown(_("Time until alert, if READY condition is false")),
5050
),
51+
(
52+
"resizepending",
53+
age_levels_dropdown(_("Time until alert, if RESIZEPENDING condition is true")),
54+
),
55+
(
56+
"resizeinprogress",
57+
age_levels_dropdown(_("Time until alert, if RESIZEINPROGRESS condition is true")),
58+
),
59+
],
60+
optional_keys=[
61+
"initialized",
62+
"scheduled",
63+
"containersready",
64+
"ready",
65+
"resizepending",
66+
"resizeinprogress",
5167
],
52-
optional_keys=["initialized", "scheduled", "containersready", "ready"],
5368
)
5469

5570

packages/cmk-plugins/cmk/plugins/kube/agent_based/kube_pod_conditions.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ def discovery(section: PodConditions) -> DiscoveryResult:
3737

3838

3939
def _check_condition(
40-
now: float, name: str, cond: PodCondition | None, levels_upper: tuple[int, int] | None
40+
now: float,
41+
name: str,
42+
cond: PodCondition | None,
43+
levels_upper: tuple[int, int] | None,
44+
invert: bool = False, # if True, alert when the condition is *False*
4145
) -> CheckResult:
4246
if cond is not None:
4347
# keep the last-seen one
4448
time_diff = now - cond.last_transition_time # type: ignore[operator] # SUP-12170
45-
if cond.status:
49+
if (not invert and cond.status) or (invert and not cond.status):
4650
# TODO: CMK-11697
4751
yield Result(state=State.OK, summary=condition_short_description(name, cond.status))
4852
return
@@ -100,6 +104,22 @@ def _check(now: float, params: Mapping[str, VSResultAge], section: PodConditions
100104
section.ready,
101105
get_age_levels_for(params, "ready"),
102106
)
107+
if section.resizepending is not None: # v1.33+
108+
yield from _check_condition(
109+
now,
110+
"resizepending",
111+
section.resizepending,
112+
get_age_levels_for(params, "resizepending"),
113+
invert=True,
114+
)
115+
if section.resizeinprogress is not None: # v1.33+
116+
yield from _check_condition(
117+
now,
118+
"resizeinprogress",
119+
section.resizeinprogress,
120+
get_age_levels_for(params, "resizeinprogress"),
121+
invert=True,
122+
)
103123
if (disruptiontarget := section.disruptiontarget) is not None:
104124
yield Result(
105125
state=State.OK,
@@ -133,6 +153,8 @@ def check(params: Mapping[str, VSResultAge], section: PodConditions) -> CheckRes
133153
"initialized": "no_levels",
134154
"containersready": "no_levels",
135155
"ready": "no_levels",
156+
"resizepending": ("levels", (300, 600)),
157+
"resizeinprogress": ("levels", (300, 600)),
136158
},
137159
check_ruleset_name="kube_pod_conditions",
138160
)

packages/cmk-plugins/cmk/plugins/kube/checkman/kube_pod_conditions

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ catalog: containerization/kubernetes
44
license: GPLv2
55
distribution: check_mk
66
description:
7-
A pod's status depends on an array of PodConditions through which the
7+
A Pod's status depends on an array of PodConditions through which the
88
Pod has or has not yet passed. This check monitors the status of each
9-
condition (scheduled, initialized, containersready and ready) and the
10-
duration if the condition has not yet passed. This check does not
9+
condition (scheduled, initialized, containersready and ready, along with
10+
resizepending and resizeinprogress as of Kubernetes v1.33) and the
11+
duration of the condition if it is in an abnormal state. This check does not
1112
monitor custom conditions.
1213

13-
Upper levels for {WARN}/{CRIT} can be defined for time until a
14-
condition is not yet passed.
14+
Upper levels for WARN/CRIT can be defined to determine how much time must pass
15+
before an alert is triggered when a condition is in an abnormal state for an
16+
extended period of time.
1517

1618
discovery:
1719
One service is created representing pod conditions.

packages/cmk-plugins/cmk/plugins/kube/schemata/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ class ConditionType(str, enum.Enum):
830830
INITIALIZED = "initialized"
831831
READY = "ready"
832832
DISRUPTIONTARGET = "disruptiontarget"
833+
PODRESIZEPENDING = "resizepending"
834+
PODRESIZEINPROGRESS = "resizeinprogress"
833835

834836

835837
class PodCondition(BaseModel):

packages/cmk-plugins/cmk/plugins/kube/schemata/section.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ class PodConditions(Section):
286286
containersready: PodCondition | None = Field(None)
287287
ready: PodCondition | None = Field(None)
288288
disruptiontarget: PodCondition | None = Field(None)
289+
# https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#pod-resize-status
290+
resizepending: PodCondition | None = Field(None)
291+
resizeinprogress: PodCondition | None = Field(None)
289292

290293

291294
class PodContainers(Section):

packages/cmk-plugins/cmk/plugins/kube/transform.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def pod_conditions(
201201
"ContainersReady": api.ConditionType.CONTAINERSREADY,
202202
"Ready": api.ConditionType.READY,
203203
"DisruptionTarget": api.ConditionType.DISRUPTIONTARGET,
204+
"PodResizePending": api.ConditionType.PODRESIZEPENDING,
205+
"PodResizeInProgress": api.ConditionType.PODRESIZEINPROGRESS,
204206
}
205207
result = []
206208
for condition in conditions:

0 commit comments

Comments
 (0)