From b9e893ff9fd27a83799f3652d95670f25d5a54c0 Mon Sep 17 00:00:00 2001 From: Pawan Date: Mon, 29 Jun 2020 12:54:18 +0530 Subject: [PATCH] klog rebase --- pkg/driver/agent.go | 4 ++-- pkg/mgmt/backup/backup.go | 21 ++++++++++----------- pkg/mgmt/backup/builder.go | 6 +++--- pkg/mgmt/backup/start.go | 4 ++-- pkg/mgmt/restore/builder.go | 6 +++--- pkg/mgmt/restore/restore.go | 20 ++++++++++---------- pkg/mgmt/restore/start.go | 4 ++-- pkg/zfs/volume.go | 4 ++-- pkg/zfs/zfs_util.go | 4 ++-- 9 files changed, 36 insertions(+), 37 deletions(-) diff --git a/pkg/driver/agent.go b/pkg/driver/agent.go index 672d2e5e1..54ea992f7 100644 --- a/pkg/driver/agent.go +++ b/pkg/driver/agent.go @@ -71,7 +71,7 @@ func NewNode(d *CSIDriver) csi.NodeServer { go func() { err := backup.Start(&ControllerMutex, stopCh) if err != nil { - logrus.Fatalf("Failed to start ZFS volume snapshot management controller: %s", err.Error()) + klog.Fatalf("Failed to start ZFS volume snapshot management controller: %s", err.Error()) } }() @@ -79,7 +79,7 @@ func NewNode(d *CSIDriver) csi.NodeServer { go func() { err := restore.Start(&ControllerMutex, stopCh) if err != nil { - logrus.Fatalf("Failed to start ZFS volume snapshot management controller: %s", err.Error()) + klog.Fatalf("Failed to start ZFS volume snapshot management controller: %s", err.Error()) } }() diff --git a/pkg/mgmt/backup/backup.go b/pkg/mgmt/backup/backup.go index 1ae43edcb..0a54412a2 100644 --- a/pkg/mgmt/backup/backup.go +++ b/pkg/mgmt/backup/backup.go @@ -18,10 +18,9 @@ package backup import ( "fmt" + "k8s.io/klog" "time" - "github.com/Sirupsen/logrus" - apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" zfs "github.com/openebs/zfs-localpv/pkg/zfs" k8serror "k8s.io/apimachinery/pkg/api/errors" @@ -103,7 +102,7 @@ func (c *BackupController) addBkp(obj interface{}) { if zfs.NodeID != bkp.Spec.OwnerNodeID { return } - logrus.Infof("Got add event for Bkp %s@%s", bkp.Spec.VolumeName, bkp.Spec.SnapName) + klog.Infof("Got add event for Bkp %s@%s", bkp.Spec.VolumeName, bkp.Spec.SnapName) c.enqueueBkp(bkp) } @@ -121,7 +120,7 @@ func (c *BackupController) updateBkp(oldObj, newObj interface{}) { } if c.isDeletionCandidate(newBkp) { - logrus.Infof("Got update event for Bkp %s@%s", newBkp.Spec.VolumeName, newBkp.Spec.SnapName) + klog.Infof("Got update event for Bkp %s@%s", newBkp.Spec.VolumeName, newBkp.Spec.SnapName) c.enqueueBkp(newBkp) } } @@ -146,7 +145,7 @@ func (c *BackupController) deleteBkp(obj interface{}) { return } - logrus.Infof("Got delete event for Bkp %s@%s", bkp.Spec.VolumeName, bkp.Spec.SnapName) + klog.Infof("Got delete event for Bkp %s@%s", bkp.Spec.VolumeName, bkp.Spec.SnapName) c.enqueueBkp(bkp) } @@ -159,23 +158,23 @@ func (c *BackupController) Run(threadiness int, stopCh <-chan struct{}) error { defer c.workqueue.ShutDown() // Start the informer factories to begin populating the informer caches - logrus.Info("Starting Bkp controller") + klog.Info("Starting Bkp controller") // Wait for the k8s caches to be synced before starting workers - logrus.Info("Waiting for informer caches to sync") + klog.Info("Waiting for informer caches to sync") if ok := cache.WaitForCacheSync(stopCh, c.bkpSynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } - logrus.Info("Starting Bkp workers") + klog.Info("Starting Bkp workers") // Launch worker to process Bkp resources // Threadiness will decide the number of workers you want to launch to process work items from queue for i := 0; i < threadiness; i++ { go wait.Until(c.runWorker, time.Second, stopCh) } - logrus.Info("Started Bkp workers") + klog.Info("Started Bkp workers") <-stopCh - logrus.Info("Shutting down Bkp workers") + klog.Info("Shutting down Bkp workers") return nil } @@ -231,7 +230,7 @@ func (c *BackupController) processNextWorkItem() bool { // Finally, if no error occurs we Forget this item so it does not // get queued again until another change happens. c.workqueue.Forget(obj) - logrus.Infof("Successfully synced '%s'", key) + klog.Infof("Successfully synced '%s'", key) return nil }(obj) diff --git a/pkg/mgmt/backup/builder.go b/pkg/mgmt/backup/builder.go index 1a65197fe..5a3dddf24 100644 --- a/pkg/mgmt/backup/builder.go +++ b/pkg/mgmt/backup/builder.go @@ -17,7 +17,7 @@ limitations under the License. package backup import ( - "github.com/Sirupsen/logrus" + "k8s.io/klog" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" openebsScheme "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/scheme" @@ -105,9 +105,9 @@ func (cb *BackupControllerBuilder) withWorkqueueRateLimiting() *BackupController // withRecorder adds recorder to controller object. func (cb *BackupControllerBuilder) withRecorder(ks kubernetes.Interface) *BackupControllerBuilder { - logrus.Infof("Creating event broadcaster") + klog.Infof("Creating event broadcaster") eventBroadcaster := record.NewBroadcaster() - eventBroadcaster.StartLogging(logrus.Infof) + eventBroadcaster.StartLogging(klog.Infof) eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: ks.CoreV1().Events("")}) recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName}) cb.BackupController.recorder = recorder diff --git a/pkg/mgmt/backup/start.go b/pkg/mgmt/backup/start.go index f380c23d5..6cf5ce9fc 100644 --- a/pkg/mgmt/backup/start.go +++ b/pkg/mgmt/backup/start.go @@ -19,8 +19,8 @@ package backup import ( "sync" - "github.com/Sirupsen/logrus" "github.com/pkg/errors" + "k8s.io/klog" "time" @@ -94,7 +94,7 @@ func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error { func getClusterConfig(kubeconfig string) (*rest.Config, error) { cfg, err := rest.InClusterConfig() if err != nil { - logrus.Errorf("Failed to get k8s Incluster config. %+v", err) + klog.Errorf("Failed to get k8s Incluster config. %+v", err) if kubeconfig == "" { return nil, errors.Wrap(err, "kubeconfig is empty") } diff --git a/pkg/mgmt/restore/builder.go b/pkg/mgmt/restore/builder.go index c685c0e86..9b70e4906 100644 --- a/pkg/mgmt/restore/builder.go +++ b/pkg/mgmt/restore/builder.go @@ -17,7 +17,7 @@ limitations under the License. package restore import ( - "github.com/Sirupsen/logrus" + "k8s.io/klog" clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset" openebsScheme "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/scheme" @@ -105,9 +105,9 @@ func (cb *RestoreControllerBuilder) withWorkqueueRateLimiting() *RestoreControll // withRecorder adds recorder to controller object. func (cb *RestoreControllerBuilder) withRecorder(ks kubernetes.Interface) *RestoreControllerBuilder { - logrus.Infof("Creating event broadcaster") + klog.Infof("Creating event broadcaster") eventBroadcaster := record.NewBroadcaster() - eventBroadcaster.StartLogging(logrus.Infof) + eventBroadcaster.StartLogging(klog.Infof) eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: ks.CoreV1().Events("")}) recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName}) cb.RestoreController.recorder = recorder diff --git a/pkg/mgmt/restore/restore.go b/pkg/mgmt/restore/restore.go index bfd664d90..f98907fb2 100644 --- a/pkg/mgmt/restore/restore.go +++ b/pkg/mgmt/restore/restore.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "github.com/Sirupsen/logrus" + "k8s.io/klog" apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1" zfs "github.com/openebs/zfs-localpv/pkg/zfs" @@ -103,7 +103,7 @@ func (c *RestoreController) addRestore(obj interface{}) { if zfs.NodeID != rstr.Spec.OwnerNodeID { return } - logrus.Infof("Got add event for Restore %s", rstr.Spec.VolumeName) + klog.Infof("Got add event for Restore %s", rstr.Spec.VolumeName) c.enqueueRestore(rstr) } @@ -121,7 +121,7 @@ func (c *RestoreController) updateRestore(oldObj, newObj interface{}) { } if c.isDeletionCandidate(newRestore) { - logrus.Infof("Got update event for Restore %s", newRestore.Spec.VolumeName) + klog.Infof("Got update event for Restore %s", newRestore.Spec.VolumeName) c.enqueueRestore(newRestore) } } @@ -146,7 +146,7 @@ func (c *RestoreController) deleteRestore(obj interface{}) { return } - logrus.Infof("Got delete event for Restore %s", rstr.Spec.VolumeName) + klog.Infof("Got delete event for Restore %s", rstr.Spec.VolumeName) c.enqueueRestore(rstr) } @@ -159,23 +159,23 @@ func (c *RestoreController) Run(threadiness int, stopCh <-chan struct{}) error { defer c.workqueue.ShutDown() // Start the informer factories to begin populating the informer caches - logrus.Info("Starting Restore controller") + klog.Info("Starting Restore controller") // Wait for the k8s caches to be synced before starting workers - logrus.Info("Waiting for informer caches to sync") + klog.Info("Waiting for informer caches to sync") if ok := cache.WaitForCacheSync(stopCh, c.rstrSynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } - logrus.Info("Starting Restore workers") + klog.Info("Starting Restore workers") // Launch worker to process Restore resources // Threadiness will decide the number of workers you want to launch to process work items from queue for i := 0; i < threadiness; i++ { go wait.Until(c.runWorker, time.Second, stopCh) } - logrus.Info("Started Restore workers") + klog.Info("Started Restore workers") <-stopCh - logrus.Info("Shutting down Restore workers") + klog.Info("Shutting down Restore workers") return nil } @@ -231,7 +231,7 @@ func (c *RestoreController) processNextWorkItem() bool { // Finally, if no error occurs we Forget this item so it does not // get queued again until another change happens. c.workqueue.Forget(obj) - logrus.Infof("Successfully synced '%s'", key) + klog.Infof("Successfully synced '%s'", key) return nil }(obj) diff --git a/pkg/mgmt/restore/start.go b/pkg/mgmt/restore/start.go index cb91709cf..8155f019e 100644 --- a/pkg/mgmt/restore/start.go +++ b/pkg/mgmt/restore/start.go @@ -19,8 +19,8 @@ package restore import ( "sync" - "github.com/Sirupsen/logrus" "github.com/pkg/errors" + "k8s.io/klog" "time" @@ -94,7 +94,7 @@ func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error { func getClusterConfig(kubeconfig string) (*rest.Config, error) { cfg, err := rest.InClusterConfig() if err != nil { - logrus.Errorf("Failed to get k8s Incluster config. %+v", err) + klog.Errorf("Failed to get k8s Incluster config. %+v", err) if kubeconfig == "" { return nil, errors.Wrap(err, "kubeconfig is empty") } diff --git a/pkg/zfs/volume.go b/pkg/zfs/volume.go index 5f4e57319..b8385385e 100644 --- a/pkg/zfs/volume.go +++ b/pkg/zfs/volume.go @@ -267,7 +267,7 @@ func UpdateBkpInfo(bkp *apis.ZFSBackup, status apis.ZFSBackupStatus) error { newBkp.Status = status if err != nil { - logrus.Errorf("Update snapshot failed %s err: %s", bkp.Spec.VolumeName, err.Error()) + klog.Errorf("Update snapshot failed %s err: %s", bkp.Spec.VolumeName, err.Error()) return err } @@ -283,7 +283,7 @@ func UpdateRestoreInfo(rstr *apis.ZFSRestore, status apis.ZFSRestoreStatus) erro newRstr.Status = status if err != nil { - logrus.Errorf("Update snapshot failed %s err: %s", rstr.Spec.VolumeName, err.Error()) + klog.Errorf("Update snapshot failed %s err: %s", rstr.Spec.VolumeName, err.Error()) return err } diff --git a/pkg/zfs/zfs_util.go b/pkg/zfs/zfs_util.go index fd8773e5f..b75e0ab2f 100644 --- a/pkg/zfs/zfs_util.go +++ b/pkg/zfs/zfs_util.go @@ -676,7 +676,7 @@ func CreateBackup(bkp *apis.ZFSBackup) error { out, err := cmd.CombinedOutput() if err != nil { - logrus.Errorf( + klog.Errorf( "zfs: could not backup the volume %v cmd %v error: %s", volume, args, string(out), ) } @@ -696,7 +696,7 @@ func CreateRestore(rstr *apis.ZFSRestore) error { out, err := cmd.CombinedOutput() if err != nil { - logrus.Errorf( + klog.Errorf( "zfs: could not restore the volume %v cmd %v error: %s", volume, args, string(out), ) }