mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
chore(go-lint): fix golint warning (#133)
Fixes several go lint cases reported by go report. Signed-off-by: wiwen <shenggxhz@gmail.com>
This commit is contained in:
parent
639ead416e
commit
f5ae3ff476
25 changed files with 78 additions and 51 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@ tags
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*.swn
|
*.swn
|
||||||
|
*.idea
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,8 @@ func (b *Builder) WithLabels(labels map[string]string) *Builder {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithFinalizer merge existing finalizers if any
|
||||||
|
// with the ones that are provided here
|
||||||
func (b *Builder) WithFinalizer(finalizer []string) *Builder {
|
func (b *Builder) WithFinalizer(finalizer []string) *Builder {
|
||||||
b.snap.Object.Finalizers = append(b.snap.Object.Finalizers, finalizer...)
|
b.snap.Object.Finalizers = append(b.snap.Object.Finalizers, finalizer...)
|
||||||
return b
|
return b
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ func (b *Builder) WithSnapshot(snap string) *Builder {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithPoolName sets Pool name for creating volume
|
||||||
func (b *Builder) WithPoolName(pool string) *Builder {
|
func (b *Builder) WithPoolName(pool string) *Builder {
|
||||||
if pool == "" {
|
if pool == "" {
|
||||||
b.errs = append(
|
b.errs = append(
|
||||||
|
|
@ -192,7 +193,8 @@ func (b *Builder) WithPoolName(pool string) *Builder {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Builder) WithNodename(name string) *Builder {
|
// WithNodeName sets NodeID for creating the volume
|
||||||
|
func (b *Builder) WithNodeName(name string) *Builder {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
b.errs = append(
|
b.errs = append(
|
||||||
b.errs,
|
b.errs,
|
||||||
|
|
@ -223,6 +225,7 @@ func (b *Builder) WithLabels(labels map[string]string) *Builder {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithFinalizer sets Finalizer name creating the volume
|
||||||
func (b *Builder) WithFinalizer(finalizer []string) *Builder {
|
func (b *Builder) WithFinalizer(finalizer []string) *Builder {
|
||||||
b.volume.Object.Finalizers = append(b.volume.Object.Finalizers, finalizer...)
|
b.volume.Object.Finalizers = append(b.volume.Object.Finalizers, finalizer...)
|
||||||
return b
|
return b
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Namespacegetter abstracts fetching of Namespace from kubernetes cluster
|
// NamespaceGetter abstracts fetching of Namespace from kubernetes cluster
|
||||||
type NamespaceGetter interface {
|
type NamespaceGetter interface {
|
||||||
Get(name string, options metav1.GetOptions) (*corev1.Namespace, error)
|
Get(name string, options metav1.GetOptions) (*corev1.Namespace, error)
|
||||||
}
|
}
|
||||||
|
|
@ -43,9 +43,8 @@ func (ns *namespace) Get(name string, options metav1.GetOptions) (*corev1.Namesp
|
||||||
cs, err := Clientset().Get()
|
cs, err := Clientset().Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to get namespace: %s", name)
|
return nil, errors.Wrapf(err, "failed to get namespace: %s", name)
|
||||||
} else {
|
|
||||||
return cs.CoreV1().Namespaces().Get(name, options)
|
|
||||||
}
|
}
|
||||||
|
return cs.CoreV1().Namespaces().Get(name, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns a slice of namespaces defined in a Kubernetes cluster
|
// List returns a slice of namespaces defined in a Kubernetes cluster
|
||||||
|
|
@ -53,7 +52,6 @@ func (ns *namespace) List(options metav1.ListOptions) (*corev1.NamespaceList, er
|
||||||
cs, err := Clientset().Get()
|
cs, err := Clientset().Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to get namespaces")
|
return nil, errors.Wrapf(err, "failed to get namespaces")
|
||||||
} else {
|
|
||||||
return cs.CoreV1().Namespaces().List(options)
|
|
||||||
}
|
}
|
||||||
|
return cs.CoreV1().Namespaces().List(options)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
pkg/common/env/env.go
vendored
3
pkg/common/env/env.go
vendored
|
|
@ -64,9 +64,8 @@ func GetOrDefault(e string, defaultValue string) (value string) {
|
||||||
if len(envValue) == 0 {
|
if len(envValue) == 0 {
|
||||||
// ENV not defined or set to ""
|
// ENV not defined or set to ""
|
||||||
return defaultValue
|
return defaultValue
|
||||||
} else {
|
|
||||||
return envValue
|
|
||||||
}
|
}
|
||||||
|
return envValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup looks up an environment variable
|
// Lookup looks up an environment variable
|
||||||
|
|
|
||||||
|
|
@ -212,11 +212,12 @@ func (c *Client) Config() (config *rest.Config, err error) {
|
||||||
return c.getInClusterConfig()
|
return c.getInClusterConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigForPath returns the kuberentes config instance based on KubeConfig path
|
// ConfigForPath returns the kubernetes config instance based on KubeConfig path
|
||||||
func (c *Client) ConfigForPath(kubeConfigPath string) (config *rest.Config, err error) {
|
func (c *Client) ConfigForPath(kubeConfigPath string) (config *rest.Config, err error) {
|
||||||
return c.buildConfigFromFlags("", kubeConfigPath)
|
return c.buildConfigFromFlags("", kubeConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetConfigForPathOrDirect returns the kubernetes config instance based on direct KubeConfig
|
||||||
func (c *Client) GetConfigForPathOrDirect() (config *rest.Config, err error) {
|
func (c *Client) GetConfigForPathOrDirect() (config *rest.Config, err error) {
|
||||||
if c.KubeConfigPath != "" {
|
if c.KubeConfigPath != "" {
|
||||||
return c.ConfigForPath(c.KubeConfigPath)
|
return c.ConfigForPath(c.KubeConfigPath)
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ func NewNode(d *CSIDriver) csi.NodeServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVolAndMountInfo get volume and mount info from node csi volume request
|
||||||
func GetVolAndMountInfo(
|
func GetVolAndMountInfo(
|
||||||
req *csi.NodePublishVolumeRequest,
|
req *csi.NodePublishVolumeRequest,
|
||||||
) (*apis.ZFSVolume, *apis.MountInfo, error) {
|
) (*apis.ZFSVolume, *apis.MountInfo, error) {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
|
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
|
||||||
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
|
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
|
||||||
errors "github.com/openebs/zfs-localpv/pkg/common/errors"
|
errors "github.com/openebs/zfs-localpv/pkg/common/errors"
|
||||||
|
|
@ -31,9 +35,6 @@ import (
|
||||||
csipayload "github.com/openebs/zfs-localpv/pkg/response"
|
csipayload "github.com/openebs/zfs-localpv/pkg/response"
|
||||||
analytics "github.com/openebs/zfs-localpv/pkg/usage"
|
analytics "github.com/openebs/zfs-localpv/pkg/usage"
|
||||||
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
|
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// controller is the server implementation
|
// controller is the server implementation
|
||||||
|
|
@ -74,6 +75,7 @@ func sendEventOrIgnore(pvcName, pvName, capacity, stgType, method string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateZFSVolume create new zfs volume from csi volume request
|
||||||
func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
|
func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
|
||||||
volName := req.GetName()
|
volName := req.GetName()
|
||||||
size := req.GetCapacityRange().RequiredBytes
|
size := req.GetCapacityRange().RequiredBytes
|
||||||
|
|
@ -137,6 +139,7 @@ func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
|
||||||
return selected, nil
|
return selected, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateZFSClone create a clone of zfs volume
|
||||||
func CreateZFSClone(req *csi.CreateVolumeRequest, snapshot string) (string, error) {
|
func CreateZFSClone(req *csi.CreateVolumeRequest, snapshot string) (string, error) {
|
||||||
|
|
||||||
volName := req.GetName()
|
volName := req.GetName()
|
||||||
|
|
@ -260,6 +263,14 @@ func (cs *controller) DeleteVolume(
|
||||||
goto deleteResponse
|
goto deleteResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(
|
||||||
|
err,
|
||||||
|
"failed to get volume for {%s}",
|
||||||
|
volumeID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the corresponding ZV CR
|
// Delete the corresponding ZV CR
|
||||||
err = zfs.DeleteVolume(volumeID)
|
err = zfs.DeleteVolume(volumeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,9 @@ var supportedAccessMode = &csi.VolumeCapability_AccessMode{
|
||||||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
|
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check if this can be renamed to Base
|
|
||||||
//
|
|
||||||
// CSIDriver defines a common data structure
|
// CSIDriver defines a common data structure
|
||||||
// for drivers
|
// for drivers
|
||||||
|
// TODO check if this can be renamed to Base
|
||||||
type CSIDriver struct {
|
type CSIDriver struct {
|
||||||
// TODO change the field names to make it
|
// TODO change the field names to make it
|
||||||
// readable
|
// readable
|
||||||
|
|
|
||||||
|
|
@ -75,22 +75,22 @@ type NonBlockingGRPCServer interface {
|
||||||
// NewNonBlockingGRPCServer returns a new instance of NonBlockingGRPCServer
|
// NewNonBlockingGRPCServer returns a new instance of NonBlockingGRPCServer
|
||||||
func NewNonBlockingGRPCServer(ep string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) NonBlockingGRPCServer {
|
func NewNonBlockingGRPCServer(ep string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) NonBlockingGRPCServer {
|
||||||
return &nonBlockingGRPCServer{
|
return &nonBlockingGRPCServer{
|
||||||
endpoint: ep,
|
endpoint: ep,
|
||||||
idnty_server: ids,
|
idntyServer: ids,
|
||||||
ctrl_server: cs,
|
ctrlServer: cs,
|
||||||
agent_server: ns}
|
agentServer: ns}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NonBlocking server
|
// NonBlocking server
|
||||||
// dont block the execution for a task to complete.
|
// dont block the execution for a task to complete.
|
||||||
// use wait group to wait for all the tasks dispatched.
|
// use wait group to wait for all the tasks dispatched.
|
||||||
type nonBlockingGRPCServer struct {
|
type nonBlockingGRPCServer struct {
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
server *grpc.Server
|
server *grpc.Server
|
||||||
endpoint string
|
endpoint string
|
||||||
idnty_server csi.IdentityServer
|
idntyServer csi.IdentityServer
|
||||||
ctrl_server csi.ControllerServer
|
ctrlServer csi.ControllerServer
|
||||||
agent_server csi.NodeServer
|
agentServer csi.NodeServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start grpc server for serving CSI endpoints
|
// Start grpc server for serving CSI endpoints
|
||||||
|
|
@ -98,7 +98,7 @@ func (s *nonBlockingGRPCServer) Start() {
|
||||||
|
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
|
|
||||||
go s.serve(s.endpoint, s.idnty_server, s.ctrl_server, s.agent_server)
|
go s.serve(s.endpoint, s.idntyServer, s.ctrlServer, s.agentServer)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func (c *ZVController) updateZV(oldObj, newObj interface{}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oldZV, ok := oldObj.(*apis.ZFSVolume)
|
oldZV, _ := oldObj.(*apis.ZFSVolume)
|
||||||
if zfs.PropertyChanged(oldZV, newZV) ||
|
if zfs.PropertyChanged(oldZV, newZV) ||
|
||||||
c.isDeletionCandidate(newZV) {
|
c.isDeletionCandidate(newZV) {
|
||||||
logrus.Infof("Got update event for ZV %s/%s", newZV.Spec.PoolName, newZV.Name)
|
logrus.Infof("Got update event for ZV %s/%s", newZV.Spec.PoolName, newZV.Name)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func (b *CreateVolumeResponseBuilder) WithName(name string) *CreateVolumeRespons
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithName sets the capacity against the
|
// WithCapacity sets the capacity against the
|
||||||
// CreateVolumeResponse instance
|
// CreateVolumeResponse instance
|
||||||
func (b *CreateVolumeResponseBuilder) WithCapacity(capacity int64) *CreateVolumeResponseBuilder {
|
func (b *CreateVolumeResponseBuilder) WithCapacity(capacity int64) *CreateVolumeResponseBuilder {
|
||||||
b.response.Volume.CapacityBytes = capacity
|
b.response.Volume.CapacityBytes = capacity
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,28 @@ const (
|
||||||
|
|
||||||
// supported events categories
|
// supported events categories
|
||||||
|
|
||||||
// Install event is sent on pod starts
|
// InstallEvent event is sent on pod starts
|
||||||
InstallEvent string = "install"
|
InstallEvent string = "install"
|
||||||
// Ping event is sent periodically
|
// Ping event is sent periodically
|
||||||
Ping string = "zfs-ping"
|
Ping string = "zfs-ping"
|
||||||
// VolumeProvision event is sent when a volume is created
|
// VolumeProvision event is sent when a volume is created
|
||||||
VolumeProvision string = "volume-provision"
|
VolumeProvision string = "volume-provision"
|
||||||
//VolumeDeprovision event is sent when a volume is deleted
|
// VolumeDeprovision event is sent when a volume is deleted
|
||||||
VolumeDeprovision string = "volume-deprovision"
|
VolumeDeprovision string = "volume-deprovision"
|
||||||
AppName string = "OpenEBS"
|
// AppName the application name
|
||||||
|
AppName string = "OpenEBS"
|
||||||
|
|
||||||
|
// RunningStatus status is running
|
||||||
|
RunningStatus string = "running"
|
||||||
// Event labels
|
// Event labels
|
||||||
RunningStatus string = "running"
|
|
||||||
EventLabelNode string = "nodes"
|
EventLabelNode string = "nodes"
|
||||||
EventLabelCapacity string = "capacity"
|
EventLabelCapacity string = "capacity"
|
||||||
|
|
||||||
// Event action
|
// Replica Event replication
|
||||||
Replica string = "replica:"
|
Replica string = "replica:"
|
||||||
DefaultReplicaCount string = "replica:1"
|
DefaultReplicaCount string = "replica:1"
|
||||||
|
|
||||||
// Event application name constant for volume event
|
// DefaultCASType Event application name constant for volume event
|
||||||
DefaultCASType string = "zfs-localpv"
|
DefaultCASType string = "zfs-localpv"
|
||||||
|
|
||||||
// LocalPVReplicaCount is the constant used by usage to represent
|
// LocalPVReplicaCount is the constant used by usage to represent
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package usage
|
package usage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/openebs/zfs-localpv/pkg/common/env"
|
"github.com/openebs/zfs-localpv/pkg/common/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OpenEBSPingPeriod ping interval of volume io analytics
|
||||||
var OpenEBSPingPeriod = "OPENEBS_IO_ANALYTICS_PING_INTERVAL"
|
var OpenEBSPingPeriod = "OPENEBS_IO_ANALYTICS_PING_INTERVAL"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -39,7 +40,7 @@ func PingCheck() {
|
||||||
u := New()
|
u := New()
|
||||||
duration := getPingPeriod()
|
duration := getPingPeriod()
|
||||||
ticker := time.NewTicker(duration)
|
ticker := time.NewTicker(duration)
|
||||||
for _ = range ticker.C {
|
for range ticker.C {
|
||||||
u.Build().
|
u.Build().
|
||||||
InstallBuilder(true).
|
InstallBuilder(true).
|
||||||
SetCategory(Ping).
|
SetCategory(Ping).
|
||||||
|
|
@ -57,7 +58,8 @@ func getPingPeriod() time.Duration {
|
||||||
if duration < minimumPingPeriod {
|
if duration < minimumPingPeriod {
|
||||||
// Avoid corner case when the ENV value is undesirable
|
// Avoid corner case when the ENV value is undesirable
|
||||||
return time.Duration(defaultPingPeriod)
|
return time.Duration(defaultPingPeriod)
|
||||||
} else {
|
|
||||||
return time.Duration(duration)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return time.Duration(duration)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package usage
|
package usage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -204,7 +205,7 @@ func (u *Usage) Build() *Usage {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Application builder is used for adding k8s&openebs environment detail
|
// ApplicationBuilder Application builder is used for adding k8s&openebs environment detail
|
||||||
// for non install events
|
// for non install events
|
||||||
func (u *Usage) ApplicationBuilder() *Usage {
|
func (u *Usage) ApplicationBuilder() *Usage {
|
||||||
v := NewVersion()
|
v := NewVersion()
|
||||||
|
|
@ -223,7 +224,7 @@ func (u *Usage) SetVolumeCapacity(volCapG string) *Usage {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper for setting the default storage-engine for volume-provision event
|
// SetVolumeType Wrapper for setting the default storage-engine for volume-provision event
|
||||||
func (u *Usage) SetVolumeType(volType, method string) *Usage {
|
func (u *Usage) SetVolumeType(volType, method string) *Usage {
|
||||||
if method == VolumeProvision && volType == "" {
|
if method == VolumeProvision && volType == "" {
|
||||||
// Set the default storage engine, if not specified in the request
|
// Set the default storage engine, if not specified in the request
|
||||||
|
|
@ -234,7 +235,7 @@ func (u *Usage) SetVolumeType(volType, method string) *Usage {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper for setting replica count for volume events
|
// SetReplicaCount Wrapper for setting replica count for volume events
|
||||||
// NOTE: This doesn't get the replica count in a volume de-provision event.
|
// NOTE: This doesn't get the replica count in a volume de-provision event.
|
||||||
// TODO: Pick the current value of replica-count from the CAS-engine
|
// TODO: Pick the current value of replica-count from the CAS-engine
|
||||||
func (u *Usage) SetReplicaCount(count, method string) *Usage {
|
func (u *Usage) SetReplicaCount(count, method string) *Usage {
|
||||||
|
|
@ -244,7 +245,7 @@ func (u *Usage) SetReplicaCount(count, method string) *Usage {
|
||||||
u.SetAction(DefaultReplicaCount)
|
u.SetAction(DefaultReplicaCount)
|
||||||
} else {
|
} else {
|
||||||
// Catch all case for volume-deprovision event and
|
// Catch all case for volume-deprovision event and
|
||||||
// volume-provision event with an overriden replica-count
|
// volume-provision event with an overridden replica-count
|
||||||
u.SetAction(Replica + count)
|
u.SetAction(Replica + count)
|
||||||
}
|
}
|
||||||
return u
|
return u
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package usage
|
package usage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ func GetGitCommit() string {
|
||||||
return strings.TrimSpace(string(output))
|
return strings.TrimSpace(string(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVersionDetails return version info from git commit
|
||||||
func GetVersionDetails() string {
|
func GetVersionDetails() string {
|
||||||
return "zfs-" + strings.Join([]string{Get(), GetGitCommit()[0:7]}, "-")
|
return "zfs-" + strings.Join([]string{Get(), GetGitCommit()[0:7]}, "-")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ func MountDataset(vol *apis.ZFSVolume, mount *apis.MountInfo) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MountVolume mounts the disk to the specified path
|
// MountFilesystem mounts the disk to the specified path
|
||||||
func MountFilesystem(vol *apis.ZFSVolume, mount *apis.MountInfo) error {
|
func MountFilesystem(vol *apis.ZFSVolume, mount *apis.MountInfo) error {
|
||||||
switch vol.Spec.VolumeType {
|
switch vol.Spec.VolumeType {
|
||||||
case VOLTYPE_DATASET:
|
case VOLTYPE_DATASET:
|
||||||
|
|
@ -245,6 +245,7 @@ func MountFilesystem(vol *apis.ZFSVolume, mount *apis.MountInfo) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MountBlock mounts the block disk to the specified path
|
||||||
func MountBlock(vol *apis.ZFSVolume, mountinfo *apis.MountInfo) error {
|
func MountBlock(vol *apis.ZFSVolume, mountinfo *apis.MountInfo) error {
|
||||||
target := mountinfo.MountPath
|
target := mountinfo.MountPath
|
||||||
devicePath := ZFS_DEVPATH + vol.Spec.PoolName + "/" + vol.Name
|
devicePath := ZFS_DEVPATH + vol.Spec.PoolName + "/" + vol.Name
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// OpenEBSNamespace is the environment variable to get openebs namespace
|
// OpenEBSNamespaceKey is the environment variable to get openebs namespace
|
||||||
//
|
//
|
||||||
// This environment variable is set via kubernetes downward API
|
// This environment variable is set via kubernetes downward API
|
||||||
OpenEBSNamespaceKey string = "OPENEBS_NAMESPACE"
|
OpenEBSNamespaceKey string = "OPENEBS_NAMESPACE"
|
||||||
// This environment variable is set via env
|
// GoogleAnalyticsKey This environment variable is set via env
|
||||||
GoogleAnalyticsKey string = "OPENEBS_IO_ENABLE_ANALYTICS"
|
GoogleAnalyticsKey string = "OPENEBS_IO_ENABLE_ANALYTICS"
|
||||||
// ZFSFinalizer for the ZfsVolume CR
|
// ZFSFinalizer for the ZfsVolume CR
|
||||||
ZFSFinalizer string = "zfs.openebs.io/finalizer"
|
ZFSFinalizer string = "zfs.openebs.io/finalizer"
|
||||||
|
|
@ -56,7 +56,7 @@ var (
|
||||||
// NodeID is the NodeID of the node on which the pod is present
|
// NodeID is the NodeID of the node on which the pod is present
|
||||||
NodeID string
|
NodeID string
|
||||||
|
|
||||||
// should send google analytics or not
|
// GoogleAnalyticsEnabled should send google analytics or not
|
||||||
GoogleAnalyticsEnabled string
|
GoogleAnalyticsEnabled string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func xfs_temp_mount(volume string) error {
|
func xfsTempMount(volume string) error {
|
||||||
device := ZFS_DEVPATH + volume
|
device := ZFS_DEVPATH + volume
|
||||||
pvol := strings.Split(volume, "/")
|
pvol := strings.Split(volume, "/")
|
||||||
|
|
||||||
|
|
@ -69,11 +69,11 @@ func xfs_temp_mount(volume string) error {
|
||||||
* There might be something there in the xfs log, we have to clear them
|
* There might be something there in the xfs log, we have to clear them
|
||||||
* so that filesystem is clean and we can generate the UUID for it.
|
* so that filesystem is clean and we can generate the UUID for it.
|
||||||
*/
|
*/
|
||||||
func xfs_generate_uuid(volume string) error {
|
func xfsGenerateUuid(volume string) error {
|
||||||
device := ZFS_DEVPATH + volume
|
device := ZFS_DEVPATH + volume
|
||||||
|
|
||||||
// temporary mount the volume with nouuid to replay the logs
|
// temporary mount the volume with nouuid to replay the logs
|
||||||
err := xfs_temp_mount(volume)
|
err := xfsTempMount(volume)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ const (
|
||||||
VOLTYPE_ZVOL = "ZVOL"
|
VOLTYPE_ZVOL = "ZVOL"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PropertyChanged return whether volume property is changed
|
||||||
func PropertyChanged(oldVol *apis.ZFSVolume, newVol *apis.ZFSVolume) bool {
|
func PropertyChanged(oldVol *apis.ZFSVolume, newVol *apis.ZFSVolume) bool {
|
||||||
if oldVol.Spec.VolumeType == VOLTYPE_DATASET &&
|
if oldVol.Spec.VolumeType == VOLTYPE_DATASET &&
|
||||||
newVol.Spec.VolumeType == VOLTYPE_DATASET &&
|
newVol.Spec.VolumeType == VOLTYPE_DATASET &&
|
||||||
|
|
@ -363,7 +364,7 @@ func CreateClone(vol *apis.ZFSVolume) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vol.Spec.FsType == "xfs" {
|
if vol.Spec.FsType == "xfs" {
|
||||||
return xfs_generate_uuid(volume)
|
return xfsGenerateUuid(volume)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -597,6 +598,7 @@ func GetVolumeDevPath(vol *apis.ZFSVolume) (string, error) {
|
||||||
return dev, nil
|
return dev, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResizeZFSVolume resize volume
|
||||||
func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
|
func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string) error {
|
||||||
|
|
||||||
volume := vol.Spec.PoolName + "/" + vol.Name
|
volume := vol.Spec.PoolName + "/" + vol.Name
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ func (b *Builder) WithNodeSelector(selector map[string]string) *Builder {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithNodeSelector Sets the node selector with the provided argument.
|
// WithNodeSelectorNew Sets the node selector with the provided argument.
|
||||||
func (b *Builder) WithNodeSelectorNew(selector map[string]string) *Builder {
|
func (b *Builder) WithNodeSelectorNew(selector map[string]string) *Builder {
|
||||||
if len(selector) == 0 {
|
if len(selector) == 0 {
|
||||||
b.errors = append(
|
b.errors = append(
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func (l predicateList) all(p *Pod) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRunning retuns true if the pod is in running
|
// IsRunning returns true if the pod is in running
|
||||||
// state
|
// state
|
||||||
func (p *Pod) IsRunning() bool {
|
func (p *Pod) IsRunning() bool {
|
||||||
return p.object.Status.Phase == "Running"
|
return p.object.Status.Phase == "Running"
|
||||||
|
|
@ -87,7 +87,7 @@ func IsRunning() Predicate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCompleted retuns true if the pod is in completed
|
// IsCompleted returns true if the pod is in completed
|
||||||
// state
|
// state
|
||||||
func (p *Pod) IsCompleted() bool {
|
func (p *Pod) IsCompleted() bool {
|
||||||
return p.object.Status.Phase == "Succeeded"
|
return p.object.Status.Phase == "Succeeded"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue