Skip to content

Conversation

@rohan47
Copy link
Contributor

@rohan47 rohan47 commented Nov 27, 2025

delete nfs driver if nfs is not enabled and nfs driver exists, also there are no PVCs using nfs storageclass
DFBUGS-4704

@openshift-ci
Copy link

openshift-ci bot commented Nov 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

Comment on lines 717 to 719
nfsDriver := &csiopv1.Driver{}
nfsDriver.Name = templates.NfsDriverName
nfsDriver.Namespace = c.OperatorNamespace
Copy link
Member

@Nikhil-Ladha Nikhil-Ladha Nov 28, 2025

Choose a reason for hiding this comment

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

We can move this from here and the if condition above, to the outside block in someway like this:

nfsDriver := &csiopv1.Driver{
    Name: templates.NfsDriverName,
    Namespace: c.OperatorNamespace
}

@rohan47
Copy link
Contributor Author

rohan47 commented Nov 28, 2025

/hold
testing changes

return nil
}

func (c *OperatorConfigMapReconciler) hasPVsWithNfsDriver() (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the need to spread the functionality across multiple functions, a single func per type would do and list with matchingfield + limit of 1.

return nil
}

func (c *OperatorConfigMapReconciler) hasPVsWithNfsDriver() (bool, error) {
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
func (c *OperatorConfigMapReconciler) hasPVsWithNfsDriver() (bool, error) {
func (c *OperatorConfigMapReconciler) hasPersistentVolumesWithNfsDriver() (bool, error) {

after the first usage your ide would autocomplete and no need to shorten it, in other controllers we aren't shortening it.

return len(pvList.Items) > 0, nil
}

func (c *OperatorConfigMapReconciler) hasSnapshotsWithNfsDriver() (bool, error) {
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
func (c *OperatorConfigMapReconciler) hasSnapshotsWithNfsDriver() (bool, error) {
func (c *OperatorConfigMapReconciler) hasVolumeSnapshotContentsWithNfsDriver() (bool, error) {

the existing one is misleading, we are checking for vsc but not for vs.

return fmt.Errorf("failed to reconcile nfs driver: %v", err)
}
} else {
if hasPVs, err := c.hasPVsWithNfsDriver(); 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.

Suggested change
if hasPVs, err := c.hasPVsWithNfsDriver(); err != nil {
if hasPvs, err := c.hasPVsWithNfsDriver(); err != nil {

c.log.Info("NFS driver has PVs, skipping deletion")
return nil
}
if hasSnapshots, err := c.hasSnapshotsWithNfsDriver(); 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.

Suggested change
if hasSnapshots, err := c.hasSnapshotsWithNfsDriver(); err != nil {
if hasVscs, err := c.hasSnapshotsWithNfsDriver(); err != nil {

if hasSnapshots, err := c.hasSnapshotsWithNfsDriver(); err != nil {
return fmt.Errorf("failed to check if NFS driver has snapshots: %v", err)
} else if hasSnapshots {
c.log.Info("NFS driver has snapshots, skipping deletion")
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
c.log.Info("NFS driver has snapshots, skipping deletion")
c.log.Info("NFS driver has volumesnapshotcontents, skipping deletion")

return nil
}
if hasSnapshots, err := c.hasSnapshotsWithNfsDriver(); err != nil {
return fmt.Errorf("failed to check if NFS driver has snapshots: %v", err)
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
return fmt.Errorf("failed to check if NFS driver has snapshots: %v", err)
return fmt.Errorf("failed to check if NFS driver has volumesnapshotcontents: %v", err)

if hasPvs, err := c.hasPersistentVolumesWithNfsDriver(); err != nil {
return fmt.Errorf("failed to check if NFS driver has PVs: %v", err)
} else if hasPvs {
c.log.Info("NFS driver has PVs, skipping deletion")

Choose a reason for hiding this comment

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

Do we really need to log this info?

return fmt.Errorf("failed to check if NFS driver has volumesnapshotcontents: %v", err)
} else if hasVscs {
c.log.Info("NFS driver has volumesnapshotcontents, skipping deletion")
return nil

Choose a reason for hiding this comment

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

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants