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

Add tuning option of AccessModes for Kubevirt NodePool root volume #1583

Merged

Conversation

orenc1
Copy link
Contributor

@orenc1 orenc1 commented Jul 18, 2022

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

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@netlify
Copy link

netlify bot commented Jul 18, 2022

Deploy Preview for hypershift-docs ready!

Name Link
🔨 Latest commit 6374caa
🔍 Latest deploy log https://app.netlify.com/sites/hypershift-docs/deploys/62dfebbaef74d000088747af
😎 Deploy Preview https://deploy-preview-1583--hypershift-docs.netlify.app/reference/api
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@openshift-ci openshift-ci bot requested review from csrwng and enxebre July 18, 2022 20:46
@orenc1 orenc1 force-pushed the rootvolume_accessmode_tuning branch 2 times, most recently from c2ab0e8 to c7de7c9 Compare July 19, 2022 08:13
@orenc1
Copy link
Contributor Author

orenc1 commented Jul 19, 2022

/retest

Copy link
Contributor

@davidvossel davidvossel left a 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

Comment on lines 450 to 454
// 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"`
Copy link
Contributor

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"`


Copy link
Contributor Author

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.

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 @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?

@orenc1 orenc1 force-pushed the rootvolume_accessmode_tuning branch 2 times, most recently from 8bd0022 to 094f37f Compare July 24, 2022 16:26
@orenc1
Copy link
Contributor Author

orenc1 commented Jul 24, 2022

/retest

Copy link
Contributor

@davidvossel davidvossel left a 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@orenc1 orenc1 force-pushed the rootvolume_accessmode_tuning branch 2 times, most recently from 250314d to 6d3e43c Compare July 26, 2022 11:37
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>
@orenc1 orenc1 force-pushed the rootvolume_accessmode_tuning branch from 6d3e43c to 6374caa Compare July 26, 2022 13:27
Copy link
Contributor

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 26, 2022
@csrwng
Copy link
Contributor

csrwng commented Jul 28, 2022

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 29, 2022

[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:
  • OWNERS [alvaroaleman,csrwng]

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 29, 2022

@orenc1: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws 6374caa link false /test e2e-aws

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.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 2 against base HEAD d74698b and 8 for PR HEAD 6374caa in total

@openshift-merge-robot openshift-merge-robot merged commit a78f398 into openshift:main Jul 30, 2022
@orenc1 orenc1 deleted the rootvolume_accessmode_tuning branch July 31, 2022 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants