Skip to content

Commit

Permalink
Create a cloned OpenEBS (jiva) Volume from a snapshot (#283)
Browse files Browse the repository at this point in the history
The Volume Create Spec is extended to include:

- CloneIP - Source Controller IP
- SnapshotName - Source Volume Snapshot Name

The Jiva Replica command line takes 3 new ags:
- cloneIP : This is frontendIP of running source controller, which will be used to make a clone request, will be passed as a argument while starting clone replica.
- type=clone: Type of replica, now we can pass type as clone to trigger the clone API of jiva, which says the new replica is getting added as clone not as usual replica.
- snapName : Name of the snapshot which will be synced/cloned to a new persistent volume.

The replica when it comes up as clone, will register itself with it controller in write-only mode. Then issue a sync request to the source controller. Restore to the snapshot provided and convert itself into read-write mode.

Current implementation only support launching of clone volume in read-only mode. To support read-write clones, further cases need to be handled.

Signed-off-by: prateekpandey14 <prateekpandey14@gmail.com>
  • Loading branch information
prateekpandey14 authored and kmova committed Mar 28, 2018
1 parent 33bbdcb commit 362bdfa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion orchprovider/k8s/v1/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ func (k *k8sOrchestrator) createReplicaDeployment(volProProfile volProfile.Volum
return nil, err
}

glog.Infof("Successfully added replica(s) 'count: %d' for Volume '%s'", rCount, d.Name)
glog.Infof("Successfully added replica(s) 'count: %d' for Volume '%s'", *rCount, d.Name)

//glog.Infof("Successfully added replica #%d for VSM '%s'", rcIndex, d.Name)
//} -- end of for loop -- if manual replica addition
Expand Down
13 changes: 13 additions & 0 deletions types/v1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,16 @@ const (
// This is replaced at runtime
JivaClusterIPHolder JivaAnnotations = "__CLUSTER_IP__"

// JivaCloneIPHolder is used as a placeholder for sync controller IP address
// which will be used as cloneIP
//
// NOTE:
// This is replaced at runtime
JivaCloneIPHolder JivaAnnotations = "__CLONE_IP__"

//JivaReplicaTypeHolder JivaAnnotations = "clone"
JivaSnapNameHolder JivaAnnotations = "__SNAPNAME__"

// JivaStorageSizeHolder is used as a placeholder for persistent volume's
// storage capacity
//
Expand Down Expand Up @@ -611,6 +621,9 @@ var (

// JivaReplicaArgs is the set of arguments provided to JivaReplicaCmd
JivaReplicaArgs = []string{"replica", "--frontendIP", string(JivaClusterIPHolder), "--size", string(JivaStorageSizeHolder), string(JivaPersistentMountPathDef)}

// JivaCloneReplicaArgs is the set of arguments provided to JivaReplicaCmd
JivaCloneReplicaArgs = []string{"replica", "--frontendIP", string(JivaClusterIPHolder), "--cloneIP", string(JivaCloneIPHolder), "--type", string("clone"), "--snapName", string(JivaSnapNameHolder), "--size", string(JivaStorageSizeHolder), string(JivaPersistentMountPathDef)}
)

// TODO
Expand Down
7 changes: 7 additions & 0 deletions types/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ type Volume struct {
// - `true` indicates monitoring is required & should use the defaults
Monitor string `json:"monitor,omitempty" protobuf:"bytes,1,opt,name=monitor"`

// CloneIP is the source controller IP which will be used to make a sync and rebuild
// request from the new clone replica.
CloneIP string `json:"cloneIP,omitempty" protobuf:"bytes,1,opt,name=cloneIP"`

// SnapshotName name of snapshot which is getting promoted as persistent
// volume(this snapshot will be cloned to new volume).
SnapshotName string `json:"snapshotName,omitempty" protobuf:"bytes,1,opt,name=snapshotName"`
// Specs contains the desired specifications the volume should have.
// +optional
Specs []VolumeSpec `json:"specs,omitempty" protobuf:"bytes,2,rep,name=specs"`
Expand Down
30 changes: 22 additions & 8 deletions types/v1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,16 +924,30 @@ func MakeOrDefJivaReplicaArgs(vol *Volume, clusterIP string) []string {

//storSize := GetPVPStorageSize(profileMap)
storSize := vol.Capacity
cloneIP := vol.CloneIP
snapshotName := vol.SnapshotName

//repArgs := make([]string, len(JivaReplicaArgs))
if cloneIP == "" {
repArgs := make([]string, len(JivaReplicaArgs))
for i, rArg := range JivaReplicaArgs {
rArg = strings.Replace(rArg, string(JivaClusterIPHolder), clusterIP, 1)
rArg = strings.Replace(rArg, string(JivaStorageSizeHolder), storSize, 1)
repArgs[i] = rArg
}
return repArgs
} else {
repArgs := make([]string, len(JivaCloneReplicaArgs))
for i, rArg := range JivaCloneReplicaArgs {
rArg = strings.Replace(rArg, string(JivaClusterIPHolder), clusterIP, 1)
rArg = strings.Replace(rArg, string(JivaStorageSizeHolder), storSize, 1)
rArg = strings.Replace(rArg, string(JivaCloneIPHolder), cloneIP, 1)
rArg = strings.Replace(rArg, string(JivaSnapNameHolder), snapshotName, 1)
repArgs[i] = rArg

repArgs := make([]string, len(JivaReplicaArgs))

for i, rArg := range JivaReplicaArgs {
rArg = strings.Replace(rArg, string(JivaClusterIPHolder), clusterIP, 1)
rArg = strings.Replace(rArg, string(JivaStorageSizeHolder), storSize, 1)
repArgs[i] = rArg
}
return repArgs
}

return repArgs
}

// DefaultJivaISCSIPort will provide the port required to make ISCSI based
Expand Down

0 comments on commit 362bdfa

Please sign in to comment.