Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a cloned OpenEBS (jiva) Volume from a snapshot #283

Merged
merged 3 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we calling these as annotations? I guess this is an old type that we are re-using. But lets make it a point to avoid once we feel that this design/code is not good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these are coming from the Volume struct, just using this to pass as replica args .


//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