()
| 60 | } |
| 61 | |
| 62 | func cleanupOldJobLogs() { |
| 63 | jobDir := wavebase.GetRemoteJobLogDir() |
| 64 | entries, err := os.ReadDir(jobDir) |
| 65 | if err != nil { |
| 66 | return |
| 67 | } |
| 68 | |
| 69 | cutoffTime := time.Now().Add(-JobLogRetentionTime) |
| 70 | |
| 71 | for _, entry := range entries { |
| 72 | if entry.IsDir() { |
| 73 | continue |
| 74 | } |
| 75 | |
| 76 | name := entry.Name() |
| 77 | if !strings.HasSuffix(name, ".log") { |
| 78 | continue |
| 79 | } |
| 80 | |
| 81 | info, err := entry.Info() |
| 82 | if err != nil { |
| 83 | continue |
| 84 | } |
| 85 | |
| 86 | if info.ModTime().Before(cutoffTime) { |
| 87 | filePath := filepath.Join(jobDir, name) |
| 88 | err := os.Remove(filePath) |
| 89 | if err != nil { |
| 90 | log.Printf("error removing old job log file %s: %v", filePath, err) |
| 91 | } else { |
| 92 | log.Printf("removed old job log file: %s", filePath) |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func startJobLogCleanup() { |
| 99 | go func() { |
no test coverage detected