mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
GCE provider: Log full contents of long operations
Dump JSON of long running (>1m) GCE operations.
This commit is contained in:
parent
7476d97781
commit
ce6537aa48
@ -402,19 +402,33 @@ func (gce *GCECloud) waitForOp(op *compute.Operation, getOperation func(operatio
|
|||||||
return getErrorFromOp(op)
|
return getErrorFromOp(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opStart := time.Now()
|
||||||
opName := op.Name
|
opName := op.Name
|
||||||
return wait.Poll(operationPollInterval, operationPollTimeoutDuration, func() (bool, error) {
|
return wait.Poll(operationPollInterval, operationPollTimeoutDuration, func() (bool, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
gce.operationPollRateLimiter.Accept()
|
gce.operationPollRateLimiter.Accept()
|
||||||
duration := time.Now().Sub(start)
|
duration := time.Now().Sub(start)
|
||||||
if duration > 5*time.Second {
|
if duration > 5*time.Second {
|
||||||
glog.Infof("pollOperation: waited %v for %v", duration, opName)
|
glog.Infof("pollOperation: throttled %v for %v", duration, opName)
|
||||||
}
|
}
|
||||||
pollOp, err := getOperation(opName)
|
pollOp, err := getOperation(opName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("GCE poll operation %s failed: pollOp: [%v] err: [%v] getErrorFromOp: [%v]", opName, pollOp, err, getErrorFromOp(pollOp))
|
glog.Warningf("GCE poll operation %s failed: pollOp: [%v] err: [%v] getErrorFromOp: [%v]", opName, pollOp, err, getErrorFromOp(pollOp))
|
||||||
}
|
}
|
||||||
return opIsDone(pollOp), getErrorFromOp(pollOp)
|
done := opIsDone(pollOp)
|
||||||
|
if done {
|
||||||
|
duration := time.Now().Sub(opStart)
|
||||||
|
if duration > 1*time.Minute {
|
||||||
|
// Log the JSON. It's cleaner than the %v structure.
|
||||||
|
enc, err := op.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("waitForOperation: long operation (%v): %v (failed to encode to JSON: %v)", duration, op, err)
|
||||||
|
} else {
|
||||||
|
glog.Infof("waitForOperation: long operation (%v): %v", duration, string(enc))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return done, getErrorFromOp(pollOp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user