From 2141247565dd2dd7051ea91a8ac1afed1ceaa0c8 Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Thu, 13 Sep 2018 11:37:06 -0700 Subject: [PATCH] Add event scheme This PR adds the event scheme --- cmd/csi-snapshotter/main.go | 5 +++++ pkg/controller/snapshot_controller_base.go | 1 + 2 files changed, 6 insertions(+) diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index 327a695e4..80e1ff077 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -26,6 +26,7 @@ import ( "github.com/golang/glog" "k8s.io/client-go/kubernetes" + "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" @@ -33,6 +34,7 @@ import ( "github.com/kubernetes-csi/external-snapshotter/pkg/controller" clientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned" + snapshotscheme "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned/scheme" informers "github.com/kubernetes-csi/external-snapshotter/pkg/client/informers/externalversions" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" ) @@ -97,6 +99,9 @@ func main() { os.Exit(1) } + // Add Snapshot types to the defualt Kubernetes so events can be logged for them + snapshotscheme.AddToScheme(scheme.Scheme) + // Connect to CSI. csiConn, err := connection.New(*csiAddress, *connectionTimeout) if err != nil { diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 9a5c519ac..f878acaa9 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -84,6 +84,7 @@ func NewCSISnapshotController( snapshotNameUUIDLength int, ) *csiSnapshotController { broadcaster := record.NewBroadcaster() + broadcaster.StartLogging(glog.Infof) broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: client.Core().Events(v1.NamespaceAll)}) var eventRecorder record.EventRecorder eventRecorder = broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("csi-snapshotter %s", snapshotterName)})