@@ -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.
106109func (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