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
38 changes: 38 additions & 0 deletions pkg/core/controller_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,25 @@ func ControllerTestSuite[I InstanceType](
Expect(instance.GetAnnotations()[SchedulingDisabledAnnotation]).To(Equal("default-scheduler"))
})

It("Emits a MissingChildren warning event", func() {
eventReason := func(event *corev1.Event) string {
return event.Reason
}
eventType := func(event *corev1.Event) string {
return event.Type
}
Eventually(func() *corev1.EventList {
events := &corev1.EventList{}
Expect(m.Client.List(context.TODO(), events)).To(Succeed())
return events
}, timeout).Should(utils.WithItems(ContainElement(
SatisfyAll(
WithTransform(eventReason, Equal("MissingChildren")),
WithTransform(eventType, Equal(corev1.EventTypeWarning)),
),
)))
})

Context("And the missing child is created", func() {
JustBeforeEach(func() {
expectNoReconciles()
Expand Down Expand Up @@ -559,6 +578,25 @@ func ControllerTestSuite[I InstanceType](
Expect(instance.GetAnnotations()[SchedulingDisabledAnnotation]).To(Equal("default-scheduler"))
})

It("Emits a MissingChildren warning event", func() {
eventReason := func(event *corev1.Event) string {
return event.Reason
}
eventType := func(event *corev1.Event) string {
return event.Type
}
Eventually(func() *corev1.EventList {
events := &corev1.EventList{}
Expect(m.Client.List(context.TODO(), events)).To(Succeed())
return events
}, timeout).Should(utils.WithItems(ContainElement(
SatisfyAll(
WithTransform(eventReason, Equal("MissingChildren")),
WithTransform(eventType, Equal(corev1.EventTypeWarning)),
),
)))
})

Context("And the missing child is created with a missing field", func() {
BeforeEach(func() {
expectNoReconciles()
Expand Down
3 changes: 2 additions & 1 deletion pkg/core/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (h *Handler[I]) handlePodController(ctx context.Context, instance I) (recon
err = h.checkRequiredChildren(configMaps, secrets, configMapsConfig, secretsConfig)
if err != nil {
// We are missing children but we added watchers for all children so we are done
h.recorder.Eventf(instance, corev1.EventTypeWarning, "MissingChildren", "Scheduling blocked due to missing children: %s", err)
return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -191,7 +192,7 @@ func (h *Handler[I]) updatePodController(instance I, dryRun bool, isCreate bool)
if isCreate {
if !dryRun {
log.V(0).Info("Not all required children found yet. Disabling scheduling!", "err", err)
h.recorder.Eventf(instance, corev1.EventTypeNormal, "SchedulingDisabled", "Disabled scheduling due to missing children: %s", err)
h.recorder.Eventf(instance, corev1.EventTypeWarning, "SchedulingDisabled", "Disabled scheduling due to missing children: %s", err)
}
disableScheduling(instance)
} else {
Expand Down
Loading