do not panic if DNS_WEBHOOK_ENDPOINT is not reachable (#13265)

This commit is contained in:
Harshavardhana 2021-09-22 09:16:12 -07:00 committed by GitHub
parent 32df742b85
commit 9a27c4a2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,16 +90,19 @@ func (c *OperatorDNS) Put(bucket string) error {
if err = c.addAuthHeader(req); err != nil {
return newError(bucket, err)
}
resp, err := c.httpClient.Do(req)
if err != nil {
if derr := c.Delete(bucket); derr != nil {
return newError(bucket, derr)
}
return err
}
var errorStringBuilder strings.Builder
io.Copy(&errorStringBuilder, io.LimitReader(resp.Body, resp.ContentLength))
xhttp.DrainBody(resp.Body)
defer xhttp.DrainBody(resp.Body)
if resp.StatusCode != http.StatusOK {
var errorStringBuilder strings.Builder
io.Copy(&errorStringBuilder, io.LimitReader(resp.Body, resp.ContentLength))
errorString := errorStringBuilder.String()
switch resp.StatusCode {
case http.StatusConflict: