logResponseWarnings logs warningHeaders from res, if any.
(res *http.Response, warningHeaders []string)
| 626 | |
| 627 | // logResponseWarnings logs warningHeaders from res, if any. |
| 628 | func (c *dockerClient) logResponseWarnings(res *http.Response, warningHeaders []string) { |
| 629 | c.reportedWarningsLock.Lock() |
| 630 | defer c.reportedWarningsLock.Unlock() |
| 631 | |
| 632 | for _, header := range warningHeaders { |
| 633 | warningString := parseRegistryWarningHeader(header) |
| 634 | if warningString == "" { |
| 635 | logrus.Debugf("Ignored Warning: header from registry: %q", header) |
| 636 | } else { |
| 637 | if !c.reportedWarnings.Contains(warningString) { |
| 638 | c.reportedWarnings.Add(warningString) |
| 639 | // Note that reportedWarnings is based only on warningString, so that we don’t |
| 640 | // repeat the same warning for every request - but the warning includes the URL; |
| 641 | // so it may not be specific to that URL. |
| 642 | logrus.Warnf("Warning from registry (first encountered at %q): %q", res.Request.URL.Redacted(), warningString) |
| 643 | } else { |
| 644 | logrus.Debugf("Repeated warning from registry at %q: %q", res.Request.URL.Redacted(), warningString) |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | // parseRegistryWarningHeader parses a Warning: header per RFC 7234, limited to the warning |
| 651 | // values allowed by opencontainers/distribution-spec. |
no test coverage detected