cloud/shepherd/wrapngo: don't crash on remote API errors
A regression test for this will come in a subsequent CL.
Change-Id: Ic2c1f872bcea510bef7adbdb6ed86f504733ecca
Reviewed-on: https://review.monogon.dev/c/monogon/+/1549
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/cloud/shepherd/equinix/wrapngo/duct_tape.go b/cloud/shepherd/equinix/wrapngo/duct_tape.go
index c9e156b..f58cf7b 100644
--- a/cloud/shepherd/equinix/wrapngo/duct_tape.go
+++ b/cloud/shepherd/equinix/wrapngo/duct_tape.go
@@ -65,7 +65,11 @@
func (r *injectContextRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
klog.V(5).Infof("Request -> %v", req.URL.String())
res, err := r.original.RoundTrip(req.WithContext(r.ctx))
- klog.V(5).Infof("Response <- %v", res.Status)
+ if err != nil {
+ klog.V(5).Infof("HTTP error <- %v", err)
+ } else {
+ klog.V(5).Infof("Response <- %v", res.Status)
+ }
return res, err
}