@@ -209,9 +209,10 @@ func (s *Puller) ProcessLoadModelRequest(ctx context.Context, req *mmesh.LoadMod
209
209
}
210
210
211
211
// 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 {
213
213
s .Log .Error (err1 , "Model disk size will not be included in the LoadModelRequest due to error" , "model_key" , modelKey )
214
214
} else {
215
+ s .Log .Info ("Calculated disk size" , "modelFullPath" , modelFullPath , "disk_size" , size )
215
216
modelKey .DiskSizeBytes = size
216
217
}
217
218
@@ -230,18 +231,36 @@ func (s *Puller) ProcessLoadModelRequest(ctx context.Context, req *mmesh.LoadMod
230
231
return req , nil
231
232
}
232
233
233
- func getModelDiskSize (modelPath string ) (int64 , error ) {
234
+ func ( s * Puller ) getModelDiskSize (modelPath string ) (int64 , error ) {
234
235
// This walks the local filesystem and accumulates the size of the model
235
236
// It would be more efficient to accumulate the size as the files are downloaded,
236
237
// but this would require refactoring because the s3 download iterator does not return a size.
237
238
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 {
239
240
if err != nil {
240
241
return err
241
242
}
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 () {
243
261
size += info .Size ()
244
262
}
263
+
245
264
return nil
246
265
})
247
266
if err != nil {
0 commit comments