Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whenever bootstrap files hosted in the http_directory are accessed, it should show in the logs #50

Open
marcosdiez opened this issue Apr 5, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@marcosdiez
Copy link

Here is a simple suggestion to save us lots of time in debugging.

In images like virtualbox-iso, one can host files using the http_directory parameter.

These files are are, for example, "install settings" used in debian and ubuntu.

On a good day, everything works as expected.

On other days, it would be great if the internal HTTP server on packer showed some very basic access logs, so we could be sure our ISO image is hitting the HTTP server to download the files and this way narrow down whatever error we are having to "before" or "after" downloading the HTTP file.

@sylviamoss
Copy link
Member

Thanks for reaching out. We’ll take a look when we get a chance.

@azr azr transferred this issue from hashicorp/packer Apr 7, 2021
@azr
Copy link
Contributor

azr commented Apr 7, 2021

Moved this issue here; to do this, I would add an http handler wrapper here:

func (s *StepHTTPServer) Handler() http.Handler {
if s.HTTPDir != "" {
return http.FileServer(http.Dir(s.HTTPDir))
}
return MapServer(s.HTTPContent)
}

That handler would log the URL of each request. Note that we might not have the immediate time to look at this so if you feel like taking a stab at it: we would love to review.

@azr
Copy link
Contributor

azr commented Apr 7, 2021

func logreq(f func(w http.ResponseWriter, r *http.Request)) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		log.Printf("http_server: hit path=%q", r.URL.Path)

		f(w, r)
	})
}

Is a nice snippet for that.

@azr azr added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants