Skip to content

Commit

Permalink
Add post-create retry for big query job (#3579) (#2122)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 29, 2020
1 parent 34ccce3 commit f82d0d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/3579.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
`bigquery`: Fixed an issue where `google_bigquery_job` would return "was present, but now absent" error after job creation
```
26 changes: 26 additions & 0 deletions google-beta/resource_big_query_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,37 @@ func resourceBigQueryJobCreate(d *schema.ResourceData, meta interface{}) error {
}
d.SetId(id)

err = PollingWaitTime(resourceBigQueryJobPollRead(d, meta), PollCheckForExistence, "Creating Job", d.Timeout(schema.TimeoutCreate))
if err != nil {
return fmt.Errorf("Error waiting to create Job: %s", err)
}

log.Printf("[DEBUG] Finished creating Job %q: %#v", d.Id(), res)

return resourceBigQueryJobRead(d, meta)
}

func resourceBigQueryJobPollRead(d *schema.ResourceData, meta interface{}) PollReadFunc {
return func() (map[string]interface{}, error) {
config := meta.(*Config)

url, err := replaceVars(d, config, "{{BigQueryBasePath}}projects/{{project}}/jobs/{{job_id}}")
if err != nil {
return nil, err
}

project, err := getProject(d, config)
if err != nil {
return nil, err
}
res, err := sendRequest(config, "GET", project, url, nil)
if err != nil {
return res, err
}
return res, nil
}
}

func resourceBigQueryJobRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

Expand Down

0 comments on commit f82d0d8

Please sign in to comment.