-
Notifications
You must be signed in to change notification settings - Fork 330
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 tuning option of AccessModes for Kubevirt NodePool root volume #1583
Add tuning option of AccessModes for Kubevirt NodePool root volume #1583
Conversation
✅ Deploy Preview for hypershift-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
c2ab0e8
to
c7de7c9
Compare
/retest |
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 great! i left one comment in line
api/v1alpha1/nodepool_types.go
Outdated
// AccessModes is an array that contains the desired Access Modes the root volume should have. | ||
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes | ||
// | ||
// +optional | ||
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"` |
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 talked a bit about this out of band. Maybe we can perform some validation on these AccessModes to prevent someone from adding something invalid that's just going to result in the cluster not forming.
I'm pretty sure the system won't catch an issue with the access mode until the kubevirt controllers actually attempt to provision the storage using the datavolume api. Pushing this validation up a bit would provide a faster feedback loop for users.
If you feel comfortable with the idea, i believe it's possible for this validation to live on the crd schema. It might require some kubebuilder trickery where we create a PersistentVolumeMode local to this api that references the corev1 one... Maybe something like
// +kubebuilder:validation:Enum=ReadWriteOnce;ReadWriteMany;ReadOnly;ReadWriteOncePod
type PersistentVolumeAccessMode corev1.PersistentVolumeAccessMode
// AccessModes is an array that contains the desired Access Modes the root volume should have.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
//
// +optional
AccessModes []PersistentVolumeAccessMode `json:"accessModes,omitempty"`
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.
Thanks @davidvossel for the suggestion.
However, this creates a problem in a sense that the "local" type of PersistentVolumeAccessMode
when we want to assign that array into dataVolume.Spec.Storage.AccessModes
when the DV is creates according to the NodePool configuration:
https://github.com/openshift/hypershift/pull/1583/files#diff-276580ea82853abc6e9445605e0303e4881c564bcd9a67b87f5f7f7c6d5fff04R169
If we do that, the assignment is not possible:
Cannot use 'kvPlatform.RootVolume.Persistent.AccessModes' (type []"github.com/openshift/hypershift/api/v1alpha1".PersistentVolumeAccessMode) as the type []PersistentVolumeAccessMode
If we want to do this, we'll need to perform a casting between these types, entry by entry.
Do you see another option for us to use CRD validation using kubebuilder markers?
Thanks.
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.
Hi @davidvossel ,
I've managed to get that working by casting the slice elements from the local type to the corev1.PersistentVolumeAccessMode
type.
Now, a creation of a NodePool with unrecognized AccessMode is getting rejected by the API Server thanks to the CRD validation:
$ ./bin/hypershift create nodepool kubevirt --name oren-nodepool --root-volume-size 16 --root-volume-access-modes ReadWriteMany,ReadWriteOnce,david --cluster-name $CLUSTER_NAME
2022-07-24T16:19:50+03:00 ERROR Failed to create nodepool [...]
Error: NodePool.hypershift.openshift.io "oren-nodepool" is invalid: spec.platform.kubevirt.rootVolume.persistent.accessModes[2]: Unsupported value: "david": supported values: "ReadWriteOnce", "ReadWriteMany", "ReadOnly", "ReadWriteOncePod"
When submitting valid values only to --root-volume-access-modes
, they are getting into the DV and the PVC, in order.
Could you please re-review?
8bd0022
to
094f37f
Compare
/retest |
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.
your crd validation logic makes sense to me. I added one comment inline.
if kvPlatform.RootVolume.Persistent.StorageClass != nil { | ||
dataVolume.Spec.Storage.StorageClassName = kvPlatform.RootVolume.Persistent.StorageClass | ||
} | ||
if kvPlatform.RootVolume.Persistent.AccessModes != nil { |
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.
shouldn't this be something like...
if len(kvPlatform.RootVolume.Persistent.AccessModes) != 0 {
otherwise i'm pretty sure this condition will always != nil
which means the if statement wouldn't really be necessary.
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.
Right, because it is an array so it can't be nil.
Fixing, thanks.
250314d
to
6d3e43c
Compare
This PR adds a --root-volume-access-modes CLI option that will be used for the AccessModes in the root volume PVCs for kubevirt NodePools. Signed-off-by: orenc1 <ocohen@redhat.com>
6d3e43c
to
6374caa
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
Thanks!
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, csrwng, orenc1 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 |
@orenc1: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Signed-off-by: orenc1 ocohen@redhat.com
What this PR does / why we need it:
This PR adds a
--root-volume-access-modes
CLI option that will be used for the AccessModes in the root volume PVCs for kubevirt NodePools.Which issue(s) this PR fixes (optional, use
fixes #<issue_number>(, fixes #<issue_number>, ...)
format, where issue_number might be a GitHub issue, or a Jira story:Fixes #
Checklist