Skip to content

Commit

Permalink
fix(logs): save full job log into database
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Jul 4, 2021
1 parent 31b66c9 commit 7a0b7cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/core/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type (
StartTime *time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime"`
Status string `gorm:"not null;size:20;default:'queued'" json:"status"` // queued | running | passing | failing
Log string `sql:"type:text" json:"-"`
Log string `gorm:"size:16777216" json:"-"`
Stage string `json:"stage"`
Cache string `json:"cache"`
Build *Build `gorm:"preload:false" json:"build,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions server/store/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func (s jobStore) Create(job *core.Job) error {

func (s jobStore) Update(job *core.Job) error {
log := []byte(job.Log)

err := s.db.Model(job).Updates(map[string]interface{}{
"status": job.Status,
"start_time": job.StartTime,
"end_time": job.EndTime,
"log": job.Log,
}).Error

if err == nil {
return nil
}

if len(log) > 65535 {
log = log[len(log)-65535:]
job.Log = string(log)
Expand Down

0 comments on commit 7a0b7cc

Please sign in to comment.