Skip to content

Commit 32c8284

Browse files
chhnbcheyang
andauthored
Add comments to invokeCleanCache in pkg\ddc\goosefs\cache.go (#4808)
* Add comments to invokeCleanCache in pkg\ddc\goosefs\cache.go Signed-off-by: chh <522024330002@smail.nju.edu.cn> * Gofmt pkg/ddc/goosefs/cache.go Signed-off-by: cheyang <cheyang@163.com> --------- Signed-off-by: chh <522024330002@smail.nju.edu.cn> Signed-off-by: cheyang <cheyang@163.com> Co-authored-by: cheyang <cheyang@163.com>
1 parent ddbd5bc commit 32c8284

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

pkg/ddc/goosefs/cache.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,21 @@ func (e *GooseFSEngine) GetCacheHitStates() (cacheHitStates cacheHitStates) {
102102
return
103103
}
104104

105-
// clean cache
105+
// invokeCleanCache cleans the cache for a specified path in the GooseFS cluster.
106+
// This function ensures that the master pod is ready before initiating the clean action.
107+
// If the master pod is not available or not ready, the function logs the issue and exits gracefully.
108+
// Otherwise, it proceeds to clean the cache using the GooseFS file utilities.
106109
func (e *GooseFSEngine) invokeCleanCache(path string) (err error) {
107-
// 1. Check if master is ready, if not, just return
110+
// 1. Check if the master pod is ready. If not, log the status and return without performing any action.
108111
masterName := e.getMasterName()
109112
master, err := kubeclient.GetStatefulSet(e.Client, masterName, e.namespace)
110113
if err != nil {
114+
// Ignore "not found" errors and exit gracefully.
111115
if utils.IgnoreNotFound(err) == nil {
112116
e.Log.Info("Failed to get master", "err", err.Error())
113117
return nil
114118
}
115-
// other error
119+
// Return other unexpected errors.
116120
return err
117121
}
118122
if master.Status.ReadyReplicas == 0 {
@@ -122,9 +126,8 @@ func (e *GooseFSEngine) invokeCleanCache(path string) (err error) {
122126
e.Log.Info("The master is ready, so start cleaning cache", "master", masterName)
123127
}
124128

125-
// 2. run clean action
129+
// 2. Run the clean action using the GooseFS file utilities.
126130
podName, containerName := e.getMasterPodInfo()
127131
fileUitls := operations.NewGooseFSFileUtils(podName, containerName, e.namespace, e.Log)
128132
return fileUitls.CleanCache(path)
129-
130133
}

0 commit comments

Comments
 (0)