Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/nodeagent/controller/systemdunitcheck/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ func (r *Reconciler) checkUnits(ctx context.Context, units []unitInfo) (unhealth
}

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

case "activating", "deactivating":
// Services configured with Restart=always/on-success cycle through "activating (auto-restart)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,28 @@ var _ = Describe("SystemdUnitCheck controller tests", func() {
})))
})

It("should not report unhealthy for a disabled unit that is in a failed state", func() {
writeOSC(&extensionsv1alpha1.OperatingSystemConfig{
Spec: extensionsv1alpha1.OperatingSystemConfigSpec{
Units: []extensionsv1alpha1.Unit{
{Name: "optional.service", Enable: ptr.To(false)},
},
},
})

fakeDBus.AddUnitsToList(
systemddbus.UnitStatus{Name: "optional.service", ActiveState: "failed"},
)

Eventually(func(g Gomega) *corev1.NodeCondition {
return getNodeCondition(g)
}).Should(PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(nodeagentconfigv1alpha1.ConditionTypeSystemdUnitsReady),
"Status": Equal(corev1.ConditionTrue),
"Reason": Equal("AllUnitsHealthy"),
})))
})

It("should also monitor gardener-node-agent's own units", func() {
writeOSC(&extensionsv1alpha1.OperatingSystemConfig{
Spec: extensionsv1alpha1.OperatingSystemConfigSpec{
Expand Down