@@ -237,6 +237,9 @@ func newRevisionThrottler(revID types.NamespacedName,
237237 protocol : proto ,
238238 podTrackers : []* podTracker {},
239239 }
240+ if containerConcurrency < 0 {
241+ containerConcurrency = 0
242+ }
240243 t .containerConcurrency .Store (uint32 (containerConcurrency ))
241244 t .lbPolicy .Store (lbp )
242245
@@ -615,10 +618,14 @@ func (t *Throttler) revisionUpdated(obj any) {
615618 zap .Error (err ), zap .String (logkey .Key , revID .String ()))
616619 } else if rt != nil {
617620 // Update the lbPolicy dynamically if the revision's spec policy changed
618- newPolicy , name := pickLBPolicy (rev .Spec .LoadBalancingPolicy , nil , int (rev .Spec .GetContainerConcurrency ()), t .logger )
621+ containerConcurrency := rev .Spec .GetContainerConcurrency ()
622+ if containerConcurrency < 0 {
623+ containerConcurrency = 0
624+ }
625+ newPolicy , name := pickLBPolicy (rev .Spec .LoadBalancingPolicy , nil , int (containerConcurrency ), t .logger )
619626 // Use atomic store for lock-free access in the hot request path
620627 rt .lbPolicy .Store (newPolicy )
621- rt .containerConcurrency .Store (uint32 (rev . Spec . GetContainerConcurrency () ))
628+ rt .containerConcurrency .Store (uint32 (containerConcurrency ))
622629 t .logger .Infof ("Updated revision throttler LB policy to: %s" , name )
623630 }
624631}
@@ -692,12 +699,14 @@ func (rt *revisionThrottler) handlePubEpsUpdate(eps *corev1.Endpoints, selfIP st
692699 }
693700
694701 na , ai := rt .numActivators .Load (), rt .activatorIndex .Load ()
695- if na == uint32 (newNA ) && ai == newAI {
702+ if newNA >= 0 && na == uint32 (newNA ) && ai == newAI {
696703 // The state didn't change, do nothing
697704 return
698705 }
699706
700- rt .numActivators .Store (uint32 (newNA ))
707+ if newNA >= 0 {
708+ rt .numActivators .Store (uint32 (newNA ))
709+ }
701710 rt .activatorIndex .Store (newAI )
702711 rt .logger .Infof ("This activator index is %d/%d was %d/%d" ,
703712 newAI , newNA , ai , na )
0 commit comments