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

fix: mark the topolvm storageclass as default #210

Merged
merged 1 commit into from
Jun 17, 2022
Merged

fix: mark the topolvm storageclass as default #210

merged 1 commit into from
Jun 17, 2022

Conversation

nbalacha
Copy link
Contributor

This commit marks the topolvm storageClass as the default
if there are no other storageClasses that are present or
is no other class is marked default.

Signed-off-by: N Balachandran nibalach@redhat.com

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

@sp98 sp98 left a comment

Choose a reason for hiding this comment

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

nit

sc := []*storagev1.StorageClass{}
allowVolumeExpansion := true
volumeBindingMode := storagev1.VolumeBindingWaitForFirstConsumer
// defaultStorageClass := false
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// defaultStorageClass := false
// defaultStorageClass := false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

r.Log.Error(err, "failed to list storage classes. Not setting any storageclass as the default")
} else {
if len(scList.Items) == 0 {
//defaultStorageClass = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//defaultStorageClass = true
// defaultStorageClass = true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

//defaultStorageClass = true
} else {
for _, sc := range scList.Items {
v := sc.Annotations["storageclass.kubernetes.io/is-default-class"]
Copy link
Contributor

Choose a reason for hiding this comment

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

could move storageclass.kubernetes.io/is-default-class out as a variable as its used in more than one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Mark the first lvmo storage class default if no other storageclasses exist on the cluster
scList := &storagev1.StorageClassList{}
err := r.Client.List(context.TODO(), scList)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := r.Client.List(context.TODO(), scList)
err := r.Client.List(ctx, scList)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@sp98
Copy link
Contributor

sp98 commented Jun 16, 2022

Making lvmo storage class as default seems like an important detail that user should know about. Are there plans to update the docs to reflect this?

scList := &storagev1.StorageClassList{}
err := r.Client.List(context.TODO(), scList)

if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if else block can be removed and only for loop can be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to set a new var in the if block.

@@ -106,6 +129,11 @@ func getTopolvmStorageClasses(lvmCluster *lvmv1alpha1.LVMCluster) []*storagev1.S
"csi.storage.k8s.io/fstype": TopolvmFilesystemType,
},
}
// reconcile will pick up any existing LVMO storage classes as well
if defaultStorageClassName == "" || defaultStorageClassName == storageClass.Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

won't defaultStorageClassName == "" condition be enough even if the reconciler picks up existing lvmo storage classes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to handle a scenario where multiple VGs may be supported.

Comment on lines 104 to 105
if len(scList.Items) != 0 {
for _, sc := range scList.Items {

Choose a reason for hiding this comment

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

Suggested change
if len(scList.Items) != 0 {
for _, sc := range scList.Items {
for _, sc := range scList.Items {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

for _, deviceClass := range lvmCluster.Spec.Storage.DeviceClasses {
scName := "odf-lvm-" + deviceClass.Name

Choose a reason for hiding this comment

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

Should we define a new variable called scPrefix := "odf-lvm-" and use it everywhere in place of this string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would need to be done in a separate PR.

This commit marks the topolvm storageClass as default
if there are no other storageClasses that are present or
is no other class is marked default.

Signed-off-by: N Balachandran <nibalach@redhat.com>
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 17, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nbalacha, sp98

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot merged commit d79efeb into openshift:main Jun 17, 2022
@nbalacha nbalacha deleted the storageclass branch June 17, 2022 15:25
@nbalacha
Copy link
Contributor Author

/cherry-pick release-4.11

@openshift-cherrypick-robot

@nbalacha: new pull request created: #214

In response to this:

/cherry-pick release-4.11

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.

akalenyu added a commit to akalenyu/assisted-service that referenced this pull request Sep 8, 2022
Operations require a default storage class to function properly,
since we are installing those, we can also mark them default:
- Set HPP storage class as default
- LVM Operator takes care of creating and setting its storage class to default:
openshift/lvm-operator#210
So no action required.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
openshift-merge-robot pushed a commit to openshift/assisted-service that referenced this pull request Sep 14, 2022
Operations require a default storage class to function properly,
since we are installing those, we can also mark them default:
- Set HPP storage class as default
- LVM Operator takes care of creating and setting its storage class to default:
openshift/lvm-operator#210
So no action required.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
danielerez pushed a commit to danielerez/assisted-service that referenced this pull request Oct 15, 2023
Operations require a default storage class to function properly,
since we are installing those, we can also mark them default:
- Set HPP storage class as default
- LVM Operator takes care of creating and setting its storage class to default:
openshift/lvm-operator#210
So no action required.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
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.

4 participants