mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 14:30:12 +01:00
feat(zfspv): move to klog (#166)
Signed-off-by: vaniisgh <vanisingh@live.co.uk>
This commit is contained in:
parent
54f2b0b9fd
commit
d0d1664d43
53 changed files with 124 additions and 2991 deletions
|
|
@ -20,14 +20,13 @@ import (
|
|||
"fmt"
|
||||
"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"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// isDeletionCandidate checks if a zfs snapshot is a deletion candidate.
|
||||
|
|
@ -106,7 +105,7 @@ func (c *SnapController) addSnap(obj interface{}) {
|
|||
if zfs.NodeID != snap.Spec.OwnerNodeID {
|
||||
return
|
||||
}
|
||||
logrus.Infof("Got add event for Snap %s/%s", snap.Spec.PoolName, snap.Name)
|
||||
klog.Infof("Got add event for Snap %s/%s", snap.Spec.PoolName, snap.Name)
|
||||
c.enqueueSnap(snap)
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +124,7 @@ func (c *SnapController) updateSnap(oldObj, newObj interface{}) {
|
|||
|
||||
// update on Snapshot CR does not make sense unless it is a deletion candidate
|
||||
if c.isDeletionCandidate(newSnap) {
|
||||
logrus.Infof("Got update event for Snap %s/%s@%s", newSnap.Spec.PoolName, newSnap.Labels[zfs.ZFSVolKey], newSnap.Name)
|
||||
klog.Infof("Got update event for Snap %s/%s@%s", newSnap.Spec.PoolName, newSnap.Labels[zfs.ZFSVolKey], newSnap.Name)
|
||||
c.enqueueSnap(newSnap)
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +149,7 @@ func (c *SnapController) deleteSnap(obj interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
logrus.Infof("Got delete event for Snap %s/%s@%s", snap.Spec.PoolName, snap.Labels[zfs.ZFSVolKey], snap.Name)
|
||||
klog.Infof("Got delete event for Snap %s/%s@%s", snap.Spec.PoolName, snap.Labels[zfs.ZFSVolKey], snap.Name)
|
||||
c.enqueueSnap(snap)
|
||||
}
|
||||
|
||||
|
|
@ -163,23 +162,23 @@ func (c *SnapController) Run(threadiness int, stopCh <-chan struct{}) error {
|
|||
defer c.workqueue.ShutDown()
|
||||
|
||||
// Start the informer factories to begin populating the informer caches
|
||||
logrus.Info("Starting Snap controller")
|
||||
klog.Info("Starting Snap 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.snapSynced); !ok {
|
||||
return fmt.Errorf("failed to wait for caches to sync")
|
||||
}
|
||||
logrus.Info("Starting Snap workers")
|
||||
klog.Info("Starting Snap workers")
|
||||
// Launch worker to process Snap 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 Snap workers")
|
||||
klog.Info("Started Snap workers")
|
||||
<-stopCh
|
||||
logrus.Info("Shutting down Snap workers")
|
||||
klog.Info("Shutting down Snap workers")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -235,7 +234,7 @@ func (c *SnapController) 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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue