mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Improve logging around SQL ops (#3268)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
This commit is contained in:
parent
0d6b100f2d
commit
b309ccdaab
@ -98,11 +98,15 @@ func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc {
|
|||||||
if !isRetryableError(err) {
|
if !isRetryableError(err) {
|
||||||
return nil, "", fmt.Errorf("Not retriable error: %s", err)
|
return nil, "", fmt.Errorf("Not retriable error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Saw error polling for op, but dismissed as retriable: %s", err)
|
||||||
if op == nil {
|
if op == nil {
|
||||||
return nil, "", fmt.Errorf("Cannot continue, Operation is nil. %s", err)
|
return nil, "", fmt.Errorf("Cannot continue, Operation is nil. %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] working with op %#v", op)
|
||||||
|
|
||||||
// Try to set the operation (so we can check it's Error/State),
|
// Try to set the operation (so we can check it's Error/State),
|
||||||
// and fail if we can't.
|
// and fail if we can't.
|
||||||
if err = w.SetOp(op); err != nil {
|
if err = w.SetOp(op); err != nil {
|
||||||
|
@ -3,6 +3,7 @@ package google
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
sqladmin "google.golang.org/api/sqladmin/v1beta4"
|
sqladmin "google.golang.org/api/sqladmin/v1beta4"
|
||||||
)
|
)
|
||||||
@ -14,7 +15,11 @@ type SqlAdminOperationWaiter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *SqlAdminOperationWaiter) State() string {
|
func (w *SqlAdminOperationWaiter) State() string {
|
||||||
if w == nil || w.Op == nil {
|
if w == nil {
|
||||||
|
return "Operation Waiter is nil!"
|
||||||
|
}
|
||||||
|
|
||||||
|
if w.Op == nil {
|
||||||
return "Operation is nil!"
|
return "Operation is nil!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,8 +34,13 @@ func (w *SqlAdminOperationWaiter) Error() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *SqlAdminOperationWaiter) SetOp(op interface{}) error {
|
func (w *SqlAdminOperationWaiter) SetOp(op interface{}) error {
|
||||||
var ok bool
|
if op == nil {
|
||||||
w.Op, ok = op.(*sqladmin.Operation)
|
// Starting as a log statement, this may be a useful error in the future
|
||||||
|
log.Printf("[DEBUG] attempted to set nil op")
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlOp, ok := op.(*sqladmin.Operation)
|
||||||
|
w.Op = sqlOp
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Unable to set operation. Bad type!")
|
return fmt.Errorf("Unable to set operation. Bad type!")
|
||||||
}
|
}
|
||||||
@ -39,19 +49,30 @@ func (w *SqlAdminOperationWaiter) SetOp(op interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *SqlAdminOperationWaiter) QueryOp() (interface{}, error) {
|
func (w *SqlAdminOperationWaiter) QueryOp() (interface{}, error) {
|
||||||
if w == nil || w.Op == nil {
|
if w == nil {
|
||||||
|
return nil, fmt.Errorf("Cannot query operation, waiter is unset or nil.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if w.Op == nil {
|
||||||
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
|
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.Service == nil {
|
if w.Service == nil {
|
||||||
return nil, fmt.Errorf("Cannot query operation, service is nil.")
|
return nil, fmt.Errorf("Cannot query operation, service is nil.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.Service.Operations.Get(w.Project, w.Op.Name).Do()
|
return w.Service.Operations.Get(w.Project, w.Op.Name).Do()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SqlAdminOperationWaiter) OpName() string {
|
func (w *SqlAdminOperationWaiter) OpName() string {
|
||||||
if w == nil || w.Op == nil {
|
if w == nil {
|
||||||
return "<nil>"
|
return "<nil waiter>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if w.Op == nil {
|
||||||
|
return "<nil op>"
|
||||||
|
}
|
||||||
|
|
||||||
return w.Op.Name
|
return w.Op.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user