-
Notifications
You must be signed in to change notification settings - Fork 200
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ func (s *HTTPServer) snapshotSpecificRequest(resp http.ResponseWriter, req *http | |
return s.snapshotCreate(resp, req) | ||
case strings.Contains(path, "/revert/"): | ||
return s.snapshotRevert(resp, req) | ||
case strings.Contains(path, "/clone/"): | ||
return s.snapshotClone(resp, req) | ||
case strings.Contains(path, "/list"): | ||
volName := strings.TrimPrefix(path, "/list/") | ||
return s.snapshotList(resp, req, volName) | ||
|
@@ -167,6 +169,17 @@ func (s *HTTPServer) snapshotList(resp http.ResponseWriter, req *http.Request, v | |
|
||
} | ||
|
||
// SnapshotClone is http handler for restore a snapshot to a persistent volume | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some more explanation might be nice. Some questions that arise here are:
You need not put these info here. But this should be answered somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Workflow is changed now, API no longer exists. |
||
func (s *HTTPServer) snapshotClone(resp http.ResponseWriter, req *http.Request) (interface{}, error) { | ||
|
||
clone, err := s.volumeAdd(resp, req) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is adding a volume. Why are we calling it as a clone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let us not reuse the methods here & inject |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return clone, nil | ||
} | ||
|
||
/*func (s *HTTPServer) getControllerIP(resp http.ResponseWriter, req *http.Request, snap.Spec.Volname string) (string, err) { | ||
voldetails, err := s.vsmRead(resp, req, snap.Spec.VolumeName) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,6 +540,14 @@ 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__" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, these are coming from the |
||
|
||
JivaReplicaTypeHolder JivaAnnotations = "clone" | ||
// JivaStorageSizeHolder is used as a placeholder for persistent volume's | ||
// storage capacity | ||
// | ||
|
@@ -611,6 +619,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(JivaReplicaTypeHolder), "--size", string(JivaStorageSizeHolder), string(JivaPersistentMountPathDef)} | ||
) | ||
|
||
// TODO | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -924,15 +924,25 @@ func MakeOrDefJivaReplicaArgs(vol *Volume, clusterIP string) []string { | |
|
||
//storSize := GetPVPStorageSize(profileMap) | ||
storSize := vol.Capacity | ||
cloneIP := vol.CloneIP | ||
|
||
repArgs := make([]string, len(JivaReplicaArgs)) | ||
if cloneIP == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe its best to avoid this |
||
for i, rArg := range JivaReplicaArgs { | ||
rArg = strings.Replace(rArg, string(JivaClusterIPHolder), clusterIP, 1) | ||
rArg = strings.Replace(rArg, string(JivaStorageSizeHolder), storSize, 1) | ||
repArgs[i] = rArg | ||
} | ||
} 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) | ||
repArgs[i] = rArg | ||
|
||
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 | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it will be good if we explain somewhere in the comments or commit or PR on:
This helps contributors as well as docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow is changed now, API no longer exists.