CSCGLOBAL: Lazy-check API results, saving 5-7 minutes per domain (#1638)

This commit is contained in:
Tom Limoncelli 2022-07-21 14:35:37 -04:00 committed by GitHub
parent b2bef175e0
commit 15e6c95042
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
"io/ioutil"
"net/http"
"os"
@ -12,6 +11,8 @@ import (
"strings"
"time"
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
"github.com/mattn/go-isatty"
)
@ -377,6 +378,7 @@ func (client *providerClient) sendZoneEditRequest(domainname string, edits []zon
return err
}
// What did we get back?
var errResp zoneEditRequestResultZoneEditRequestResult
err = json.Unmarshal(responseBody, &errResp)
if err != nil {
@ -386,9 +388,13 @@ func (client *providerClient) sendZoneEditRequest(domainname string, edits []zon
return fmt.Errorf("CSC Global API error: %s DATA: %q", errResp.Content.Status, errResp.Content.Message)
}
// The request was successfully submitted. Now query the status link until the request is complete.
statusURL := errResp.Links.Status
return client.waitRequestURL(statusURL)
// NB(tlim): The request was successfully submitted. The "statusURL" is what we query if we want to wait until the request was processed and see if it was a success.
// Right now we don't want to wait. Instead, the next time we do a mutation we wait then.
// If we ever change our mind and want to wait for success/failure, it would look like:
//statusURL := errResp.Links.Status
//return client.waitRequestURL(statusURL)
return nil
}
func (client *providerClient) waitRequest(reqID string) error {