volumereplica

package
v1.12.0-RC1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// VolumeReplicaOperator is the name of the tool that makes volume-related operations.
	VolumeReplicaOperator = "zfs"
	// BinaryCapacityUnitSuffix is the suffix for binary capacity unit.
	BinaryCapacityUnitSuffix = "i"
	// CreateCmd is the create command for zfs volume.
	CreateCmd = "create"
	// CloneCmd is the zfs volume clone command.
	CloneCmd = "clone"
	// BackupCmd is the zfs send command
	BackupCmd = "send"
	// RestoreCmd is the zfs volume send command.
	RestoreCmd = "recv"
	// StatsCmd is the zfs volume stats command.
	StatsCmd = "stats"
	// ZfsStatusDegraded is the degraded state of zfs volume.
	ZfsStatusDegraded = "Degraded"
	// ZfsStatusOffline is the offline state of zfs volume.
	ZfsStatusOffline = "Offline"
	// ZfsStatusHealthy is the healthy state of zfs volume.
	ZfsStatusHealthy = "Healthy"
	// ZfsStatusRebuilding is the rebuilding state of zfs volume.
	ZfsStatusRebuilding = "Rebuilding"
	// MaxBackupRetryCount is a max number of retry should be performed during backup transfer
	MaxBackupRetryCount = 10
	// BackupRetryDelay is time(in seconds) to wait before the next attempt for backup transfer
	BackupRetryDelay = 5
	// MaxRestoreRetryCount is a max number of retry should be performed during restore transfer
	MaxRestoreRetryCount = 10
	// RestoreRetryDelay is time(in seconds) to wait before the next attempt for restore transfer
	RestoreRetryDelay = 5
)
View Source
const (
	// CStorPoolUIDKey is the key for csp object uid which is present in cvr labels.
	CStorPoolUIDKey = "cstorpool.openebs.io/uid"
	// PvNameKey is the key for pv object uid which is present in cvr labels.
	PvNameKey = "cstorvolume.openebs.io/name"
	// PoolPrefix is the prefix of zpool name.
	PoolPrefix = "cstor-"
)

Variables

View Source
var RunnerVar util.Runner

RunnerVar the runner variable for executing binaries.

Functions

func Capacity

func Capacity(volName string) (*apis.CStorVolumeCapacityAttr, error)

Capacity finds the capacity of the volume. The ouptut of command executed is as follows:

root@cstor-sparse-pool-6dft-5b5c78ccc7-dls8s:/# zfs get used,logicalused cstor-d82bd105-f3a8-11e8-87fd-42010a800087/pvc-1b2a7d4b-f3a9-11e8-87fd-42010a800087 NAME PROPERTY VALUE SOURCE cstor-d82bd105-f3a8-11e8-87fd-42010a800087/pvc-1b2a7d4b-f3a9-11e8-87fd-42010a800087 used 6K - cstor-d82bd105-f3a8-11e8-87fd-42010a800087/pvc-1b2a7d4b-f3a9-11e8-87fd-42010a800087 logicalused 6K -

func CheckValidVolumeReplica

func CheckValidVolumeReplica(cVR *apis.CStorVolumeReplica) error

CheckValidVolumeReplica checks for validity of cStor replica resource.

func CreateVolumeBackup

func CreateVolumeBackup(bkp *apis.CStorBackup) error

CreateVolumeBackup sends cStor snapshots to remote location specified by cstorbackup.

func CreateVolumeReplica

func CreateVolumeReplica(cStorVolumeReplica *apis.CStorVolumeReplica, fullVolName string, quorum bool) error

CreateVolumeReplica creates cStor replica(zfs volumes).

func CreateVolumeRestore

func CreateVolumeRestore(rst *apis.CStorRestore) error

CreateVolumeRestore receive cStor snapshots from remote location(zfs volumes).

func DeleteVolume

func DeleteVolume(fullVolName string) error

DeleteVolume deletes the specified volume.

func GenerateReplicaID

func GenerateReplicaID(cvr *apis.CStorVolumeReplica) error

GenerateReplicaID generate new replicaID for given CVR

func GetAndUpdateReplicaID

func GetAndUpdateReplicaID(cvr *apis.CStorVolumeReplica) error

GetAndUpdateReplicaID update replicaID for CVR and set it to volume

func GetAndUpdateSnapshotInfo

func GetAndUpdateSnapshotInfo(
	clientset clientset.Interface, cvr *apis.CStorVolumeReplica) error

GetAndUpdateSnapshotInfo get the snapshot list from ZFS and updates in CVR status. Execution happens in following steps:

  1. Get snapshot list from ZFS
  2. Checks whether above snapshots exist on CVR under Status.Snapshots: 2.1 If snapshot doesn't exist then get the info of snapshot from ZFS and update the details in CVR.Status.Snapshots
  3. Verify and delete the snapshot details on CVR if it is deleted from ZFS
  4. Update the pending list of snapshots by verifying with snapshot list obtained from step1
  5. If replica is under rebuilding get the snapshot list from peer CVR and update them under pending snapshot list

func GetReplicaIDFromZFS

func GetReplicaIDFromZFS(volumeName string) (string, error)

GetReplicaIDFromZFS returns replicaID for provided volume name by executing ZFS commands

func GetSnapshotList

func GetSnapshotList(dsName string) (map[string]string, error)

GetSnapshotList get the list of snapshots by executing command: `zfs listsnap <dataset_name>` and returns output: {"name":"pool1\/vol1","snaplist":{"istgt_snap1":null,"istgt_snap2":null}} and error if there are any(Few Error codes: 11 -- TryAgain).

func GetVolumeName

func GetVolumeName(cVR *apis.CStorVolumeReplica) (string, error)

GetVolumeName finds the zctual zfs volume name for the given cvr.

func GetVolumes

func GetVolumes() ([]string, error)

GetVolumes returns the slice of volumes.

func PoolNameFromBackup

func PoolNameFromBackup(bkp *apis.CStorBackup) string

PoolNameFromBackup gets the name of cstorpool from cstorvolumereplica label if not found then gets cstorpoolinstance name from the OPENEBS_IO_POOL_NAME env

func PoolNameFromCVR

func PoolNameFromCVR(cvr *apis.CStorVolumeReplica) string

PoolNameFromCVR gets the name of cstorpool from cstorvolumereplica label if not found then gets cstorpoolinstance name from the OPENEBS_IO_POOL_NAME env

func PoolNameFromRestore

func PoolNameFromRestore(rst *apis.CStorRestore) string

PoolNameFromRestore gets the name of cstorPool from cstorvolumereplica label if not found then gets cstorPoolInstance name from the OPENEBS_IO_POOL_NAME env

func SetReplicaID

func SetReplicaID(cvr *apis.CStorVolumeReplica) error

SetReplicaID set replicaID to volume

func Status

func Status(volumeName string) (string, error)

Status function gives the status of cvr which extracted and mapped to a set of cvr statuses after getting the zfs volume status

func ZfsToCvrStatusMapper

func ZfsToCvrStatusMapper(zfsstatus string, quorum int) string

ZfsToCvrStatusMapper maps zfs status to defined cvr status.

Types

type CvrStats

type CvrStats struct {
	// Stats is an array which holds zfs volume related stats
	Stats []Stats `json:"stats"`
}

CvrStats struct is zfs volume status output JSON contract.

type Stats

type Stats struct {
	// Name of the zfs volume.
	Name string `json:"name"`
	// Status of the zfs volume.
	Status string `json:"status"`
	// RebuildStatus of the zfs volume.
	RebuildStatus             string `json:"rebuildStatus"`
	IsIOAckSenderCreated      int    `json:"isIOAckSenderCreated"`
	IsIOReceiverCreated       int    `json:"isIOReceiverCreated"`
	RunningIONum              int    `json:"runningIONum"`
	CheckpointedIONum         int    `json:"checkpointedIONum"`
	DegradedCheckpointedIONum int    `json:"degradedCheckpointedIONum"`
	CheckpointedTime          int    `json:"checkpointedTime"`
	RebuildBytes              int    `json:"rebuildBytes"`
	RebuildCnt                int    `json:"rebuildCnt"`
	RebuildDoneCnt            int    `json:"rebuildDoneCnt"`
	RebuildFailedCnt          int    `json:"rebuildFailedCnt"`
	Quorum                    int    `json:"quorum"`
}

Stats contain the zfs volume related stats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL