Skip to content

Commit

Permalink
Use k8s recorder for events (#1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
reivaj05 authored Aug 17, 2022
1 parent 3e8aa5d commit c94dfd9
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions pkg/controller/cluster/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,11 @@ package cluster

import (
"context"
"time"

miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
)

// RegisterEvent creates an event for a given tenant
func (c *Controller) RegisterEvent(ctx context.Context, tenant *miniov2.Tenant, eventType, reason, message string) {
now := time.Now()
_, err := c.kubeClientSet.CoreV1().Events(tenant.Namespace).Create(ctx, &corev1.Event{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "tenant-",
Namespace: tenant.Namespace,
},
InvolvedObject: tenant.ObjectRef(),
Reason: reason,
Message: message,
Source: corev1.EventSource{
Component: "minio-operator",
},
FirstTimestamp: metav1.NewTime(now),
LastTimestamp: metav1.NewTime(now),

Type: eventType,

ReportingController: "minio-operator",
}, metav1.CreateOptions{})
if err != nil {
klog.Errorf("Error registering event: %s", err)
}
c.recorder.Event(tenant, eventType, reason, message)
}

0 comments on commit c94dfd9

Please sign in to comment.