From 6ccc3ceecbca30079c5bcf62b8b781d8babca299 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 25 May 2022 23:10:10 -0700 Subject: [PATCH 1/2] Readded compression to the GET request This works around an out of memory issue reported in IRC from Norm Gaywood (thanks Norm!) --- etc/ipxe/default.ipxe | 53 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/etc/ipxe/default.ipxe b/etc/ipxe/default.ipxe index e92e863b..dc0fef07 100644 --- a/etc/ipxe/default.ipxe +++ b/etc/ipxe/default.ipxe @@ -19,40 +19,41 @@ echo Warewulf Controller: {{.Ipaddr}} echo Downloading Kernel Image: kernel --name kernel ${uri_base}&stage=kernel || goto reboot -## try extracting compressed images first -## NOTE: system overlay tends to be the smallest, so failure here is the cheapest -#echo Downloading Container Image: -#imgextract --name container ${uri_base}&stage=container&compress=gz || goto nocompress -# -#echo Downloading System Overlay: -#imgextract --name system ${uri_base}&stage=system&compress=gz || goto reboot -# -#echo Downloading Runtime Overlay: -#imgextract --name runtime ${uri_base}&stage=runtime&compress=gz || goto reboot -# -#{{if ne .KernelOverride "" -}} -#echo Downloading Kernel Modules: -#imgextract --name kmods ${uri_base}&stage=kmods&compress=gz || goto reboot -#{{- end}} -# -#goto imoktogo -# -#:nocompress -# -#echo Extraction failed, attempting un-compressed version of images - +# try extracting compressed images first +# NOTE: system overlay tends to be the smallest, so failure here is the cheapest echo Downloading Container Image: -initrd --name container ${uri_base}&stage=container || goto reboot +imgextract --name container ${uri_base}&stage=container&compress=gz || goto nocompress echo Downloading System Overlay: -initrd --name system ${uri_base}&stage=system || goto reboot +imgextract --name system ${uri_base}&stage=system&compress=gz || goto reboot echo Downloading Runtime Overlay: -initrd --name runtime ${uri_base}&stage=runtime || goto reboot +imgextract --name runtime ${uri_base}&stage=runtime&compress=gz || goto reboot {{if ne .KernelOverride "" -}} echo Downloading Kernel Modules: -initrd --name kmods ${uri_base}&stage=kmods || goto reboot +imgextract --name kmods ${uri_base}&stage=kmods&compress=gz || goto reboot +{{- end}} + +goto imoktogo + +:nocompress + +echo +echo Image extract not supported in this iPXE, using standard initrd mode + +echo Downloading Container Image: +initrd --name container ${uri_base}&stage=container&compress=gz || goto reboot + +echo Downloading System Overlay: +initrd --name system ${uri_base}&stage=system&compress=gz || goto reboot + +echo Downloading Runtime Overlay: +initrd --name runtime ${uri_base}&stage=runtime&compress=gz || goto reboot + +{{if ne .KernelOverride "" -}} +echo Downloading Kernel Modules: +initrd --name kmods ${uri_base}&stage=kmods&compress=gz || goto reboot {{- end}} From bf9ca54b8e1e9583c26e0185ec80f1c1b54f29ff Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Wed, 25 May 2022 23:11:26 -0700 Subject: [PATCH 2/2] Don't read in binary data blobs to memory before sending to HTTP writer --- internal/pkg/warewulfd/util.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/pkg/warewulfd/util.go b/internal/pkg/warewulfd/util.go index 63e89718..2cc609df 100644 --- a/internal/pkg/warewulfd/util.go +++ b/internal/pkg/warewulfd/util.go @@ -2,7 +2,6 @@ package warewulfd import ( "io" - "bytes" "net/http" "os" "strconv" @@ -36,18 +35,16 @@ func sendFile(w http.ResponseWriter, filename string, sendto string) error { return errors.Wrap(err, "failed to seek") } - var buf bytes.Buffer - _, err = io.Copy(&buf, fd) + w.Header().Set("Content-Disposition", "attachment; filename=kernel") + w.Header().Set("Content-Type", FileContentType) + w.Header().Set("Content-Length", FileSize) + + _, err = io.Copy(w, fd) if err != nil { w.WriteHeader(http.StatusInternalServerError) return errors.Wrap(err, "failed to copy") } - w.Header().Set("Content-Disposition", "attachment; filename=kernel") - w.Header().Set("Content-Type", FileContentType) - w.Header().Set("Content-Length", FileSize) - _, err = buf.WriteTo(w) - wwlog.Send("%15s: %s", sendto, filename) return err