Skip to content

Commit

Permalink
Merge pull request dragonflyoss#960 from Starnop/gc-disk-not-exist
Browse files Browse the repository at this point in the history
bugfix: reduce error logs when download home dir not exist
  • Loading branch information
lowzj authored Sep 27, 2019
2 parents 9f72e4d + fc485fe commit cfd78e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions supernode/daemon/mgr/cdn/cache_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/dragonflyoss/Dragonfly/supernode/httpclient"
"github.com/dragonflyoss/Dragonfly/supernode/store"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -59,7 +60,7 @@ func (cd *cacheDetector) detectCache(ctx context.Context, task *types.TaskInfo)

if breakNum == 0 {
if metaData, err = cd.resetRepo(ctx, task); err != nil {
return 0, nil, err
return 0, nil, errors.Wrapf(err, "failed to reset repo")
}
} else {
logrus.Debugf("start to update access time with taskID(%s)", task.ID)
Expand Down Expand Up @@ -120,7 +121,7 @@ func (cd *cacheDetector) parseBreakNumByCheckFile(ctx context.Context, taskID st
func (cd *cacheDetector) resetRepo(ctx context.Context, task *types.TaskInfo) (*fileMetaData, error) {
logrus.Infof("reset repo for taskID: %s", task.ID)
if err := deleteTaskFiles(ctx, cd.cacheStore, task.ID); err != nil {
return nil, err
logrus.Errorf("reset repo: failed to delete task(%s) files: %v", task.ID, err)
}

return cd.metaDataManager.writeFileMetaDataByTask(ctx, task)
Expand Down
6 changes: 5 additions & 1 deletion supernode/daemon/mgr/cdn/cdn_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/emirpasic/gods/maps/treemap"
godsutils "github.com/emirpasic/gods/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

Expand All @@ -41,7 +42,10 @@ func (cm *Manager) GetGCTaskIDs(ctx context.Context, taskMgr mgr.TaskMgr) ([]str

freeDisk, err := cm.cacheStore.GetAvailSpace(ctx, getHomeRawFunc())
if err != nil {
return nil, err
if store.IsKeyNotFound(err) {
return nil, nil
}
return nil, errors.Wrapf(err, "failed to get avail space")
}
if freeDisk > cm.cfg.YoungGCThreshold {
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion supernode/store/local_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (ls *localStorage) statPath(bucket, key string) (string, os.FileInfo, error
f, err := os.Stat(filePath)
if err != nil {
if os.IsNotExist(err) {
return "", nil, errors.Wrapf(ErrKeyNotFound, "key: %s", key)
return "", nil, errors.Wrapf(ErrKeyNotFound, "bucket(%s) key(%s)", bucket, key)
}
return "", nil, err
}
Expand Down

0 comments on commit cfd78e0

Please sign in to comment.