refactor(zfspv): renamed watcher to mgmt package

as it does the management task also corrected few logs
and renamed zvol to zfs(as we support zvol and dataset both)

Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan 2019-11-26 14:57:06 +05:30 committed by Kiran Mova
parent e953af99cf
commit 523e862159
7 changed files with 27 additions and 27 deletions

View file

@ -10,7 +10,7 @@ import (
config "github.com/openebs/zfs-localpv/pkg/config"
"github.com/openebs/zfs-localpv/pkg/driver"
"github.com/openebs/zfs-localpv/pkg/version"
zvol "github.com/openebs/zfs-localpv/pkg/zfs"
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
"github.com/spf13/cobra"
)
@ -39,7 +39,7 @@ func main() {
cmd.Flags().AddGoFlagSet(flag.CommandLine)
cmd.PersistentFlags().StringVar(
&config.NodeID, "nodeid", zvol.NodeID, "NodeID to identify the node running this driver",
&config.NodeID, "nodeid", zfs.NodeID, "NodeID to identify the node running this driver",
)
cmd.PersistentFlags().StringVar(

View file

@ -200,7 +200,7 @@ func (b *Builder) WithLabels(labels map[string]string) *Builder {
if len(labels) == 0 {
b.errs = append(
b.errs,
errors.New("failed to build cstorvolume object: missing labels"),
errors.New("failed to build zfs volume object: missing labels"),
)
return b
}

View file

@ -19,9 +19,9 @@ package driver
import (
"github.com/Sirupsen/logrus"
"github.com/container-storage-interface/spec/lib/go/csi"
ctrl "github.com/openebs/zfs-localpv/cmd/controller"
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/core/v1alpha1"
"github.com/openebs/zfs-localpv/pkg/builder"
"github.com/openebs/zfs-localpv/pkg/mgmt"
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
@ -42,9 +42,9 @@ func NewNode(d *CSIDriver) csi.NodeServer {
var ControllerMutex = sync.RWMutex{}
// start the zfsvolume watcher
go func() {
err := ctrl.Start(&ControllerMutex)
err := mgmt.Start(&ControllerMutex)
if err != nil {
logrus.Errorf("Failed to start cstorvolume claim controller: %s", err.Error())
logrus.Fatalf("Failed to start ZFS volume management controller: %s", err.Error())
}
}()

View file

@ -24,7 +24,7 @@ import (
"github.com/openebs/zfs-localpv/pkg/builder"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
zvol "github.com/openebs/zfs-localpv/pkg/zfs"
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
)
// scheduling algorithm constants
@ -41,7 +41,7 @@ func volumeWeightedScheduler(topo *csi.TopologyRequirement, pool string) string
var selected string
zvlist, err := builder.NewKubeclient().
WithNamespace(zvol.OpenEBSNamespace).
WithNamespace(zfs.OpenEBSNamespace).
List(metav1.ListOptions{})
if err != nil {
@ -63,7 +63,7 @@ func volumeWeightedScheduler(topo *csi.TopologyRequirement, pool string) string
// schedule it on the node which has less
// number of volume for the given pool
for _, prf := range topo.Preferred {
node := prf.Segments[zvol.ZFSTopologyKey]
node := prf.Segments[zfs.ZFSTopologyKey]
if volmap[node] < numVol {
selected = node
numVol = volmap[node]
@ -83,7 +83,7 @@ func scheduler(topo *csi.TopologyRequirement, schld string, pool string) string
}
// if there is a single node, schedule it on that
if len(topo.Preferred) == 1 {
return topo.Preferred[0].Segments[zvol.ZFSTopologyKey]
return topo.Preferred[0].Segments[zfs.ZFSTopologyKey]
}
switch schld {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
package mgmt
import (
"github.com/Sirupsen/logrus"

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
package mgmt
import (
"fmt"
@ -23,7 +23,7 @@ import (
"github.com/Sirupsen/logrus"
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/core/v1alpha1"
zvol "github.com/openebs/zfs-localpv/pkg/zfs"
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"
@ -80,27 +80,27 @@ func (c *ZVController) syncZV(zv *apis.ZFSVolume) error {
var err error
// ZFS Volume should be deleted. Check if deletion timestamp is set
if c.isDeletionCandidate(zv) {
err = zvol.DestroyVolume(zv)
err = zfs.DestroyVolume(zv)
if err == nil {
zvol.RemoveZvolFinalizer(zv)
zfs.RemoveZvolFinalizer(zv)
}
} else {
// if finalizer is not set then it means we are creating
// the volume. And if it is set then volume has already been
// created and this event is for property change only.
if zv.Finalizers != nil {
err = zvol.SetZvolProp(zv)
err = zfs.SetZvolProp(zv)
} else {
err = zvol.CreateVolume(zv)
err = zfs.CreateVolume(zv)
if err == nil {
err = zvol.UpdateZvolInfo(zv)
err = zfs.UpdateZvolInfo(zv)
}
}
}
return err
}
// addZV is the add event handler for CstorVolumeClaim
// addZV is the add event handler for ZFSVolume
func (c *ZVController) addZV(obj interface{}) {
zv, ok := obj.(*apis.ZFSVolume)
if !ok {
@ -108,14 +108,14 @@ func (c *ZVController) addZV(obj interface{}) {
return
}
if zvol.NodeID != zv.Spec.OwnerNodeID {
if zfs.NodeID != zv.Spec.OwnerNodeID {
return
}
logrus.Infof("Got add event for ZV %s/%s", zv.Spec.PoolName, zv.Name)
c.enqueueZV(zv)
}
// updateZV is the update event handler for CstorVolumeClaim
// updateZV is the update event handler for ZFSVolume
func (c *ZVController) updateZV(oldObj, newObj interface{}) {
newZV, ok := newObj.(*apis.ZFSVolume)
@ -124,19 +124,19 @@ func (c *ZVController) updateZV(oldObj, newObj interface{}) {
return
}
if zvol.NodeID != newZV.Spec.OwnerNodeID {
if zfs.NodeID != newZV.Spec.OwnerNodeID {
return
}
oldZV, ok := oldObj.(*apis.ZFSVolume)
if zvol.PropertyChanged(oldZV, newZV) ||
if zfs.PropertyChanged(oldZV, newZV) ||
c.isDeletionCandidate(newZV) {
logrus.Infof("Got update event for ZV %s/%s", newZV.Spec.PoolName, newZV.Name)
c.enqueueZV(newZV)
}
}
// deleteZV is the delete event handler for CstorVolumeClaim
// deleteZV is the delete event handler for ZFSVolume
func (c *ZVController) deleteZV(obj interface{}) {
zv, ok := obj.(*apis.ZFSVolume)
if !ok {
@ -147,12 +147,12 @@ func (c *ZVController) deleteZV(obj interface{}) {
}
zv, ok = tombstone.Obj.(*apis.ZFSVolume)
if !ok {
runtime.HandleError(fmt.Errorf("Tombstone contained object that is not a cstorvolumeclaim %#v", obj))
runtime.HandleError(fmt.Errorf("Tombstone contained object that is not a zfsvolume %#v", obj))
return
}
}
if zvol.NodeID != zv.Spec.OwnerNodeID {
if zfs.NodeID != zv.Spec.OwnerNodeID {
return
}

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
package mgmt
import (
"sync"