image icon indicating copy to clipboard operation
image copied to clipboard

WIP do not merge: Dump HTTP operations

Open mtrmac opened this issue 8 years ago • 17 comments

Quite often it has been useful to dump the full HTTP request and response headers, and sometimes fuill bodies, for debugging; we probably should make that possible either automatically at the “debug” log level, or when the user sets an option.

This is by no means a workable implementation for that, but I’ve written exactly this hack two or three times now, so right now I am at least recording it for posterity, expecting that rebasing it will be easier than rewriting it.

A real implementation should, I guess, wrap a http.RoundTripper or perhaps http.Client (or just http.Client.Do?), or perhaps using net/http/httptrace somehow.

mtrmac avatar Jan 07 '17 03:01 mtrmac

Isn't this adding overhead to the command? I'm fine with this, just want to make sure we don't wait that much dumping req/res.

runcom avatar Jan 07 '17 10:01 runcom

Any way to pass down a debug flag? Or just rebuild with a DEBUG Tag?

rhatdan avatar Jan 09 '17 14:01 rhatdan

Isn't this adding overhead to the command?

Yes, and it completely clutters the debugging output. As I said

This is by no means a workable implementation

mtrmac avatar Jan 09 '17 15:01 mtrmac

Any way to pass down a debug flag? Or just rebuild with a DEBUG Tag?

We have a types.SystemContext which can be used to pass down such flags, yes.

mtrmac avatar Jan 09 '17 15:01 mtrmac

@mtrmac Could you open a trello card with an intern flag, so we could have an intern work on this next summer.

rhatdan avatar Jan 29 '18 13:01 rhatdan

@mtrmac Could you open a trello card with an intern flag, so we could have an intern work on this next summer.

https://trello.com/c/xrAwKleu/542-containers-image-http-dumps-intern

mtrmac avatar Feb 06 '18 16:02 mtrmac

@mtrmac @vrothberg What is the state of this PR? Should we rebase and move forward with it or should we close it?

rhatdan avatar Apr 25 '19 09:04 rhatdan

Rebased, but this still needs turning into a types.SystemContext option + CLI options in users of the library.

mtrmac avatar Jun 01 '19 12:06 mtrmac

Meeting notes: use logrus.Trace*

vrothberg avatar Jan 19 '21 14:01 vrothberg

logrus has a Trace log level, probably a good way to opt in now.

mtrmac avatar Jan 19 '21 14:01 mtrmac

Updated:

  • To centralize the dumping implementation (still just a helper method, not a http.RoundTripper)
  • In that dumping implementation, to log errors as well
  • To use logrus.Tracef, if enabled.

WARNING: Using this will cause trace-level logs to include all credentials (Basic auth, bearer tokens, etc.). Is that OK? Applications including this should probably warn about that at least in documentation.

mtrmac avatar Jan 19 '21 17:01 mtrmac

Unless we can easily hide this information, then yes we should document this in the release notes. As well as in the man pages if possible. Perhaps containers-transports.5.md Under the "docker" section?

rhatdan avatar Jan 20 '21 10:01 rhatdan

Unless we can easily hide this information, then yes we should document this in the release notes. As well as in the man pages if possible. Perhaps containers-transports.5.md Under the "docker" section?

And in the man pages of the tools (i.e., the --debug and --log-level flags).

vrothberg avatar Jan 20 '21 10:01 vrothberg

Just needs to have an update to the transports man page.

rhatdan avatar Aug 27 '21 09:08 rhatdan

In addition to the previously-noted concerns about opt-in, this should almost certainly be reworked to become a http.RoundTripper, wrapper, so that all redirects are logged.

mtrmac avatar Jun 27 '24 20:06 mtrmac

This would be very useful for troubleshooting issues with access to remote registries. At the moment, I tend to opt for a set up with a transparent TLS proxy to snoop on this type of traffic, but having a log that exposes this type of data that can be easily enabled would be ideal.

kwilczynski avatar Jul 09 '24 03:07 kwilczynski

For the record, Red Hat internal tracking: https://issues.redhat.com/browse/RHEL-36783

mtrmac avatar Jul 09 '24 16:07 mtrmac