@@ -63,22 +63,36 @@ func (InactiveScheduleError) Error() string {
63
63
// computeDesiredFleetSize computes the new desired size of the given fleet
64
64
func computeDesiredFleetSize (pol autoscalingv1.FleetAutoscalerPolicy , f * agonesv1.Fleet ,
65
65
gameServerNamespacedLister listeragonesv1.GameServerNamespaceLister , nodeCounts map [string ]gameservers.NodeCount , fasLog * FasLogger ) (int32 , bool , error ) {
66
+
67
+ var (
68
+ replicas int32
69
+ limited bool
70
+ err error
71
+ )
72
+
66
73
switch pol .Type {
67
74
case autoscalingv1 .BufferPolicyType :
68
- return applyBufferPolicy (pol .Buffer , f , fasLog )
75
+ replicas , limited , err = applyBufferPolicy (pol .Buffer , f , fasLog )
69
76
case autoscalingv1 .WebhookPolicyType :
70
- return applyWebhookPolicy (pol .Webhook , f , fasLog )
77
+ replicas , limited , err = applyWebhookPolicy (pol .Webhook , f , fasLog )
71
78
case autoscalingv1 .CounterPolicyType :
72
- return applyCounterOrListPolicyWrapper (pol .Counter , nil , f , gameServerNamespacedLister , nodeCounts , fasLog )
79
+ replicas , limited , err = applyCounterOrListPolicyWrapper (pol .Counter , nil , f , gameServerNamespacedLister , nodeCounts , fasLog )
73
80
case autoscalingv1 .ListPolicyType :
74
- return applyCounterOrListPolicyWrapper (nil , pol .List , f , gameServerNamespacedLister , nodeCounts , fasLog )
81
+ replicas , limited , err = applyCounterOrListPolicyWrapper (nil , pol .List , f , gameServerNamespacedLister , nodeCounts , fasLog )
75
82
case autoscalingv1 .SchedulePolicyType :
76
- return applySchedulePolicy (pol .Schedule , f , gameServerNamespacedLister , nodeCounts , time .Now (), fasLog )
83
+ replicas , limited , err = applySchedulePolicy (pol .Schedule , f , gameServerNamespacedLister , nodeCounts , time .Now (), fasLog )
77
84
case autoscalingv1 .ChainPolicyType :
78
- return applyChainPolicy (pol .Chain , f , gameServerNamespacedLister , nodeCounts , time .Now (), fasLog )
85
+ replicas , limited , err = applyChainPolicy (pol .Chain , f , gameServerNamespacedLister , nodeCounts , time .Now (), fasLog )
86
+ default :
87
+ err = errors .New ("wrong policy type, should be one of: Buffer, Webhook, Counter, List, Schedule, Chain" )
88
+ }
89
+
90
+ if err != nil {
91
+ loggerForFleetAutoscalerKey (fasLog .fas .ObjectMeta .Name , fasLog .baseLogger ).
92
+ Debugf ("Failed to apply policy type %q: %v" , pol .Type , err )
79
93
}
80
94
81
- return 0 , false , errors . New ( "wrong policy type, should be one of: Buffer, Webhook, Counter, List" )
95
+ return replicas , limited , err
82
96
}
83
97
84
98
// buildURLFromWebhookPolicy - build URL for Webhook and set CARoot for client Transport
@@ -451,11 +465,26 @@ func applyChainPolicy(c autoscalingv1.ChainPolicy, f *agonesv1.Fleet, gameServer
451
465
switch entry .Type {
452
466
case autoscalingv1 .SchedulePolicyType :
453
467
replicas , limited , err = applySchedulePolicy (entry .Schedule , f , gameServerNamespacedLister , nodeCounts , currentTime , fasLog )
468
+
469
+ if err != nil {
470
+ loggerForFleetAutoscalerKey (fasLog .fas .ObjectMeta .Name , fasLog .baseLogger ).Debugf (
471
+ "Failed to apply SchedulePolicy ID=%s in ChainPolicy: %v" , entry .ID , err )
472
+ }
454
473
case autoscalingv1 .WebhookPolicyType :
455
474
replicas , limited , err = applyWebhookPolicy (entry .Webhook , f , fasLog )
475
+
476
+ if err != nil {
477
+ loggerForFleetAutoscalerKey (fasLog .fas .ObjectMeta .Name , fasLog .baseLogger ).Debugf (
478
+ "Failed to apply WebhookPolicy ID=%s in ChainPolicy: %v" , entry .ID , err )
479
+ }
456
480
default :
457
481
// Every other policy type we just want to compute the desired fleet and return it
458
482
replicas , limited , err = computeDesiredFleetSize (entry .FleetAutoscalerPolicy , f , gameServerNamespacedLister , nodeCounts , fasLog )
483
+
484
+ if err != nil {
485
+ loggerForFleetAutoscalerKey (fasLog .fas .ObjectMeta .Name , fasLog .baseLogger ).Debugf (
486
+ "Failed to apply %s ID=%s in ChainPolicy: %v" , entry .Type , entry .ID , err )
487
+ }
459
488
}
460
489
461
490
// If no error occurred, exit the loop early
0 commit comments