Skip to content

Commit d20a6be

Browse files
cerealsnowske-prow[bot]
authored andcommitted
systemdunitcheck: Do not report unhealthy status for a disabled unit that is in failed state
Signed-off-by: cerealsnow <13483299+cerealsnow@users.noreply.github.com> This commit can be dropped when upgrading to a gardener version that contains this bugfix.
1 parent 9891c43 commit d20a6be

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

pkg/nodeagent/controller/systemdunitcheck/reconciler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ func (r *Reconciler) checkUnits(ctx context.Context, units []unitInfo) (unhealth
168168
}
169169

170170
case "failed":
171-
unhealthyMessages = append(unhealthyMessages, fmt.Sprintf("%s: failed", unit.name))
171+
// Only enabled units should be marked as erroring in case they are in a failed state.
172+
if unit.enabled {
173+
unhealthyMessages = append(unhealthyMessages, fmt.Sprintf("%s: failed", unit.name))
174+
}
172175

173176
case "activating", "deactivating":
174177
// Services configured with Restart=always/on-success cycle through "activating (auto-restart)"

test/integration/nodeagent/systemdunitcheck/systemdunitcheck_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,28 @@ var _ = Describe("SystemdUnitCheck controller tests", func() {
302302
})))
303303
})
304304

305+
It("should not report unhealthy for a disabled unit that is in a failed state", func() {
306+
writeOSC(&extensionsv1alpha1.OperatingSystemConfig{
307+
Spec: extensionsv1alpha1.OperatingSystemConfigSpec{
308+
Units: []extensionsv1alpha1.Unit{
309+
{Name: "optional.service", Enable: ptr.To(false)},
310+
},
311+
},
312+
})
313+
314+
fakeDBus.AddUnitsToList(
315+
systemddbus.UnitStatus{Name: "optional.service", ActiveState: "failed"},
316+
)
317+
318+
Eventually(func(g Gomega) *corev1.NodeCondition {
319+
return getNodeCondition(g)
320+
}).Should(PointTo(MatchFields(IgnoreExtras, Fields{
321+
"Type": Equal(nodeagentconfigv1alpha1.ConditionTypeSystemdUnitsReady),
322+
"Status": Equal(corev1.ConditionTrue),
323+
"Reason": Equal("AllUnitsHealthy"),
324+
})))
325+
})
326+
305327
It("should also monitor gardener-node-agent's own units", func() {
306328
writeOSC(&extensionsv1alpha1.OperatingSystemConfig{
307329
Spec: extensionsv1alpha1.OperatingSystemConfigSpec{

0 commit comments

Comments
 (0)