This repository has been archived by the owner on May 6, 2022. It is now read-only.
Fix event recorder scheme #1981
Merged
carolynvs
merged 1 commit into
kubernetes-retired:master
from
atlassian:fix-event-recorder-scheme
Apr 25, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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" | ||
|
||
|
@@ -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 | ||
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}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, afaik. Events work for instances and bindings, for example. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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{}) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good comments.