Previews: create crawler auth setup service (#47349)
* #46968: add `RetrieveServiceAccountIdByName` to serviceaccounts service * #46968: improve error logging in rendering service * #46968: add oss crawler account setup * #46968: fix tests * #46968: switch back to ROLE_ADMIN * #46968: rename to crawlerAuth * comment crawler_auth.go
This commit is contained in:
@@ -46,7 +46,8 @@ func (rs *RenderingService) renderViaHTTP(ctx context.Context, renderKey string,
|
||||
}
|
||||
|
||||
queryParams := rendererURL.Query()
|
||||
queryParams.Add("url", rs.getURL(opts.Path))
|
||||
url := rs.getURL(opts.Path)
|
||||
queryParams.Add("url", url)
|
||||
queryParams.Add("renderKey", renderKey)
|
||||
queryParams.Add("width", strconv.Itoa(opts.Width))
|
||||
queryParams.Add("height", strconv.Itoa(opts.Height))
|
||||
@@ -74,7 +75,7 @@ func (rs *RenderingService) renderViaHTTP(ctx context.Context, renderKey string,
|
||||
}
|
||||
}()
|
||||
|
||||
err = rs.readFileResponse(reqContext, resp, filePath)
|
||||
err = rs.readFileResponse(reqContext, resp, filePath, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -94,7 +95,8 @@ func (rs *RenderingService) renderCSVViaHTTP(ctx context.Context, renderKey stri
|
||||
}
|
||||
|
||||
queryParams := rendererURL.Query()
|
||||
queryParams.Add("url", rs.getURL(opts.Path))
|
||||
url := rs.getURL(opts.Path)
|
||||
queryParams.Add("url", url)
|
||||
queryParams.Add("renderKey", renderKey)
|
||||
queryParams.Add("domain", rs.domain)
|
||||
queryParams.Add("timezone", isoTimeOffsetToPosixTz(opts.Timezone))
|
||||
@@ -125,7 +127,7 @@ func (rs *RenderingService) renderCSVViaHTTP(ctx context.Context, renderKey stri
|
||||
}
|
||||
downloadFileName := params["filename"]
|
||||
|
||||
err = rs.readFileResponse(reqContext, resp, filePath)
|
||||
err = rs.readFileResponse(reqContext, resp, filePath, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -156,7 +158,7 @@ func (rs *RenderingService) doRequest(ctx context.Context, url *url.URL, headers
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (rs *RenderingService) readFileResponse(ctx context.Context, resp *http.Response, filePath string) error {
|
||||
func (rs *RenderingService) readFileResponse(ctx context.Context, resp *http.Response, filePath string, url string) error {
|
||||
// check for timeout first
|
||||
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
||||
rs.log.Info("Rendering timed out")
|
||||
@@ -165,7 +167,7 @@ func (rs *RenderingService) readFileResponse(ctx context.Context, resp *http.Res
|
||||
|
||||
// if we didn't get a 200 response, something went wrong.
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
rs.log.Error("Remote rendering request failed", "error", resp.Status)
|
||||
rs.log.Error("Remote rendering request failed", "error", resp.Status, "url", url)
|
||||
return fmt.Errorf("remote rendering request failed, status code: %d, status: %s", resp.StatusCode,
|
||||
resp.Status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user