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

feat: support unclear stale pvc #167

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions provisioner/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const (
// NFSBackendPvcTimeout defines env name to store BackendPvcBoundTimeout value
NFSBackendPvcTimeout menv.ENVKey = "OPENEBS_IO_NFS_SERVER_BACKEND_PVC_TIMEOUT"

// NFSCleanUpStalePvcEnable defines env name to store the value of clean stale pvc enable
NFSCleanUpStalePvcEnable menv.ENVKey = "OPENEBS_IO_NFS_SERVER_CLEANUP_STALE_PVC_ENABLE"

Choose a reason for hiding this comment

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

This flag essentially enables/disables garbage collection. Even though the garbage collection currently removes stale PVCs, maybe the flag should be instead called OPENEBS_IO_NFS_SERVER_GARBAGE_COLLECTION_ENABLED? Then in case the logic of what the garbage collector does is changed, this flag won't be misleading :)

Copy link
Contributor Author

@njuptlzf njuptlzf Nov 20, 2023

Choose a reason for hiding this comment

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

Even though the garbage collection currently removes stale PVCs, maybe the flag should be instead called OPENEBS_IO_NFS_SERVER_GARBAGE_COLLECTION_ENABLED?

sounds good

Then in case the logic of what the garbage collector does is changed, this flag won't be misleading

Yes, when the logic of cleanup is optimized, we actually do not need to turn off recycling. Currently, only for data recovery scenarios, completely turning off can solve my problem.


// NFSServerImagePullSecret defines the env name to store the name of the image pull secret
NFSServerImagePullSecret menv.ENVKey = "OPENEBS_IO_NFS_SERVER_IMAGE_PULL_SECRET"
)
Expand Down Expand Up @@ -105,6 +108,10 @@ func getBackendPvcTimeout() string {
return menv.Get(NFSBackendPvcTimeout)
}

// OPENEBS_IO_NFS_SERVER_CLEAN_STALE_PVC_ENABLE
func getNfsServerCleanUpStalePvcEnable() string {
return menv.Get(NFSCleanUpStalePvcEnable)
}
func getNfsServerImagePullSecret() string {
return menv.GetOrDefault(NFSServerImagePullSecret, "")
}
14 changes: 12 additions & 2 deletions provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,18 @@ func NewProvisioner(ctx context.Context, kubeClient *clientset.Clientset) (*Prov
// and maintain it in cache
go k8sNodeInformer.Run(ctx.Done())

// Running garbage collector to perform cleanup for stale NFS resources
go RunGarbageCollector(ctx, kubeClient, pvTracker, nfsServerNs)
cleanUpStalePvcStr := getNfsServerCleanUpStalePvcEnable()
cleanUpStalePvcEnable, err := strconv.ParseBool(cleanUpStalePvcStr)
if err != nil {
klog.Warningf("Invalid cleanUpStalePvc value=%s, using default value=true", cleanUpStalePvcStr)
cleanUpStalePvcEnable = true
}
if cleanUpStalePvcEnable {
// Running garbage collector to perform cleanup for stale NFS resources
go RunGarbageCollector(ctx, kubeClient, pvTracker, nfsServerNs)
} else {
klog.Warningf("CleanUpStalePvc is disabled")
}

return p, nil
}
Expand Down
Loading