Skip to content

Commit 995f3a8

Browse files
authored
chore: cleanup lingering temporary export files upon suppression backup service startup (#6493)
🔒 Scanned for secrets using gitleaks 8.28.0 # Description If suppression backup service terminates abruptly it leaves behind temporary export files which are big in size. Now we are deleting any lingering temporary export files during startup ## Linear Ticket resolves PIPE-2480 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
1 parent 399c4c6 commit 995f3a8

File tree

32 files changed

+173
-43
lines changed

32 files changed

+173
-43
lines changed

admin/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (*Admin) GetLoggingConfig(_ struct{}, reply *string) (err error) {
107107

108108
// StartServer starts an HTTP server listening on unix socket and serving rpc communication
109109
func StartServer(ctx context.Context) error {
110-
tmpDirPath, err := misc.CreateTMPDIR()
110+
tmpDirPath, err := misc.GetTmpDir()
111111
if err != nil {
112112
panic(err)
113113
}

archiver/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (w *worker) uploadJobs(ctx context.Context, jobs []*jobsdb.JobT) (string, e
147147
workspaceID := jobs[0].WorkspaceId
148148

149149
filePath := path.Join(
150-
lo.Must(misc.CreateTMPDIR()),
150+
lo.Must(misc.GetTmpDir()),
151151
"rudder-backups",
152152
w.sourceID,
153153
fmt.Sprintf("%d_%d_%s_%s.json.gz", firstJobCreatedAt.Unix(), lastJobCreatedAt.Unix(), workspaceID, uuid.NewString()),

enterprise/reporting/error_index/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (w *worker) uploadPayloads(ctx context.Context, payloads []payload) (*filem
214214
return i.FailedAtTime().Compare(j.FailedAtTime())
215215
})
216216

217-
tmpDirPath, err := misc.CreateTMPDIR()
217+
tmpDirPath, err := misc.GetTmpDir()
218218
if err != nil {
219219
return nil, fmt.Errorf("creating tmp directory: %w", err)
220220
}

enterprise/reporting/event_sampler/badger_event_sampler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func GetPathName(module string) string {
3838
}
3939

4040
func DefaultPath(pathName string) (string, error) {
41-
tmpDirPath, err := misc.CreateTMPDIR()
41+
tmpDirPath, err := misc.GetTmpDir()
4242
if err != nil {
4343
return "", err
4444
}

enterprise/suppress-user/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (m *Factory) newSyncerWithBadgerRepo(repoPath string, seederSource func() (
216216
}
217217

218218
func getRepoPath() (fullSuppressionPath, latestSuppressionPath string, err error) {
219-
tmpDir, err := misc.CreateTMPDIR()
219+
tmpDir, err := misc.GetTmpDir()
220220
if err != nil {
221221
return "", "", fmt.Errorf("could not create tmp dir: %w", err)
222222
}

router/batchrouter/asyncdestinationmanager/bing-ads/audience/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ contains the template of the uploadable file.
3939
*/
4040
func createActionFile(audienceId, actionType string) (*ActionFileInfo, error) {
4141
localTmpDirName := fmt.Sprintf(`/%s/`, misc.RudderAsyncDestinationLogs)
42-
tmpDirPath, err := misc.CreateTMPDIR()
42+
tmpDirPath, err := misc.GetTmpDir()
4343
if err != nil {
4444
return nil, err
4545
}

router/batchrouter/asyncdestinationmanager/bing-ads/offline-conversions/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ contains the template of the uploadable file.
6161
*/
6262
func createActionFile(actionType string) (*ActionFileInfo, error) {
6363
localTmpDirName := fmt.Sprintf(`/%s/`, misc.RudderAsyncDestinationLogs)
64-
tmpDirPath, err := misc.CreateTMPDIR()
64+
tmpDirPath, err := misc.GetTmpDir()
6565
if err != nil {
6666
return nil, err
6767
}
@@ -251,7 +251,7 @@ func (b *BingAdsBulkUploader) downloadAndGetUploadStatusFile(ResultFileUrl strin
251251
panic(fmt.Errorf("BRT: Failed saving zip file. Err: %w", err))
252252
}
253253
localTmpDirName := fmt.Sprintf(`/%s/`, misc.RudderAsyncDestinationLogs)
254-
tmpDirPath, err := misc.CreateTMPDIR()
254+
tmpDirPath, err := misc.GetTmpDir()
255255
if err != nil {
256256
panic(fmt.Errorf("error while creating tmp directory: %w", err))
257257
}

router/batchrouter/asyncdestinationmanager/eloqua/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func createCSVFile(fields []string, file *os.File, uploadJobInfo *JobInfo, jobId
6161
scanner := bufio.NewScanner(file)
6262
scanner.Buffer(nil, bufferSize)
6363
localTmpDirName := fmt.Sprintf(`/%s/`, misc.RudderAsyncDestinationLogs)
64-
tmpDirPath, err := misc.CreateTMPDIR()
64+
tmpDirPath, err := misc.GetTmpDir()
6565
if err != nil {
6666
return "", 0, err
6767
}

router/batchrouter/asyncdestinationmanager/lytics_bulk_upload/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ func createCSVWriter(fileName string) (*ActionFileInfo, error) {
115115
}
116116

117117
func (u *LyticsBulkUploader) createCSVFile(existingFilePath string, streamTraitsMapping []StreamTraitMapping) (*ActionFileInfo, error) {
118-
// Create a temporary directory using misc.CreateTMPDIR
119-
tmpDirPath, err := misc.CreateTMPDIR()
118+
// Create a temporary directory using misc.GetTmpDir
119+
tmpDirPath, err := misc.GetTmpDir()
120120
if err != nil {
121121
return nil, fmt.Errorf("failed to create temporary directory: %v", err)
122122
}

router/batchrouter/asyncdestinationmanager/sftp/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func generateCSVFile(filePath string, sortColumnNames bool) (string, error) {
200200

201201
func getTempFilePath() (string, error) {
202202
localTmpDirName := fmt.Sprintf(`/%s/`, misc.RudderAsyncDestinationLogs)
203-
tmpDirPath, err := misc.CreateTMPDIR()
203+
tmpDirPath, err := misc.GetTmpDir()
204204
if err != nil {
205205
return "", err
206206
}

0 commit comments

Comments
 (0)