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

Update VolumeGroupSnapshot to v1beta1 #1150

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

leonardoce
Copy link
Contributor

@leonardoce leonardoce commented Aug 30, 2024

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

Update the definition of CRDs to move VolumeGroupSnapshot, VolumeGroupSnapshotContent, and VolumeGroupSnapshotClass from v1alpha1 to v1beta1.

cc: @xing-yang

Which issue(s) this PR fixes:

Fixes #1119

Special notes for your reviewer:

This PR entirely removes the capability to serve the v1alpha version. Existing clients will be broken.
This is consistent with the relative PR comment and the related Kubernetes documentation.

The underlying structure of v1alpha and v1beta1 is consistent.

Does this PR introduce a user-facing change?:

`VolumeGroupSnapshot`, `VolumeGroupSnapshotContent`, and `VolumeGroupSnapshotClass`
are now available in `v1beta1` version. The support for the `v1alpha1` version have been removed.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: leonardoce
Once this PR has been reviewed and has the lgtm label, please assign msau42 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 30, 2024
@nixpanic
Copy link
Member

nixpanic commented Oct 1, 2024

/cc xing-yang

@leonardoce
Copy link
Contributor Author

I rebased this PR and added a commit to add and set the new field VolumeSnapshotHandlePairList of the VolumeGroupSnapshotContent resource, as described in the latest iteration of the relative KEP.

Thank you!

cc: @xing-yang

Copy link
Contributor

@yati1998 yati1998 left a comment

Choose a reason for hiding this comment

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

LGTM

@xing-yang
Copy link
Collaborator

@leonardoce We discussed this PR during today's CSI Implementation meeting. @jsafrane suggested that we break this PR into two PRs.

@leonardoce
Copy link
Contributor Author

Ok. I'll close it and file the one to add the new field

@yati1998
Copy link
Contributor

Ok. I'll close it and file the one to add the new field
@leonardoce can we please have any timeline by when can we get this done?

@leonardoce
Copy link
Contributor Author

Hi @yati1998. I filed PR #1169 to add the new field.

@leonardoce
Copy link
Contributor Author

/draft

@leonardoce leonardoce marked this pull request as draft October 23, 2024 15:34
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 23, 2024
@mulbc
Copy link

mulbc commented Oct 28, 2024

#1169 has been merged - can we merge this PR now?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2024
@yati1998
Copy link
Contributor

yati1998 commented Nov 6, 2024

@leonardoce can I know why this PR is in draft? I think we were good on this part?

@leonardoce
Copy link
Contributor Author

Hi @yati1998.
According to this plan: https://docs.google.com/document/d/1jjliw0tFhCPnT9ixlYpj61k5u8_-awf1qSCWrkunshQ/edit?tab=t.0#heading=h.fizenae5evi0
We need at least #1177 to be merged before this one.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2024
@xing-yang
Copy link
Collaborator

Can you please rebase?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2024
@yati1998
Copy link
Contributor

@gnufied can you please review this as well?

@@ -1,5 +1,5 @@
---
apiVersion: groupsnapshot.storage.k8s.io/v1alpha1
apiVersion: groupsnapshot.storage.k8s.io/v1beta1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi! If you are referring to app.kubernetes.io/name: postgresql, that's just the selector this example uses to get the PVC list. I don't think we need to change it 👍

@xing-yang
Copy link
Collaborator

@leonardoce Please ignore my comments:)

@gnufied
Copy link
Contributor

gnufied commented Nov 22, 2024

We should compile this branch rebased with master and then run e2e tests in a loop for sometime. I have often done this for testing pre-release code which needs more testing. This will give us greater confidence about this feature. This does not require making a release.

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// +kubebuilder:object:generate=true
package v1alpha1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is VolumeGroupSnapshot.Status.CreationTime --> metav1.Time and why is VolumeGroupSnapshotContentStatus.CreationTime --> int64 ?

I know that change was not introduced in this PR, but since we are moving this to beta, we have to be careful about all the decisions we make.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same is happening with independent VolumeSnapshots:

CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"`

vs:

CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"`

The content object looks more directly related to the GRPC CSI call.

Copy link
Contributor

@gnufied gnufied Nov 22, 2024

Choose a reason for hiding this comment

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

This is how it is displayed in CLI (via kubectl ) then:

  creationTime: "2024-11-22T22:14:35Z"
  creationTime: 1732313675689050917

@xing-yang can you confirm if this intentional? This doesn't seem right.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can always convert int64 to metav1.Time so as this is nicely handled by k8s tooling. I am not sure if this has to be int64...

Copy link
Collaborator

Choose a reason for hiding this comment

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

In CSI spec, the timestamp is .google.protobuf.Timestamp which represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. So in VolumeSnapshotContent and VolumeGroupSnapshotContent, it is a direct mapping to what is returned from the CSI driver.
VolumeSnapshot and VolumeGroupSnapshot are in user namespace, we try to show them nicely in the readable format of metav1.Time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

VolumeSnapshotContent and VolumeGroupSnapshotContent are admin API objects. We don't need to show them in user readable format. I think they should stay true to the original values returned by the CSI driver.
Since we've already made a decision for this in VolumeSnapshotContent, it also looks inconsistent now if we are showing them differently in VolumeGroupSnapshotContent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having time represented as int64 imo causes unnecessary indirection for person reading the output of kubectl.

status:
  creationTime: 1732377314333256450
  readyToUse: true
  volumeGroupSnapshotHandle: 53e1f6ce-a9b3-11ef-adf7-88c9b3b05f70
  volumeSnapshotHandlePairList:
  - snapshotHandle: 53e1f6e0-a9b3-11ef-adf7-88c9b3b05f70
    volumeHandle: 4711d50d-a9b3-11ef-adf7-88c9b3b05f70

I understand we made this decision for volumesnapshotcontent already, but this seems like making one bad choice to cover another. I could be wrong of course, @jsafrane @msau42 what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since VolumeSnapshot and VolumeGroupSnapshot already have timestamps shown in user readable format, my preference is to keep the timestamps in VolumeSnapshotContent and VolumeGroupSnapshotContent the same as what is returned by the CSI driver as they are admin facing, but let's see what @jsafrane and @msau42 think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@leonardoce can you please update the comments with the highlighted text?

type VolumeGroupSnapshotStatus struct {
..........
// CreationTime is the timestamp when the point-in-time group snapshot is taken
// by the underlying storage system.
// If not specified, it may indicate that the creation time of the group snapshot
// is unknown.
// The format of this field is a Unix nanoseconds time encoded as an int64.
// On Unix, the command date +%s%N returns the current time in nanoseconds
// since 1970-01-01 00:00:00 UTC.
// This field is updated based on the CreationTime field in VolumeGroupSnapshotContentStatus
// +optional
CreationTime *metav1.Time json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"

type VolumeGroupSnapshotContentStatus struct {
..........
// CreationTime is the timestamp when the point-in-time group snapshot is taken
// by the underlying storage system.
// If not specified, it indicates the creation time is unknown.
// If not specified, it means the readiness of a group snapshot is unknown.
// The format of this field is a Unix nanoseconds time encoded as an int64.
// On Unix, the command date +%s%N returns the current time in nanoseconds
// since 1970-01-01 00:00:00 UTC.
// This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
// +optional
CreationTime *int64 json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I improved the comments @xing-yang.

@gnufied
Copy link
Contributor

gnufied commented Nov 23, 2024

I noticed that following field in volumeGroupSnapshot.Status is user editable after setting it:

BoundVolumeGroupSnapshotContentName *string `json:"boundVolumeGroupSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=boundVolumeGroupSnapshotContentName"`

Should this be immutable after creation?

@xing-yang
Copy link
Collaborator

I noticed that following field in volumeGroupSnapshot.Status is user editable after setting it:

BoundVolumeGroupSnapshotContentName *string json:"boundVolumeGroupSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=boundVolumeGroupSnapshotContentName"
Should this be immutable after creation?

This field is in the Status. Are we supposed to make fields in Status immutable? We have not done that for VolumeSnapshot APIs.

@gnufied
Copy link
Contributor

gnufied commented Nov 24, 2024

This field is in the Status. Are we supposed to make fields in Status immutable? We have not done that for VolumeSnapshot APIs.

It would have been nice to have. But not a blocker I think.

// VolumeSnapshotContentRef is a reference to the volume snapshot content resource
VolumeSnapshotContentRef core_v1.LocalObjectReference `json:"volumeSnapshotContentRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentRef"`
}

// VolumeGroupSnapshotContentSource represents the CSI source of a group snapshot.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not visible in PR - Can VolumeHandle and SnapshotHandle inside VolumeSnapshotHandlePair be empty? Or they both have to be specified. I didn't see these fields marked as required and neither see any validation kinda logic preventing saving of these fields without any values. Correct me if I missed something.

Copy link
Collaborator

Choose a reason for hiding this comment

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

VolumeSnapshotHandlePair itself is not required, but if a VolumeSnapshotHandlePair is specified, then both VolumeHandle and SnapshotHandle should be required. Otherwise, it is not very useful.
We can add CEL for them.

Copy link
Contributor

@gnufied gnufied Nov 25, 2024

Choose a reason for hiding this comment

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

We can add CEL for them.

Yeah we should IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@leonardoce Can you make changes to make VolumeHandle and SnapshotHandle required in VolumeSnapshotHandlePair?

Copy link
Contributor Author

@leonardoce leonardoce Nov 25, 2024

Choose a reason for hiding this comment

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

Sure! I think it's better to file a different PR for that and keep this as a giant substitution. If we use this PR to review the API, it will become really difficult to rebase.

Is that fine with you @gnufied ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The main reason I wanted all API changes in same PR is, so as we don't have to do follow up API fixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gnufied I see both fields are already marked as required (meaning they are not optional) in the CRD.
See:

volumeSnapshotHandlePairList:
description: |-
VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
pair returned by the CSI driver to identify snapshots and their source volumes
on the storage system.
items:
description: VolumeSnapshotHandlePair defines a pair of a source
volume handle and a snapshot handle
properties:
snapshotHandle:
description: |-
SnapshotHandle is a unique id returned by the CSI driver to identify a volume
snapshot on the storage system
type: string
volumeHandle:
description: |-
VolumeHandle is a unique id returned by the CSI driver to identify a volume
on the storage system
type: string
required:
- snapshotHandle
- volumeHandle
type: object

Do you still need me to add some CEL rules for them? Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

That should be sufficient. The API server will reject it if VolumeHandle or SnapshotHandle is not set in VolumeSnapshotHandlePair.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add "// Required." as comments for both VolumeHandle and SnapshotHandle in types.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it and rebased the PR too.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2024
@Madhu-1
Copy link
Contributor

Madhu-1 commented Nov 25, 2024

@gnufied @xing @leonardoce i have tested this PR + #1219 https://jenkins-ceph-csi.apps.ocp.cloud.ci.centos.org/blue/organizations/jenkins/mini-e2e_k8s-1.31/detail/mini-e2e_k8s-1.31/201/pipeline/ ceph/ceph-csi#4974 (we already have framework for volumegroupsnapshot)

This is what it does

  • Create 3 PVC
  • Create a groupsnapshot
  • Create a clones from the 3 snapshots (as part of group)
  • Create pod using the clones
  • Delete the pod
  • Delete the clones
  • Delete the group
  • Delete the PVC

Repeat the above in a loop of 20 , let me know if you guys wants me to test anything else?

@leonardoce leonardoce force-pushed the update-vgs-beta branch 3 times, most recently from f866a51 to 529df83 Compare November 26, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update VolumeGroupSnapshot CRDs to v1beta1
8 participants