Skip to content

Commit

Permalink
More processor log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dosaboy committed Aug 25, 2023
1 parent a946b7b commit 3927aa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/common/db/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Report struct {
Commented bool `gorm:"default:false"`
Subscriber string
Name string
FileName string
FileID uint
FilePath string
CaseID string
Expand Down
15 changes: 8 additions & 7 deletions pkg/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *BaseSubscriber) Setup(c *pubsub.Client) {
}

type ReportToExecute struct {
Name, BaseDir, Subscriber string
Name, BaseDir, Subscriber, FileName string
File *db.File
Scripts map[string]string
Timeout time.Duration
Expand Down Expand Up @@ -85,7 +85,7 @@ func RunReport(report *ReportToExecute) (map[string][]byte, error) {
var output = make(map[string][]byte)

for scriptName, script := range report.Scripts {
log.Debugf("Running script '%s' on sosreport '%s'", scriptName, report.Name)
log.Debugf("Running script '%s' on sosreport '%s'", scriptName, report.FileName)
var ret []byte
var err error
if report.Timeout > 0 {
Expand Down Expand Up @@ -142,14 +142,15 @@ func (runner *ReportRunner) UploadAndSaveReport(report *ReportToExecute, caseNum
newReport.Created = time.Now()
newReport.CaseID = sfCase.Id
newReport.FilePath = file.Path
newReport.FileName = filepath.Base(file.Path)
newReport.Name = report.Name
newReport.FileID = file.ID
newReport.Subscriber = report.Subscriber

if runner.Config.Processor.ReportsUploadPath == "" {
uploadPath = filePath
} else {
uploadPath = path.Join(runner.Config.Processor.ReportsUploadPath, filepath.Base(filePath))
uploadPath = path.Join(runner.Config.Processor.ReportsUploadPath, newReport.FileName)
}

log.Debugf("Uploading script output to files.com")
Expand Down Expand Up @@ -189,7 +190,7 @@ func (runner *ReportRunner) Run(reportFn func(report *ReportToExecute) (map[stri

caseNumber, err := common.GetCaseNumberFromFilename(report.File.Path)
if err != nil {
log.Error(err)
log.Info(err)
continue
}

Expand All @@ -200,7 +201,7 @@ func (runner *ReportRunner) Run(reportFn func(report *ReportToExecute) (map[stri
continue
}

log.Debugf("Uploading and saving results of running '%s' on '%s' (count=%d)", report.Name, report.File.Path, len(scriptOutputs))
log.Debugf("Uploading and saving results of running '%s' on '%s' (count=%d)", report.Name, report.FileName, len(scriptOutputs))
if err := runner.UploadAndSaveReport(&report, caseNumber, scriptOutputs); err != nil {
log.Errorf("Failed to upload and save output of '%s': %s", report.Name, err)
continue
Expand Down Expand Up @@ -412,7 +413,7 @@ func (p *Processor) BatchSalesforceComments(ctx *context.Context, interval time.
}

if len(reports) <= 0 {
log.Warnf("No reports found to be processed - skipping")
log.Info("No reports found to be processed - skipping")
return
}

Expand Down Expand Up @@ -466,7 +467,7 @@ func (p *Processor) BatchSalesforceComments(ctx *context.Context, interval time.
continue
}

log.Infof("Successfully posted comment on case %s for %d reports", caseId, len(reports))
log.Infof("Successfully posted comment on case %s for %d reports", caseId, len(reports))
for _, report := range reports {
report.Commented = true
p.Db.Save(report)
Expand Down

0 comments on commit 3927aa8

Please sign in to comment.