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
4 changes: 3 additions & 1 deletion internal/status/no_warnings.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func NoWarningsCondition(resources []runtime.Object, oldCondition *RabbitmqClust
goto assignLastTransitionTime
}

if !equality.Semantic.DeepEqual(resource.Spec.Template.Spec.Containers[0].Resources.Limits["memory"], resource.Spec.Template.Spec.Containers[0].Resources.Requests["memory"]) {
limitMemory := resource.Spec.Template.Spec.Containers[0].Resources.Limits["memory"]
requestMemory := resource.Spec.Template.Spec.Containers[0].Resources.Requests["memory"]
if (!limitMemory.IsZero() && !requestMemory.IsZero()) && !equality.Semantic.DeepEqual(limitMemory, requestMemory) {
condition.Status = corev1.ConditionFalse
condition.Reason = "MemoryRequestAndLimitDifferent"
condition.Message = "RabbitMQ container memory resource request and limit must be equal"
Expand Down
16 changes: 16 additions & 0 deletions internal/status/no_warnings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ var _ = Describe("NoWarnings", func() {
})
})

It("is true if the memory limit are not set but the request is set", func() {
sts := noMemoryWarningStatefulSet()
sts.Spec.Template.Spec.Containers[0].Resources.Limits = corev1.ResourceList{}
condition := rabbitmqstatus.NoWarningsCondition([]runtime.Object{sts}, nil)
By("having the correct type", func() {
var conditionType rabbitmqstatus.RabbitmqClusterConditionType = "NoWarnings"
Expect(condition.Type).To(Equal(conditionType))
})

By("having status false and reason message", func() {
Expect(condition.Status).To(Equal(corev1.ConditionTrue))
Expect(condition.Reason).To(Equal("NoWarnings"))
Expect(condition.Message).To(BeEmpty())
})
})

It("is unknown when the StatefulSet does not exist", func() {
var sts *appsv1.StatefulSet = nil
condition := rabbitmqstatus.NoWarningsCondition([]runtime.Object{sts}, nil)
Expand Down