@@ -209,9 +209,10 @@ func (s *Puller) ProcessLoadModelRequest(ctx context.Context, req *mmesh.LoadMod
209209 }
210210
211211 // update the model key to add the disk size
212- if size , err1 := getModelDiskSize (modelFullPath ); err1 != nil {
212+ if size , err1 := s . getModelDiskSize (modelFullPath ); err1 != nil {
213213 s .Log .Error (err1 , "Model disk size will not be included in the LoadModelRequest due to error" , "model_key" , modelKey )
214214 } else {
215+ s .Log .Info ("Calculated disk size" , "modelFullPath" , modelFullPath , "disk_size" , size )
215216 modelKey .DiskSizeBytes = size
216217 }
217218
@@ -230,18 +231,36 @@ func (s *Puller) ProcessLoadModelRequest(ctx context.Context, req *mmesh.LoadMod
230231 return req , nil
231232}
232233
233- func getModelDiskSize (modelPath string ) (int64 , error ) {
234+ func ( s * Puller ) getModelDiskSize (modelPath string ) (int64 , error ) {
234235 // This walks the local filesystem and accumulates the size of the model
235236 // It would be more efficient to accumulate the size as the files are downloaded,
236237 // but this would require refactoring because the s3 download iterator does not return a size.
237238 var size int64
238- err := filepath .Walk (modelPath , func (_ string , info os.FileInfo , err error ) error {
239+ err := filepath .Walk (modelPath , func (path string , info os.FileInfo , err error ) error {
239240 if err != nil {
240241 return err
241242 }
242- if ! info .IsDir () {
243+
244+ // Calculating the size of the resolved path (for pvc) instead of the symlink itself.
245+ // We are not expecting to have infinite recursion since otherwise the serving runtime would not be able to load the model
246+ if info .Mode ()& os .ModeSymlink != 0 {
247+ resolvedPath , resolveErr := os .Readlink (path )
248+
249+ if resolveErr != nil {
250+ s .Log .Error (resolveErr , "Failed to resolve symlink path" , "path" , path )
251+ } else {
252+ symlinkTargetSize , symlinkTargetSizeErr := s .getModelDiskSize (resolvedPath )
253+
254+ if symlinkTargetSizeErr != nil {
255+ return symlinkTargetSizeErr
256+ }
257+
258+ size += symlinkTargetSize
259+ }
260+ } else if ! info .IsDir () {
243261 size += info .Size ()
244262 }
263+
245264 return nil
246265 })
247266 if err != nil {
0 commit comments