From 53523dd2fd520c6bf5e0d3ba412c1585ec2e3a18 Mon Sep 17 00:00:00 2001 From: Fabian-K Date: Mon, 25 Jan 2021 16:42:50 +0100 Subject: [PATCH] Accept 0 as a valid value for EventListener replicas This change is intended as a workaround until a proper Knative EventListener implementation is available (see #892). Note: without additional work, replicas=0 results in a broken setup. --- .../triggers/v1alpha1/event_listener_defaults.go | 3 --- .../v1alpha1/event_listener_defaults_test.go | 13 ------------- 2 files changed, 16 deletions(-) diff --git a/pkg/apis/triggers/v1alpha1/event_listener_defaults.go b/pkg/apis/triggers/v1alpha1/event_listener_defaults.go index 83be074d3..0e1e2f236 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_defaults.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_defaults.go @@ -24,9 +24,6 @@ import ( func (el *EventListener) SetDefaults(ctx context.Context) { if IsUpgradeViaDefaulting(ctx) { // set defaults - if el.Spec.Replicas != nil && *el.Spec.Replicas == 0 { - *el.Spec.Replicas = 1 - } for i := range el.Spec.Triggers { triggerSpecBindingArray(el.Spec.Triggers[i].Bindings). defaultBindings() diff --git a/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go b/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go index 0d9d5581d..62e29a97b 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go @@ -75,19 +75,6 @@ func TestEventListenerSetDefaults(t *testing.T) { }}, }, }, - }, { - name: "set replicas to 1 if provided replicas is 0 as part of eventlistener spec", - in: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - Replicas: ptr.Int32(0), - }, - }, - wc: v1alpha1.WithUpgradeViaDefaulting, - want: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - Replicas: ptr.Int32(1), - }, - }, }, { name: "deprecate podTemplate nodeselector to resource", in: &v1alpha1.EventListener{