Skip to content

Commit

Permalink
cleanup logging
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 25, 2024
1 parent 709c54b commit 7b67058
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 94 deletions.
2 changes: 1 addition & 1 deletion carlog/carlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func Open(staging CarStorageProvider, indexPath, dataPath string, tc TruncCleanu
return nil, xerrors.Errorf("opening fixed leveldb index: %w", err)
}

log.Errorw("leveldb index fixed", "path", filepath.Join(indexPath, LevelIndex))
log.Infow("leveldb index fixed", "path", filepath.Join(indexPath, LevelIndex))
}

jb.rIdx = idx
Expand Down
4 changes: 2 additions & 2 deletions integrations/kuri/ribsplugin/mfsdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func StartMfsDav(lc fx.Lifecycle, fr *mfs.Root) {
log.Errorf("failed to start ribs http server: %s", err)
}

log.Errorw("dav http at http://localhost:8077")
fmt.Println("dav http at http://localhost:8077")
}()
return nil
},
Expand Down Expand Up @@ -196,7 +196,7 @@ func (m *mfsDavDir) Write(p []byte) (n int, err error) {
}

func (m *mfsDavFs) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error) {
log.Errorw("OPEN FILE", "name", name, "flag", flag, "perm", perm)
log.Debugw("OPEN FILE", "name", name, "flag", flag, "perm", perm)

path, err := checkPath(name)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion integrations/web/ribsweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (ri *RIBSWeb) Index(w http.ResponseWriter, r *http.Request) {
return
}

log.Errorw("index", "path", r.URL.Path)
log.Debugw("index", "path", r.URL.Path)

tpl, err := txtempl.New("index.html").ParseFS(dres, "ribswebapp/build/index.html")
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions rbdeal/car_offload_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *ribs) maybeInitS3Offload() error {
return nil
}

log.Errorw("S3 offload enabled", "endpoint", endpoint)
log.Infow("S3 offload enabled", "endpoint", endpoint)

region := os.Getenv("S3_REGION")
accessKey := os.Getenv("S3_ACCESS_KEY")
Expand Down Expand Up @@ -194,10 +194,10 @@ func CalculateChunkSize(fileSize int64) int {

numParts = int64(math.Ceil(float64(fileSize) / float64(chunkSize)))
lastPartSize = fileSize - ((numParts - 1) * chunkSize)
log.Errorw("try chunk size", "chunkSize", chunkSize, "lastPartSize", lastPartSize, "numParts", numParts, "fileSize", fileSize)
log.Debugw("try chunk size", "chunkSize", chunkSize, "lastPartSize", lastPartSize, "numParts", numParts, "fileSize", fileSize)
}

log.Errorw("using chunk size", "chunkSize", chunkSize, "lastPartSize", lastPartSize, "numParts", numParts, "fileSize", fileSize)
log.Debugw("using chunk size", "chunkSize", chunkSize, "lastPartSize", lastPartSize, "numParts", numParts, "fileSize", fileSize)

return int(chunkSize)
}
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *ribs) uploadGroupData(gid iface.GroupKey, size int64, src io.Reader) (e

if len(nextPart) < minPartSize && len(nextPart) > 0 {
// last part is too small, merge it with the current one
log.Errorw("last part merge", "cur", len(curPart), "next", len(nextPart), "total", len(curPart)+len(nextPart))
log.Debugw("last part merge", "cur", len(curPart), "next", len(nextPart), "total", len(curPart)+len(nextPart))

temp := pool.Get(len(curPart) + len(nextPart))

Expand Down Expand Up @@ -314,7 +314,7 @@ func (r *ribs) uploadGroupData(gid iface.GroupKey, size int64, src io.Reader) (e
PartNumber: aws.Int64(partNumber),
})
partsLk.Unlock()
log.Errorw("uploaded part", "part", partNumber, "group", gid, "size", len(part))
log.Infow("uploaded part", "part", partNumber, "group", gid, "size", len(part))
break
}
partsLk.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion rbdeal/car_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (r *ribs) handleCarRequest(w http.ResponseWriter, req *http.Request) {

if s3u != "" {
// in s3, redirect
log.Errorw("car request: redir to s3 url", "error", err, "url", s3u)
log.Debugw("car request: redir to s3 url", "error", err, "url", s3u)

r.s3Redirects.Add(1)

Expand Down
2 changes: 1 addition & 1 deletion rbdeal/deal_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (r *ribsDB) startDB() error {
func timeDBOp(name string, db *ributil.RetryDB, f func(db *ributil.RetryDB) error) error {
start := time.Now()
err := f(db)
log.Errorw("DB op time", "name", name, "took", time.Since(start), "error", err)
log.Debugw("DB op time", "name", name, "took", time.Since(start), "error", err)
return err
}

Expand Down
8 changes: 4 additions & 4 deletions rbdeal/deal_repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (r *ribs) fetchGroupHttp(ctx context.Context, workerID int, group ribs2.Gro
// booster-http providers
addrInfo, err := r.retrProv.getAddrInfoCached(candidate.Provider)
if err != nil {
log.Errorw("failed to get addrinfo", "provider", candidate.Provider, "err", err)
log.Warnw("failed to get addrinfo", "provider", candidate.Provider, "err", err)
continue
}

Expand All @@ -219,7 +219,7 @@ func (r *ribs) fetchGroupHttp(ctx context.Context, workerID int, group ribs2.Gro

u, err := ributil.MaddrsToUrl(addrInfo.HttpMaddrs)
if err != nil {
log.Errorw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
log.Warnw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
continue
}

Expand All @@ -240,7 +240,7 @@ func (r *ribs) fetchGroupHttp(ctx context.Context, workerID int, group ribs2.Gro

reqUrl := candidate.reqUrl

log.Errorw("attempting http repair retrieval", "url", reqUrl.String(), "group", group, "provider", candidate.provider)
log.Infow("attempting http repair retrieval", "url", reqUrl.String(), "group", group, "provider", candidate.provider)

// make the request!!

Expand Down Expand Up @@ -399,7 +399,7 @@ func (r *ribs) fetchGroupLassie(ctx context.Context, workerID int, group ribs2.G
return xerrors.Errorf("failed to get group metadata: %w", err)
}

log.Errorw("attempting lassie repair retrieval", "group", group, "root", gm.RootCid, "piece", gm.PieceCid, "file", groupFile, "worker", workerID)
log.Infow("attempting lassie repair retrieval", "group", group, "root", gm.RootCid, "piece", gm.PieceCid, "file", groupFile, "worker", workerID)

tempDir := fmt.Sprintf("%s.temp", groupFile)
err = os.MkdirAll(tempDir, 0755)
Expand Down
8 changes: 4 additions & 4 deletions rbdeal/deal_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *ribs) dealTracker(ctx context.Context) {

checkDuration := time.Since(checkStart)

log.Errorw("deal check loop finished", "duration", checkDuration)
log.Infow("deal check loop finished", "duration", checkDuration)

if checkDuration < DealCheckInterval {
select {
Expand Down Expand Up @@ -294,18 +294,18 @@ func (r *ribs) runDealCheckLoop(ctx context.Context) error {
} else if gs.Retrievable >= int64(minimumReplicaCount) {
upStat := r.CarUploadStats().ByGroup
if upStat[gid] == nil {
log.Errorw("OFFLOAD GROUP", "group", gid)
log.Infow("OFFLOAD GROUP", "group", gid)

if err := r.Storage().Offload(ctx, gid); err != nil {
log.Errorw("offloading group", "group", gid, "error", err)
log.Infow("offloading group", "group", gid, "error", err)
return xerrors.Errorf("offloading group %d: %w", gid, err)
}

if err := r.cleanupS3Offload(gid); err != nil {
return xerrors.Errorf("cleaning up S3 offload: %w", err)
}
} else {
log.Errorw("NOT OFFLOADING GROUP yet", "group", gid, "retrievable", gs.Retrievable, "uploads", upStat[gid].ActiveRequests)
log.Infow("NOT OFFLOADING GROUP yet", "group", gid, "retrievable", gs.Retrievable, "uploads", upStat[gid].ActiveRequests)
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions rbdeal/retr_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (p *ProbingRetrievalFinder) FindCandidates(ctx context.Context, cid cid.Cid

lu, ok := p.lookups[cid]
if !ok {
log.Errorw("no candidate for cid", "cid", cid)
log.Debugw("no candidate for cid", "cid", cid)
return nil
}

Expand Down Expand Up @@ -83,7 +83,7 @@ func (r *ribs) retrievalChecker(ctx context.Context) {
for {
err := r.doRetrievalCheck(ctx, gw, rf, lsi)
if err != nil {
log.Errorw("failed to do retrieval check", "error", err)
log.Warnw("failed to do retrieval check", "error", err)
}

time.Sleep(15 * time.Minute)
Expand Down Expand Up @@ -149,7 +149,7 @@ func (r *ribs) doRetrievalCheck(ctx context.Context, gw api.Gateway, prf *Probin
v.consecutiveTimeouts = 0 // forgive
}
if v.consecutiveTimeouts >= maxConsecutiveTimeouts {
log.Errorw("skipping provider due to consecutive timeouts", "provider", candidate.Provider, "group", candidate.Group, "deal", candidate.DealID)
log.Infow("skipping provider due to consecutive timeouts", "provider", candidate.Provider, "group", candidate.Group, "deal", candidate.DealID)

res := RetrievalResult{
Success: false,
Expand Down Expand Up @@ -191,7 +191,7 @@ func (r *ribs) doRetrievalCheck(ctx context.Context, gw api.Gateway, prf *Probin

addrInfo, err := r.db.GetProviderAddrs(candidate.Provider)
if err != nil {
log.Errorw("failed to get addr info", "error", err)
log.Debugw("failed to get addr info", "error", err)
r.rckFail.Add(1)
r.rckFailAll.Add(1)
continue
Expand Down Expand Up @@ -234,14 +234,14 @@ func (r *ribs) doRetrievalCheck(ctx context.Context, gw api.Gateway, prf *Probin

gsAddrInfo, err := peer.AddrInfosFromP2pAddrs(addrInfo.LibP2PMaddrs...)
if err != nil {
log.Errorw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
log.Warnw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
r.rckFail.Add(1)
r.rckFailAll.Add(1)
continue
}

if len(gsAddrInfo) == 0 {
log.Errorw("no gs addrinfo", "provider", candidate.Provider)
log.Debugw("no gs addrinfo", "provider", candidate.Provider)
r.rckFail.Add(1)
r.rckFailAll.Add(1)
continue
Expand All @@ -252,7 +252,7 @@ func (r *ribs) doRetrievalCheck(ctx context.Context, gw api.Gateway, prf *Probin

fixedPeer, err = peer.AddrInfosFromP2pAddrs(allMaddrs...)
if err != nil {
log.Errorw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
log.Warnw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
r.rckFail.Add(1)
r.rckFailAll.Add(1)
continue
Expand All @@ -276,7 +276,7 @@ func (r *ribs) doRetrievalCheck(ctx context.Context, gw api.Gateway, prf *Probin
}()
err = r.retrievalCheckCandidate(ctx, candidate, addrInfo, cidToGet, group, fixedPeer, prf, lsi, timeoutCache, cs)
if err != nil {
log.Errorw("failed to check candidate", "error", err)
log.Warnw("failed to check candidate", "error", err)
}
}()
}
Expand All @@ -294,7 +294,7 @@ func (r *ribs) retrievalCheckCandidate(ctx context.Context, candidate RetrCheckC
if len(addrInfo.HttpMaddrs) > 0 {
u, err := ributil.MaddrsToUrl(addrInfo.HttpMaddrs)
if err != nil {
log.Errorw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
log.Warnw("failed to parse addrinfo", "provider", candidate.Provider, "err", err)
goto lassie
}

Expand All @@ -316,15 +316,15 @@ func (r *ribs) retrievalCheckCandidate(ctx context.Context, candidate RetrCheckC

resp, err := http.DefaultClient.Do(req) // todo use a tuned client
if err != nil {
log.Errorw("http retrieval failed", "error", err, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
log.Warnw("http retrieval failed", "error", err, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
return xerrors.Errorf("failed to do request: %w", err)
}

firstByte = time.Now()

if resp.StatusCode != 200 {
_ = resp.Body.Close()
log.Errorw("http retrieval failed (non-200 response)", "status", resp.StatusCode, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
log.Warnw("http retrieval failed (non-200 response)", "status", resp.StatusCode, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
return xerrors.Errorf("non-200 response: %d", resp.StatusCode)
}

Expand All @@ -349,7 +349,7 @@ func (r *ribs) retrievalCheckCandidate(ctx context.Context, candidate RetrCheckC
n, err := io.ReadFull(resp.Body, bbuf)
if err != nil && err != io.ErrUnexpectedEOF {
_ = resp.Body.Close()
log.Errorw("http retrieval failed (failed to read response)", "error", err, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
log.Warnw("http retrieval failed (failed to read response)", "error", err, "url", u.String()+"/ipfs/"+cidToGet.String(), "group", group, "provider", candidate.Provider)
return xerrors.Errorf("failed to read response: %w", err)
}
bbuf = bbuf[:n]
Expand All @@ -373,7 +373,7 @@ func (r *ribs) retrievalCheckCandidate(ctx context.Context, candidate RetrCheckC
return nil
}()
if err != nil {
log.Errorw("failed to get http", "provider", candidate.Provider, "err", err)
log.Warnw("failed to get http", "provider", candidate.Provider, "err", err)
goto lassie
}

Expand All @@ -391,7 +391,7 @@ func (r *ribs) retrievalCheckCandidate(ctx context.Context, candidate RetrCheckC
r.rckSuccess.Add(1)
r.rckSuccessAll.Add(1)

log.Errorw("http retrieval check success", "provider", candidate.Provider, "group", candidate.Group, "took", time.Since(start))
log.Debugw("http retrieval check success", "provider", candidate.Provider, "group", candidate.Group, "took", time.Since(start))
return nil
}
lassie:
Expand All @@ -402,7 +402,7 @@ lassie:
}

if !allowLassie {
log.Errorw("no http addrs, and lassie disabled", "provider", candidate.Provider)
log.Debugw("no http addrs, and lassie disabled", "provider", candidate.Provider)
r.rckFail.Add(1)
r.rckFailAll.Add(1)

Expand Down Expand Up @@ -480,7 +480,7 @@ lassie:
r.rckSuccess.Add(1)
r.rckSuccessAll.Add(1)
} else {
log.Errorw("failed to fetch", "error", err, "provider", candidate.Provider, "group", candidate.Group, "deal", candidate.DealID, "took", time.Since(start))
log.Warnw("failed to fetch", "error", err, "provider", candidate.Provider, "group", candidate.Group, "deal", candidate.DealID, "took", time.Since(start))
res.Success = false
res.Error = err.Error()

Expand Down
Loading

0 comments on commit 7b67058

Please sign in to comment.