mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 02:05:41 +01:00
JobService: fix for missing log data in jobservice DB logging (#20684)
* 20548 MISSING CONDITION FOR RETURNING LOG DATA As per bug 20548, if DB logging is enabled for jobservice and the parameter is also set for maximum log size the log data is not being returned and 'Clean Up->Show GC Logs' shows a blank page Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com> Co-authored-by: Nick Hindley <no-reply@example.com> * db_getter_test.go: test fix for missing log data in jobservice DB logging Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com> --------- Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com> Co-authored-by: Nick Hindley <no-reply@example.com> Co-authored-by: Shengwen YU <yshengwen@vmware.com>
This commit is contained in:
parent
27e06ac609
commit
cc1acc3890
@ -47,7 +47,7 @@ func (dbg *DBGetter) Retrieve(logID string) ([]byte, error) {
|
||||
sz := int64(len(jobLog.Content))
|
||||
var buf []byte
|
||||
sizeLimit := logSizeLimit()
|
||||
if sizeLimit <= 0 {
|
||||
if sizeLimit <= 0 || sz <= sizeLimit {
|
||||
buf = []byte(jobLog.Content)
|
||||
return buf, nil
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/jobservice/config"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger/backend"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger/sweeper"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
@ -44,9 +45,11 @@ func TestDBGetter(t *testing.T) {
|
||||
err = l.Close()
|
||||
require.NoError(t, err)
|
||||
|
||||
_ = config.DefaultConfig.Load("../../config_test.yml", true)
|
||||
dbGetter := NewDBGetter()
|
||||
ll, err := dbGetter.Retrieve(uuid)
|
||||
require.Nil(t, err)
|
||||
require.NotEqual(t, 0, len(ll))
|
||||
log.Infof("get logger %s", ll)
|
||||
|
||||
err = sweeper.PrepareDBSweep()
|
||||
|
Loading…
Reference in New Issue
Block a user