Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Fix event recorder scheme #1981

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 22 additions & 4 deletions cmd/controller-manager/app/controller_manager.go
Expand Up @@ -30,8 +30,8 @@ import (
"k8s.io/client-go/kubernetes"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"

"github.com/kubernetes-incubator/service-catalog/pkg/api"
"k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand All @@ -41,6 +41,7 @@ import (
"github.com/kubernetes-incubator/service-catalog/pkg/metrics"
"github.com/kubernetes-incubator/service-catalog/pkg/metrics/osbclientproxy"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/server/healthz"
Expand All @@ -54,6 +55,8 @@ import (
_ "github.com/kubernetes-incubator/service-catalog/pkg/api"

"github.com/kubernetes-incubator/service-catalog/cmd/controller-manager/app/options"
servicecatalogv1beta1 "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1"
settingsv1alpha1 "github.com/kubernetes-incubator/service-catalog/pkg/apis/settings/v1alpha1"
servicecataloginformers "github.com/kubernetes-incubator/service-catalog/pkg/client/informers_generated/externalversions"
"github.com/kubernetes-incubator/service-catalog/pkg/controller"

Expand Down Expand Up @@ -187,10 +190,25 @@ func Run(controllerManagerOptions *options.ControllerManagerServer) error {

// Create event broadcaster
glog.V(4).Info("Creating event broadcaster")
eventsScheme := runtime.NewScheme()
// We use ConfigMapLock/EndpointsLock which emit events for ConfigMap/Endpoints and hence we need core/v1 types for it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good comments.

if err = corev1.AddToScheme(eventsScheme); err != nil {
return err
}
// We also emit events for our own types
if err = servicecatalogv1beta1.AddToScheme(eventsScheme); err != nil {
return err
}
if err = settingsv1alpha1.AddToScheme(eventsScheme); err != nil {
return err
}

eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: k8sKubeClient.CoreV1().Events("")})
recorder := eventBroadcaster.NewRecorder(api.Scheme, v1.EventSource{Component: controllerManagerAgentName})
loggingWatch := eventBroadcaster.StartLogging(glog.Infof)
defer loggingWatch.Stop()
recordingWatch := eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: k8sKubeClient.CoreV1().Events("")})
defer recordingWatch.Stop()
recorder := eventBroadcaster.NewRecorder(eventsScheme, v1.EventSource{Component: controllerManagerAgentName})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any "wait to be ready" type function that needs to be called? I'm thinking of how informers work. I think because this is a push, where that is a watch, we're fine without any such call being necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, afaik. Events work for instances and bindings, for example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my understanding, yes.


// 'run' is the logic to run the controllers for the controller manager
run := func(stop <-chan struct{}) {
Expand Down