Skip to content

Commit

Permalink
feat: print headers with debug log (#2834)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Oct 30, 2023
1 parent 898c7e9 commit 132d1b2
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions scheduler/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ func (j *job) preheat(ctx context.Context, req string) error {
// Trigger seed peer download seeds.
taskID := idgen.TaskIDV1(preheat.URL, urlMeta)
log := logger.WithTask(taskID, preheat.URL)
log.Infof("preheat %s headers: %#v, tag: %s, range: %s, filter: %s, digest: %s",
preheat.URL, filterHeaders(urlMeta.Header, log.IsDebug()), urlMeta.Tag, urlMeta.Range, urlMeta.Filter, urlMeta.Digest)
log.Infof("preheat %s tag: %s, range: %s, filter: %s, digest: %s",
preheat.URL, urlMeta.Tag, urlMeta.Range, urlMeta.Filter, urlMeta.Digest)
log.Debugf("preheat %s headers: %#v", preheat.URL, urlMeta.Header)

stream, err := j.resource.SeedPeer().Client().ObtainSeeds(ctx, &cdnsystemv1.SeedRequest{
TaskId: taskID,
Url: preheat.URL,
Expand Down Expand Up @@ -227,14 +229,3 @@ func (j *job) syncPeers() (string, error) {

return internaljob.MarshalResponse(hosts)
}

// filterHeaders filters Authorization header if debugging is not enabled
func filterHeaders(urlHeader map[string]string, isDebug bool) map[string]string {
filteredHeaders := make(map[string]string)
for k, v := range urlHeader {
if isDebug || k != headers.Authorization {
filteredHeaders[k] = v
}
}
return filteredHeaders
}

0 comments on commit 132d1b2

Please sign in to comment.