Skip to content

Commit

Permalink
Merge branch 'main' into elastic
Browse files Browse the repository at this point in the history
Signed-off-by: rickbrouwer <[email protected]>
  • Loading branch information
rickbrouwer authored Sep 18, 2024
2 parents 7b59c85 + 209b1ca commit 30eb25e
Show file tree
Hide file tree
Showing 21 changed files with 349 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ jobs:
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

- name: Upload test logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: e2e-test-logs
path: "${{ github.workspace }}/**/*.log"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.x
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-main-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
NODE_POOL_SIZE: 1

- name: Upload test logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
if: ${{ always() }}
with:
name: e2e-test-logs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: make smoke-test

- name: Upload test logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
if: ${{ always() }}
with:
name: smoke-test-logs ${{ inputs.runs-on }}-${{ inputs.kubernetesVersion }}
Expand Down
8 changes: 4 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Building](#building)
- [Quick start with Visual Studio Code Remote - Containers](#quick-start-with-visual-studio-code-remote---containers)
- [Quick start with Visual Studio Code Dev Containers](#quick-start-with-visual-studio-code-dev-containers)
- [Locally directly](#locally-directly)
- [Deploying](#deploying)
- [Custom KEDA locally outside cluster](#custom-keda-locally-outside-cluster)
Expand All @@ -25,14 +25,14 @@

## Building

### Quick start with [Visual Studio Code Remote - Containers](https://code.visualstudio.com/docs/remote/containers)
### Quick start with [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/remote/containers)

This helps you pull and build quickly - dev containers launch the project inside a container with all the tooling
required for a consistent and seamless developer experience.

This means you don't have to install and configure your dev environment as the container handles this for you.

To get started install [VSCode](https://code.visualstudio.com/) and the [Remote Containers extensions](
To get started install [VSCode](https://code.visualstudio.com/) and the [Dev Containers extensions](
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

Clone the repo and launch code:
Expand All @@ -43,7 +43,7 @@ cd keda
code .
```

Once VSCode launches run `CTRL+SHIFT+P -> Remote-Containers: Reopen in container` and then use the integrated
Once VSCode launches run `CTRL+SHIFT+P -> Dev Containers: Reopen in container` and then use the integrated
terminal to run:

```bash
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
### New

- **CloudEventSource**: Introduce ClusterCloudEventSource ([#3533](https://github.com/kedacore/keda/issues/3533))
- **CloudEventSource**: Provide CloudEvents around the management of ScaledJobs resources ([#3523](https://github.com/kedacore/keda/issues/3523))
- **CloudEventSource**: Provide ClusterCloudEventSource around the management of ScaledJobs resources ([#3523](https://github.com/kedacore/keda/issues/3523))
- **CloudEventSource**: Provide ClusterCloudEventSource around the management of TriggerAuthentication/ClusterTriggerAuthentication resources ([#3524](https://github.com/kedacore/keda/issues/3524))

#### Experimental

Expand Down Expand Up @@ -91,7 +92,7 @@ New deprecation(s):

### Breaking Changes

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))
- **Pulsar Scaler**: remove `msgBacklog` trigger name ([#6059](https://github.com/kedacore/keda/issues/6059))

### Other

Expand Down
21 changes: 20 additions & 1 deletion apis/eventing/v1alpha1/cloudevent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1alpha1

// CloudEventType contains the list of cloudevent types
// +kubebuilder:validation:Enum=keda.scaledobject.ready.v1;keda.scaledobject.failed.v1;keda.scaledobject.removed.v1;keda.scaledjob.ready.v1;keda.scaledjob.failed.v1;keda.scaledjob.removed.v1
// +kubebuilder:validation:Enum=keda.scaledobject.ready.v1;keda.scaledobject.failed.v1;keda.scaledobject.removed.v1;keda.scaledjob.ready.v1;keda.scaledjob.failed.v1;keda.scaledjob.removed.v1;keda.authentication.triggerauthentication.created.v1;keda.authentication.triggerauthentication.updated.v1;keda.authentication.triggerauthentication.removed.v1;keda.authentication.clustertriggerauthentication.created.v1;keda.authentication.clustertriggerauthentication.updated.v1;keda.authentication.clustertriggerauthentication.removed.v1

type CloudEventType string

const (
Expand All @@ -38,6 +39,24 @@ const (

// ScaledJobRemovedType is for event when removed ScaledJob
ScaledJobRemovedType CloudEventType = "keda.scaledjob.removed.v1"

// TriggerAuthenticationCreatedType is for event when a new TriggerAuthentication is created
TriggerAuthenticationCreatedType CloudEventType = "keda.authentication.triggerauthentication.created.v1"

// TriggerAuthenticationUpdatedType is for event when a TriggerAuthentication is updated
TriggerAuthenticationUpdatedType CloudEventType = "keda.authentication.triggerauthentication.updated.v1"

// TriggerAuthenticationRemovedType is for event when a TriggerAuthentication is deleted
TriggerAuthenticationRemovedType CloudEventType = "keda.authentication.triggerauthentication.removed.v1"

// ClusterTriggerAuthenticationCreatedType is for event when a new ClusterTriggerAuthentication is created
ClusterTriggerAuthenticationCreatedType CloudEventType = "keda.authentication.clustertriggerauthentication.created.v1"

// ClusterTriggerAuthenticationCreatedType is for event when a ClusterTriggerAuthentication is updated
ClusterTriggerAuthenticationUpdatedType CloudEventType = "keda.authentication.clustertriggerauthentication.updated.v1"

// ClusterTriggerAuthenticationRemovedType is for event when a ClusterTriggerAuthentication is deleted
ClusterTriggerAuthenticationRemovedType CloudEventType = "keda.authentication.clustertriggerauthentication.removed.v1"
)

var AllEventTypes = []CloudEventType{
Expand Down
8 changes: 4 additions & 4 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ func main() {
os.Exit(1)
}
if err = (&kedacontrollers.TriggerAuthenticationReconciler{
Client: mgr.GetClient(),
EventRecorder: eventRecorder,
Client: mgr.GetClient(),
EventHandler: eventEmitter,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "TriggerAuthentication")
os.Exit(1)
}
if err = (&kedacontrollers.ClusterTriggerAuthenticationReconciler{
Client: mgr.GetClient(),
EventRecorder: eventRecorder,
Client: mgr.GetClient(),
EventHandler: eventEmitter,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterTriggerAuthentication")
os.Exit(1)
Expand Down
16 changes: 12 additions & 4 deletions config/crd/bases/eventing.keda.sh_cloudeventsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,36 @@ spec:
properties:
excludedEventTypes:
items:
description: CloudEventType contains the list of cloudevent
types
enum:
- keda.scaledobject.ready.v1
- keda.scaledobject.failed.v1
- keda.scaledobject.removed.v1
- keda.scaledjob.ready.v1
- keda.scaledjob.failed.v1
- keda.scaledjob.removed.v1
- keda.authentication.triggerauthentication.created.v1
- keda.authentication.triggerauthentication.updated.v1
- keda.authentication.triggerauthentication.removed.v1
- keda.authentication.clustertriggerauthentication.created.v1
- keda.authentication.clustertriggerauthentication.updated.v1
- keda.authentication.clustertriggerauthentication.removed.v1
type: string
type: array
includedEventTypes:
items:
description: CloudEventType contains the list of cloudevent
types
enum:
- keda.scaledobject.ready.v1
- keda.scaledobject.failed.v1
- keda.scaledobject.removed.v1
- keda.scaledjob.ready.v1
- keda.scaledjob.failed.v1
- keda.scaledjob.removed.v1
- keda.authentication.triggerauthentication.created.v1
- keda.authentication.triggerauthentication.updated.v1
- keda.authentication.triggerauthentication.removed.v1
- keda.authentication.clustertriggerauthentication.created.v1
- keda.authentication.clustertriggerauthentication.updated.v1
- keda.authentication.clustertriggerauthentication.removed.v1
type: string
type: array
type: object
Expand Down
16 changes: 12 additions & 4 deletions config/crd/bases/eventing.keda.sh_clustercloudeventsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,36 @@ spec:
properties:
excludedEventTypes:
items:
description: CloudEventType contains the list of cloudevent
types
enum:
- keda.scaledobject.ready.v1
- keda.scaledobject.failed.v1
- keda.scaledobject.removed.v1
- keda.scaledjob.ready.v1
- keda.scaledjob.failed.v1
- keda.scaledjob.removed.v1
- keda.authentication.triggerauthentication.created.v1
- keda.authentication.triggerauthentication.updated.v1
- keda.authentication.triggerauthentication.removed.v1
- keda.authentication.clustertriggerauthentication.created.v1
- keda.authentication.clustertriggerauthentication.updated.v1
- keda.authentication.clustertriggerauthentication.removed.v1
type: string
type: array
includedEventTypes:
items:
description: CloudEventType contains the list of cloudevent
types
enum:
- keda.scaledobject.ready.v1
- keda.scaledobject.failed.v1
- keda.scaledobject.removed.v1
- keda.scaledjob.ready.v1
- keda.scaledjob.failed.v1
- keda.scaledjob.removed.v1
- keda.authentication.triggerauthentication.created.v1
- keda.authentication.triggerauthentication.updated.v1
- keda.authentication.triggerauthentication.removed.v1
- keda.authentication.clustertriggerauthentication.created.v1
- keda.authentication.clustertriggerauthentication.updated.v1
- keda.authentication.clustertriggerauthentication.removed.v1
type: string
type: array
type: object
Expand Down
13 changes: 10 additions & 3 deletions controllers/keda/clustertriggerauthentication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@ package keda

import (
"context"
"fmt"
"sync"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

eventingv1alpha1 "github.com/kedacore/keda/v2/apis/eventing/v1alpha1"
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/kedacore/keda/v2/pkg/common/message"
"github.com/kedacore/keda/v2/pkg/eventemitter"
"github.com/kedacore/keda/v2/pkg/eventreason"
"github.com/kedacore/keda/v2/pkg/metricscollector"
)

// ClusterTriggerAuthenticationReconciler reconciles a ClusterTriggerAuthentication object
type ClusterTriggerAuthenticationReconciler struct {
client.Client
record.EventRecorder
eventemitter.EventHandler
}

type clusterTriggerAuthMetricsData struct {
Expand Down Expand Up @@ -80,8 +83,12 @@ func (r *ClusterTriggerAuthenticationReconciler) Reconcile(ctx context.Context,
r.updatePromMetrics(clusterTriggerAuthentication, req.NamespacedName.String())

if clusterTriggerAuthentication.ObjectMeta.Generation == 1 {
r.EventRecorder.Event(clusterTriggerAuthentication, corev1.EventTypeNormal, eventreason.ClusterTriggerAuthenticationAdded, "New ClusterTriggerAuthentication configured")
r.Emit(clusterTriggerAuthentication, req.NamespacedName.Namespace, corev1.EventTypeNormal, eventingv1alpha1.ClusterTriggerAuthenticationCreatedType, eventreason.ClusterTriggerAuthenticationAdded, message.ClusterTriggerAuthenticationCreatedMsg)
} else {
msg := fmt.Sprintf(message.ClusterTriggerAuthenticationUpdatedMsg, clusterTriggerAuthentication.Name)
r.Emit(clusterTriggerAuthentication, req.NamespacedName.Namespace, corev1.EventTypeNormal, eventingv1alpha1.ClusterTriggerAuthenticationUpdatedType, eventreason.ClusterTriggerAuthenticationUpdated, msg)
}

return ctrl.Result{}, nil
}

Expand Down
12 changes: 9 additions & 3 deletions controllers/keda/triggerauthentication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@ package keda

import (
"context"
"fmt"
"sync"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

eventingv1alpha1 "github.com/kedacore/keda/v2/apis/eventing/v1alpha1"
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/kedacore/keda/v2/pkg/common/message"
"github.com/kedacore/keda/v2/pkg/eventemitter"
"github.com/kedacore/keda/v2/pkg/eventreason"
"github.com/kedacore/keda/v2/pkg/metricscollector"
"github.com/kedacore/keda/v2/pkg/util"
Expand All @@ -38,7 +41,7 @@ import (
// TriggerAuthenticationReconciler reconciles a TriggerAuthentication object
type TriggerAuthenticationReconciler struct {
client.Client
record.EventRecorder
eventemitter.EventHandler
}

type triggerAuthMetricsData struct {
Expand Down Expand Up @@ -81,7 +84,10 @@ func (r *TriggerAuthenticationReconciler) Reconcile(ctx context.Context, req ctr
r.updatePromMetrics(triggerAuthentication, req.NamespacedName.String())

if triggerAuthentication.ObjectMeta.Generation == 1 {
r.EventRecorder.Event(triggerAuthentication, corev1.EventTypeNormal, eventreason.TriggerAuthenticationAdded, "New TriggerAuthentication configured")
r.Emit(triggerAuthentication, req.NamespacedName.Namespace, corev1.EventTypeNormal, eventingv1alpha1.TriggerAuthenticationCreatedType, eventreason.TriggerAuthenticationAdded, message.TriggerAuthenticationCreatedMsg)
} else {
msg := fmt.Sprintf(message.TriggerAuthenticationUpdatedMsg, triggerAuthentication.Name)
r.Emit(triggerAuthentication, req.NamespacedName.Namespace, corev1.EventTypeNormal, eventingv1alpha1.TriggerAuthenticationUpdatedType, eventreason.TriggerAuthenticationUpdated, msg)
}

return ctrl.Result{}, nil
Expand Down
10 changes: 7 additions & 3 deletions controllers/keda/util/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"

eventingv1alpha1 "github.com/kedacore/keda/v2/apis/eventing/v1alpha1"
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/kedacore/keda/v2/pkg/eventemitter"
"github.com/kedacore/keda/v2/pkg/eventreason"
)

Expand All @@ -19,7 +20,7 @@ const (

type authenticationReconciler interface {
client.Client
record.EventRecorder
eventemitter.EventHandler
UpdatePromMetricsOnDelete(string)
}

Expand Down Expand Up @@ -48,13 +49,16 @@ func EnsureAuthenticationResourceFinalizer(ctx context.Context, logger logr.Logg

func FinalizeAuthenticationResource(ctx context.Context, logger logr.Logger, reconciler authenticationReconciler, authResource client.Object, namespacedName string) error {
var authResourceType, reason string
var cloudEventType eventingv1alpha1.CloudEventType
switch authResource.(type) {
case *kedav1alpha1.TriggerAuthentication:
authResourceType = "TriggerAuthentication"
reason = eventreason.TriggerAuthenticationDeleted
cloudEventType = eventingv1alpha1.TriggerAuthenticationRemovedType
case *kedav1alpha1.ClusterTriggerAuthentication:
authResourceType = "ClusterTriggerAuthentication"
reason = eventreason.ClusterTriggerAuthenticationDeleted
cloudEventType = eventingv1alpha1.ClusterTriggerAuthenticationRemovedType
}

if Contains(authResource.GetFinalizers(), authenticationFinalizer) {
Expand All @@ -68,6 +72,6 @@ func FinalizeAuthenticationResource(ctx context.Context, logger logr.Logger, rec
}

logger.Info(fmt.Sprintf("Successfully finalized %s", authResourceType))
reconciler.Event(authResource, corev1.EventTypeNormal, reason, fmt.Sprintf("%s was deleted", authResourceType))
reconciler.Emit(authResource, namespacedName, corev1.EventTypeNormal, cloudEventType, reason, fmt.Sprintf("%s was deleted", authResourceType))
return nil
}
8 changes: 8 additions & 0 deletions pkg/common/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ const (
ScaledJobReadyMsg = "ScaledJob is ready for scaling"

ScaledJobRemoved = "ScaledJob was deleted"

TriggerAuthenticationCreatedMsg = "New TriggerAuthentication configured"

TriggerAuthenticationUpdatedMsg = "ClusterTriggerAuthentication %s is updated"

ClusterTriggerAuthenticationCreatedMsg = "New ClusterTriggerAuthentication configured"

ClusterTriggerAuthenticationUpdatedMsg = "ClusterTriggerAuthentication %s is updated"
)
6 changes: 6 additions & 0 deletions pkg/eventreason/eventreason.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const (
// TriggerAuthenticationFailed is for event when a TriggerAuthentication occurs error
TriggerAuthenticationFailed = "TriggerAuthenticationFailed"

// TriggerAuthenticationUpdated is for event when a TriggerAuthentication is updated
TriggerAuthenticationUpdated = "ClusterTriggerAuthenticationUpdated"

// ClusterTriggerAuthenticationDeleted is for event when a ClusterTriggerAuthentication is deleted
ClusterTriggerAuthenticationDeleted = "ClusterTriggerAuthenticationDeleted"

Expand All @@ -85,4 +88,7 @@ const (

// ClusterTriggerAuthenticationFailed is for event when a ClusterTriggerAuthentication occurs error
ClusterTriggerAuthenticationFailed = "ClusterTriggerAuthenticationFailed"

// ClusterTriggerAuthenticationUpdated is for event when a ClusterTriggerAuthentication is updated
ClusterTriggerAuthenticationUpdated = "ClusterTriggerAuthenticationUpdated"
)
Loading

0 comments on commit 30eb25e

Please sign in to comment.