Move defer out of the for loop

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2026-02-17 14:57:32 -07:00
parent ff1bf8030c
commit 6e85852c29

View File

@@ -326,7 +326,6 @@ func updateSystem(target string, ipaddr string, port int, wwid string, tag strin
wwlog.Debug("making request: %s", getURL)
resp, err = Webclient.Get(getURL.String())
if err == nil {
defer resp.Body.Close()
break
} else {
var certificateInvalidError x509.CertificateInvalidError
@@ -348,6 +347,7 @@ func updateSystem(target string, ipaddr string, port int, wwid string, tag strin
}
time.Sleep(1000 * time.Millisecond)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
wwlog.Warn("not applying runtime overlay: got status code: %d", resp.StatusCode)
time.Sleep(60000 * time.Millisecond)