Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install KEDA in tests #3285

Merged
merged 7 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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: 2 additions & 2 deletions control-plane/pkg/autoscaler/autoscaler_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ const (
AutoscalingActivationLagThreshold = Autoscaling + "/activation-lag-threshold"

// DefaultPollingInterval is the default value for AutoscalingPollingIntervalAnnotation.
DefaultPollingInterval = 30
DefaultPollingInterval = 10
// DefaultCooldownPeriod is the default value for AutoscalingCooldownPeriodAnnotation.
DefaultCooldownPeriod = 300
// DefaultMinReplicaCount is the default value for AutoscalingMinScaleAnnotation
DefaultMinReplicaCount = 0
// DefaultMaxReplicaCount is the default value for AutoscalingMaxScaleAnnotation.
DefaultMaxReplicaCount = 50
// DefaultLagThreshold is the default value for AutoscalingLagThreshold.
DefaultLagThreshold = 10
DefaultLagThreshold = 100
// DefaultActivationLagThreshold is the default value for AutoscalingActivationLagThreshold.
DefaultActivationLagThreshold = 1
)
14 changes: 12 additions & 2 deletions control-plane/pkg/reconciler/consumergroup/consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"knative.dev/pkg/apis"
"knative.dev/pkg/logging"
"knative.dev/pkg/reconciler"
"knative.dev/pkg/resolver"

sources "knative.dev/eventing-kafka-broker/control-plane/pkg/apis/sources/v1beta1"

Expand Down Expand Up @@ -77,6 +78,7 @@
ConfigMapLister corelisters.ConfigMapLister
PodLister corelisters.PodLister
KubeClient kubernetes.Interface
Resolver *resolver.URIResolver

NameGenerator names.NameGenerator

Expand Down Expand Up @@ -127,7 +129,7 @@
return err
}

errCondition, err := r.propagateStatus(cg)
errCondition, err := r.propagateStatus(ctx, cg)
if err != nil {
return cg.MarkReconcileConsumersFailed("PropagateConsumerStatus", err)
}
Expand Down Expand Up @@ -403,7 +405,7 @@
return placementConsumers
}

func (r Reconciler) propagateStatus(cg *kafkainternals.ConsumerGroup) (*apis.Condition, error) {
func (r Reconciler) propagateStatus(ctx context.Context, cg *kafkainternals.ConsumerGroup) (*apis.Condition, error) {
consumers, err := r.ConsumerLister.Consumers(cg.GetNamespace()).List(labels.SelectorFromSet(cg.Spec.Selector))
if err != nil {
return nil, fmt.Errorf("failed to list consumers for selector %+v: %w", cg.Spec.Selector, err)
Expand Down Expand Up @@ -432,6 +434,14 @@
}
cg.Status.Replicas = pointer.Int32(count)

if cg.Spec.Replicas != nil && *cg.Spec.Replicas == 0 {
subscriber, err := r.Resolver.URIFromDestinationV1(ctx, cg.Spec.Template.Spec.Subscriber, cg)
if err != nil {
return condition, fmt.Errorf("failed to resolve subscribed URI: %w", err)
}
cg.Status.SubscriberURI = subscriber

Check warning on line 442 in control-plane/pkg/reconciler/consumergroup/consumergroup.go

View check run for this annotation

Codecov / codecov/patch

control-plane/pkg/reconciler/consumergroup/consumergroup.go#L438-L442

Added lines #L438 - L442 were not covered by tests
}

return condition, nil
}

Expand Down
3 changes: 3 additions & 0 deletions control-plane/pkg/reconciler/consumergroup/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"knative.dev/pkg/controller"
"knative.dev/pkg/logging"
"knative.dev/pkg/reconciler"
"knative.dev/pkg/resolver"
"knative.dev/pkg/system"

statefulsetscheduler "knative.dev/eventing/pkg/scheduler/statefulset"
Expand Down Expand Up @@ -151,6 +152,8 @@ func NewController(ctx context.Context, watcher configmap.Watcher) *controller.I
}
})

r.Resolver = resolver.NewURIResolverFromTracker(ctx, impl.Tracker)

configStore := config.NewStore(ctx, func(name string, value *config.KafkaFeatureFlags) {
r.KafkaFeatureFlags.Reset(value)
impl.GlobalResync(consumerGroupInformer.Informer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
_ "knative.dev/eventing-kafka-broker/control-plane/pkg/client/injection/informers/sources/v1beta1/kafkasource/fake"
_ "knative.dev/pkg/client/injection/ducks/duck/v1/addressable/fake"
kubeclient "knative.dev/pkg/client/injection/kube/client/fake"
_ "knative.dev/pkg/client/injection/kube/informers/apps/v1/statefulset/fake"
_ "knative.dev/pkg/client/injection/kube/informers/core/v1/configmap/fake"
Expand Down
29 changes: 29 additions & 0 deletions hack/update-keda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# check that we have exactly one argument denoting which keda version to update to

if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <keda_version>"
exit 1
fi

keda_version=$1

echo "Using KEDA version: ${keda_version}"

curl -L "https://github.com/kedacore/keda/releases/download/v${keda_version}/keda-${keda_version}.yaml" \
> $(dirname $0)/../third_party/keda/keda.yaml
6 changes: 6 additions & 0 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,19 @@ function knative_eventing() {
./test/upload-test-images.sh "test/test_images" e2e || fail_test "Error uploading test images"

kafka_setup
keda_setup
}

function kafka_setup() {
echo ">> Prepare to deploy Strimzi"
./test/kafka/kafka_setup.sh || fail_test "Failed to set up Kafka cluster"
}

function keda_setup() {
echo ">> Prepare to deploy KEDA"
./test/keda/keda_setup.sh || fail_test "Failed to set up KEDA"
}

function build_components_from_source() {

[ -f "${EVENTING_KAFKA_CONTROL_PLANE_ARTIFACT}" ] && rm "${EVENTING_KAFKA_CONTROL_PLANE_ARTIFACT}"
Expand Down
24 changes: 24 additions & 0 deletions test/keda/keda_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail

source $(dirname $0)/../../vendor/knative.dev/hack/e2e-tests.sh

header "Applying KEDA Operator file"
kubectl apply -f $(dirname $0)/../../third_party/keda/keda.yaml

wait_until_pods_running keda || fail_test "Failed to start up KEDA operator"
Loading
Loading