Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(job): log was too long (closes #556) #557

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/core/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type (
ID uint `gorm:"primary_key;auto_increment;not null" json:"id"`
Branch string `json:"branch"`
Commit string `json:"commit"`
CommitMessage string `json:"commitMessage"`
CommitMessage string `json:"commitMessage" sql:"type:text"`
Ref string `gorm:"default:'refs/heads/master'" json:"ref"`
PR int `json:"pr"`
PRTitle string `json:"prTitle"`
Expand Down
2 changes: 1 addition & 1 deletion server/core/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type (
EnvVariable struct {
ID uint `gorm:"primary_key;auto_increment;not null" json:"id"`
Key string `gorm:"not null" json:"key"`
Value string `gorm:"not null" sql:"type:text" json:"value"`
Value string `gorm:"not null" sql:"type:longtext" json:"value"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only works for mysql unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I have no idea how to fix it for sqlite, except for truncating the actual value...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I tested, longtext works just fine in here with sqlite3 as backend, and if I got the docs correctly - sqlite doesn't limit the size.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tnx for the test, i will also test it and let you know

Secret bool `gorm:"not null,default:false" json:"secret"`
RepositoryID uint `gorm:"not null" json:"repositoryID"`
Repository Repository `json:"repository"`
Expand Down
4 changes: 2 additions & 2 deletions server/core/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ type (
ID uint `gorm:"primary_key;auto_increment;not null" json:"id"`
Commands string `sql:"type:text" json:"commands"`
Image string `json:"image"`
Env string `json:"env"`
Env string `json:"env" sql:"type:longtext"`
Mount string `json:"mount"`
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 `gorm:"size:16777216" json:"-"`
Log string `gorm:"size:16777216" json:"-" sql:"type:longtext"`
Stage string `json:"stage"`
Cache string `json:"cache"`
Build *Build `gorm:"preload:false" json:"build,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions server/store/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func (s jobStore) Create(job *core.Job) error {
func (s jobStore) Update(job *core.Job) error {
log := []byte(job.Log)

if len(job.Log) > 16777215 {
job.Log = job.Log[0:16777215]
}
err := s.db.Model(job).Updates(map[string]interface{}{
"status": job.Status,
"start_time": job.StartTime,
Expand Down