Delaying events in the case of scaleup and scaleup error
This commit is contained in:
parent
4eaea15796
commit
04aec6bbd3
|
|
@ -18,6 +18,7 @@ package status
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"k8s.io/klog"
|
||||
"strings"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
|
|
@ -32,9 +33,15 @@ type EventingScaleUpStatusProcessor struct{}
|
|||
// Process processes the state of the cluster after a scale-up by emitting
|
||||
// relevant events for pods depending on their post scale-up status.
|
||||
func (p *EventingScaleUpStatusProcessor) Process(context *context.AutoscalingContext, status *ScaleUpStatus) {
|
||||
if status.Result != ScaleUpSuccessful && status.Result != ScaleUpError {
|
||||
for _, noScaleUpInfo := range status.PodsRemainUnschedulable {
|
||||
context.Recorder.Event(noScaleUpInfo.Pod, apiv1.EventTypeNormal, "NotTriggerScaleUp",
|
||||
fmt.Sprintf("pod didn't trigger scale-up (it wouldn't fit if a new node is added): %s", ReasonsMessage(noScaleUpInfo)))
|
||||
fmt.Sprintf("pod didn't trigger scale-up (it wouldn't fit if a new node is"+
|
||||
" added): %s", ReasonsMessage(noScaleUpInfo)))
|
||||
}
|
||||
} else {
|
||||
klog.V(4).Infof("Skipping event processing for unschedulable pods since there is a" +
|
||||
" ScaleUp attempt this loop")
|
||||
}
|
||||
if len(status.ScaleUpInfos) > 0 {
|
||||
for _, pod := range status.PodsTriggeredScaleUp {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@ func TestEventingScaleUpStatusProcessor(t *testing.T) {
|
|||
expectedNoTriggered int
|
||||
}{
|
||||
{
|
||||
caseName: "No scale up",
|
||||
caseName: "No scale up; no options available",
|
||||
state: &ScaleUpStatus{
|
||||
Result: ScaleUpNoOptionsAvailable,
|
||||
ScaleUpInfos: []nodegroupset.ScaleUpInfo{},
|
||||
PodsRemainUnschedulable: []NoScaleUpInfo{
|
||||
{p1, reasons, reasons},
|
||||
|
|
@ -69,8 +70,9 @@ func TestEventingScaleUpStatusProcessor(t *testing.T) {
|
|||
expectedNoTriggered: 2,
|
||||
},
|
||||
{
|
||||
caseName: "Scale up",
|
||||
caseName: "Scale up; some pods remain unschedulable",
|
||||
state: &ScaleUpStatus{
|
||||
Result: ScaleUpSuccessful,
|
||||
ScaleUpInfos: []nodegroupset.ScaleUpInfo{{}},
|
||||
PodsTriggeredScaleUp: []*apiv1.Pod{p3},
|
||||
PodsRemainUnschedulable: []NoScaleUpInfo{
|
||||
|
|
@ -79,7 +81,22 @@ func TestEventingScaleUpStatusProcessor(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expectedTriggered: 1,
|
||||
expectedNoTriggered: 2,
|
||||
expectedNoTriggered: 0,
|
||||
},
|
||||
{
|
||||
caseName: "Scale failed; pods remain unschedulable",
|
||||
state: &ScaleUpStatus{
|
||||
Result: ScaleUpError,
|
||||
ScaleUpInfos: []nodegroupset.ScaleUpInfo{{}},
|
||||
PodsTriggeredScaleUp: []*apiv1.Pod{},
|
||||
PodsRemainUnschedulable: []NoScaleUpInfo{
|
||||
{p1, reasons, reasons},
|
||||
{p2, reasons, reasons},
|
||||
{p3, reasons, reasons},
|
||||
},
|
||||
},
|
||||
expectedTriggered: 0,
|
||||
expectedNoTriggered: 0,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue