-
Notifications
You must be signed in to change notification settings - Fork 371
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
Add Snapshot APIs #6
Conversation
// VolumeSnapshotConditionUploading means the snapshot is cut and the application | ||
// can resume accessing data if ConditionStatus is True. It corresponds | ||
// to "Uploading" in GCE PD or "Pending" in AWS and ConditionStatus is True. | ||
// This condition type is not applicable in OpenStack Cinder. |
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.
maybe make this comment a little more generic. "Uploading" condition is only applicable to the volume plugins which support uploading snapshots to Cloud storage. For example, it corresponds to snapshot "UPLOADING" status in GCE and ...
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.
Done
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.
I didn't see the change?
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.
"VolumeSnapshotConditionUploading means the snapshot is cut" doesn't seem like a correct condition to monitor to determine if creation has completed (means the snapshot is cut and the application can resume accessing data), for a few reasons:
- it appears to only apply to some volume plugins... if they don't upload data, this condition would never be true
- it is transient... once uploaded, this condition would no longer be true
- it is not necessarily mutually exclusive with "Creating"... a plugin could conceivably start streaming an upload while it was still in the process of creating the snapshot
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.
- it appears to only apply to some volume plugins... if they don't upload data, this condition would never be true
that's right
- it is transient... once uploaded, this condition would no longer be true
right. Snapshot creation goes through a few phases: e.g., in GCE PD, we have CREATING, UPLOADING, and READY. Both creating and uploading are transient. Once that phase passes, the condition is no longer true.
- it is not necessarily mutually exclusive with "Creating"... a plugin could conceivably start streaming an upload while it was still in the process of creating the snapshot
I think they are mutually exclusive. After the snapshot is cut, it is no longer in "creating" phase, and either go to "uploading" phase, or directly move to "ready" phase if no uploading is performed.
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.
I read the updated condition guideline again, and have the following thoughts.
Condition should be considered as observations that users cared about instead of state-machine phases. For snapshot, user cares about whether snapshot is created successfully or not first. These can be represented by "ready" and "failed" conditions. The other condition user cares about is when the snapshot is taken (or cut). Because some plugins support uploading which might take a long time. User needs to know when the snapshot is taken (usually in a second) so that application can be resumed. So we could add another condition "snapshotTaken" (or just "Taken") condition. So now we have three conditions "snapshotTaken", "snapshotReady" and "snapshotFailed"
During the snapshot creation, we might see the following conditions at different times.
- First when user create VolumeSnapshot object, there is no condition yet. (means controller is working on it, but there is no observed state available yet)
- The volume plugin starts to create the snapshot. When the snapshot is taken (cut), controller will get a response and add "SnapshotTaken" condition to true. If snapshot is failed, it will be set to false. If there is no uploading phase, Ready condition will also be true right after snapshot is taken.
- If there is an uploading phase, the controller will add "Ready" condition to true after uploading finishes. If uploading failed, the condition is set to false.
Please let me know if you have any feedback/comment about it. Thanks!
// to "Uploading" in GCE PD or "Pending" in AWS and ConditionStatus is True. | ||
// This condition type is not applicable in OpenStack Cinder. | ||
VolumeSnapshotConditionUploading VolumeSnapshotConditionType = "Uploading" | ||
// VolumeSnapshotConditionReady is added when the snapshot has been successfully created and is ready to be used. |
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.
change "is added" to "means"
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.
Done
VolumeSnapshotConditionError VolumeSnapshotConditionType = "Error" | ||
) | ||
|
||
// VolumeSnapshotCondition describes the state of a volume snapshot at a certain point. |
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.
remove at a certain point.
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.
Done.
|
||
// Spec represents the desired state of the snapshot | ||
// +optional | ||
Spec VolumeSnapshotSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` |
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.
I think Spec should be required
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.
PersistentVolumeClaimSpec is optional in PersistentVolumeClaim API object. Should we be consistent with that?
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.
We discussed with @liggitt and we think it should be required also for PersistentVolumeClaimSpec.
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.
Ok
type VolumeSnapshotSpec struct { | ||
// PersistentVolumeClaimName is the name of the PVC being snapshotted | ||
// +optional | ||
PersistentVolumeClaimName string `json:"persistentVolumeClaimName" protobuf:"bytes,1,opt,name=persistentVolumeClaimName"` |
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.
this is also a required field
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.
I think by leaving this one optional, we can support static binding?
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.
oh, I think you are right
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||
|
||
// Spec represents the desired state of the snapshot | ||
// +optional |
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.
spec should be required?
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.
I see that PersistentVolumeSpec is an optional field in PersistentVolume. So we should probably be consistent with that?
// +optional | ||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||
|
||
Items []VolumeSnapshotData `json:"items" protobuf:"bytes,2,rep,name=items"` |
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.
better to add comments to all fields?
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.
Added.
// VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot | ||
// and VolumeSnapshotData | ||
// +optional | ||
VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,2,opt,name=volumeSnapshotRef"` |
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.
also required field?
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.
I see that ClaimRef is an optional field in PersistentVolumeSpec. It becomes non-nil when bound. I'll add a comment here.
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.
ok.
// PersistentVolumeRef represents the PersistentVolume that the snapshot has been | ||
// taken from | ||
// +optional | ||
PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef" protobuf:"bytes,3,opt,name=persistentVolumeRef"` |
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.
required field?
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.
Similarly, this becomes non-nil when bound.
// Required. | ||
SnapshotHandle string `json:"snapshotHandle"` | ||
|
||
// Timestamp when the point-in-time snapshot is taken on the storage |
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.
it is not very clear that which time is used here.
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.
This timestamp will be generated by the CSI driver after the snapshot is cut. I'll add this to the comment.
cc @liggitt |
cc @saad-ali |
|
||
const ( | ||
// VolumeSnapshotDataResourcePlural is "volumesnapshotdatas" | ||
VolumeSnapshotDataResourcePlural = "volumesnapshotdatas" |
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.
"datas" is not a correct plural
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 have a suggestion for this? "data" is a plural itself. How do we differentiate between singular and plural if they are the same?
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.
Looks like "volumesnapshotdatas" will be generated automatically for clientset when generating code for the CRD. So unless if we rename VolumeSnapshotData to something else, it will be "volumesnapshotdatas".
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.
Looks like "volumesnapshotdatas" will be generated automatically for clientset when generating code for the CRD. So unless if we rename VolumeSnapshotData to something else, it will be "volumesnapshotdatas".
That's correct, and is a gap in the client generator. This has also been reported by others (see https://kubernetes.slack.com/archives/C0EG7JC6T/p1528416072000218). However, we shouldn't accept an incorrect API because of that... it would be better to participate in improving the generator to allow specifying the plural (or rename the VolumeSnapshotData type)
// VolumeSnapshotConditionType is the type of VolumeSnapshot conditions | ||
type VolumeSnapshotConditionType string | ||
|
||
// These are valid conditions of a volume snapshot. |
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.
would recommend reviewing the updated condition guidelines in https://github.com/kubernetes/community/pull/2350/files
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.
Changed VolumeSnapshotConditionType to "Created", "Available", and "Error" following today's discussion during the snapshot design meeting.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// VolumeSnapshotData represents the actual "on-disk" snapshot object | ||
type VolumeSnapshotData struct { |
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.
is the relationship between VolumeSnapshot and VolumeSnapshotData 1:1
or 1:*
?
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.
it is 1:1
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.
Renamed VolumeSnapshotData to VolumeSnapshotContent.
cc @thockin |
3c74892
to
c14d975
Compare
// addKnownTypes adds the set of types defined in this package to the supplied scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&SnapshotClass{}, |
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.
To be consistent with all the objects, I think they should all start with either "Snapshot" or "VolumeSnapshot", but not a mix.
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.
Ok, will change to VolumeSnapshotClass.
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.
Done
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// VolumeSnapshotContent represents the actual "on-disk" snapshot object | ||
type VolumeSnapshotContent struct { |
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.
I know we had some discussion on this in the last call. Wouldn't VolumeSnapshotClaim or VolumeSnapshotRequest as the user-facing object and VolumeSnapshot as the storage backend representation be better names? These names follow the PersistentVolumeClaim-PersistentVolume convention and can be pluralized.
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.
Unfortunately, PersistentVolumeClaim does not follow the name pattern as all other user-facing objects. For example, we don't use PodClaim to represent user's pod. We think we should have named PVC and PV as PersistentVolume (user) and PersistentVolumeContent (system admin) at the first place. So instead of following the wrong pattern, we decided to use VolumeSnapshot to represent the user's snapshot.
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.
PVCs don't follow other user-facing objects because other objects don't follow the dual-object model where we have a request and a response or a user-facing representation and an internal representation, but I agree with you that it's better not to follow the wrong pattern and have the more straightforward name (i.e., VolumeSnapshot) exposed to the users.
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.
OK I'm late to to conversation so don't really have much right to input. I would prefer sticking to the PVC/PV pattern even if you belive it is wrong as it exists now. I personally don't belive it is incorrect as @kangarlou says nothing else follows the request response pattern. It will make users familiar with the PVC/PV pattern pick it up easier. All through reading it I was trying to map it to PVC/PV model.
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.
sorry to reply late. Yes, naming is hard. But since we have been using these names for a while, we decided to continue use these names. The relationship between snapshot and its content is very similar to pvc/pv.
CreatedAt int64 `json:"createdAt,omitempty" protobuf:"varint,3,opt,name=createdAt"` | ||
} | ||
|
||
// GetObjectKind is required to satisfy Object interface |
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.
the following is not need, so can remove these lines.
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.
Sure. I'll take a look. Thanks.
0bc5a94
to
a12ed3e
Compare
// +optional | ||
AvailableAt *metav1.Time `json:"availableAt" protobuf:"bytes,2,opt,name=availableAt"` | ||
// Bound is set to true only if the snapshot is ready to use (e.g., finish uploading if | ||
// there is an uplaoding phase) and also VolumeSnapshot andn its VolumeSnapshotContent |
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.
s/uplaoding/uploading
s/andn/and
@@ -93,15 +88,17 @@ type VolumeSnapshotList struct { | |||
|
|||
// VolumeSnapshotSpec is the desired state of the volume snapshot | |||
type VolumeSnapshotSpec struct { | |||
// PersistentVolumeClaimName is the name of the PVC being snapshotted | |||
// PersistentVolumeClaimName is the name of the PVC being snapshotted. | |||
// If not specified, user can create SnapshotContent and bind it with VolumeSnapshot manually. |
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.
s/SnapshotContent/VolumeSnapshotContent
// +optional | ||
AvailableAt *metav1.Time `json:"availableAt" protobuf:"bytes,2,opt,name=availableAt"` | ||
// Bound is set to true only if the snapshot is ready to use (e.g., finish uploading if | ||
// there is an uploading phase) and also VolumeSnapshot andn its VolumeSnapshotContent |
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.
s/andn/and
This PR adds generated files under pkg/client and vendor folder.
This PR adds snapshot APIs as CRD.
8c7dcf1
to
3832c9d
Compare
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.
lgtm!
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.
/lgtm
/approve
// Represents the source from CSI volume snapshot | ||
type CSIVolumeSnapshotSource struct { | ||
// Driver is the name of the driver to use for this snapshot. | ||
// Required. |
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.
Please add:
// This MUST be the same name returned by the CSI GetPluginName() call for
// that driver.
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.
Sure.
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||
|
||
// Spec represents the desired state of the snapshot data | ||
Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` |
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.
No status in VolumeSnapshotContent
? No way to know if the object is bound or not?
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.
We had status in VolumeSnapshotContent earlier on but decided to drop it because it is exactly the same as status in VolumeSnapshot. Now we just use "Ready" in VolumsSnapshotStatus to let user know it is bound and snapshot is ready for use.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: saad-ali, xing-yang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR adds snapshot APIs as CRD and adds generated files.
The design doc is kubernetes/community#2335