mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Merge pull request #3824 from smarterclayton/allow_panic_and_error_reporting
Allow panics and unhandled errors to be sent elsewhere
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -65,15 +66,15 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
|
||||
},
|
||||
}
|
||||
if err := api.Scheme.Convert(&controller.Spec.Template.Spec, &pod.Spec); err != nil {
|
||||
glog.Errorf("Unable to convert pod template: %v", err)
|
||||
util.HandleError(fmt.Errorf("unable to convert pod template: %v", err))
|
||||
return
|
||||
}
|
||||
if labels.Set(pod.Labels).AsSelector().Empty() {
|
||||
glog.Errorf("Unable to create pod replica, no labels")
|
||||
util.HandleError(fmt.Errorf("unable to create pod replica, no labels"))
|
||||
return
|
||||
}
|
||||
if _, err := r.kubeClient.Pods(namespace).Create(pod); err != nil {
|
||||
glog.Errorf("Unable to create pod replica: %v", err)
|
||||
util.HandleError(fmt.Errorf("unable to create pod replica: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
|
||||
*resourceVersion,
|
||||
)
|
||||
if err != nil {
|
||||
glog.Errorf("Unexpected failure to watch: %v", err)
|
||||
util.HandleError(fmt.Errorf("unable to watch: %v", err))
|
||||
time.Sleep(5 * time.Second)
|
||||
return
|
||||
}
|
||||
@@ -125,13 +126,13 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
|
||||
return
|
||||
}
|
||||
if event.Type == watch.Error {
|
||||
glog.Errorf("error from watch during sync: %v", errors.FromObject(event.Object))
|
||||
util.HandleError(fmt.Errorf("error from watch during sync: %v", errors.FromObject(event.Object)))
|
||||
continue
|
||||
}
|
||||
glog.V(4).Infof("Got watch: %#v", event)
|
||||
rc, ok := event.Object.(*api.ReplicationController)
|
||||
if !ok {
|
||||
glog.Errorf("unexpected object: %#v", event.Object)
|
||||
util.HandleError(fmt.Errorf("unexpected object: %#v", event.Object))
|
||||
continue
|
||||
}
|
||||
// If we get disconnected, start where we left off.
|
||||
@@ -140,7 +141,7 @@ func (rm *ReplicationManager) watchControllers(resourceVersion *string) {
|
||||
// it in the desired state.
|
||||
glog.V(4).Infof("About to sync from watch: %v", rc.Name)
|
||||
if err := rm.syncHandler(*rc); err != nil {
|
||||
glog.Errorf("unexpected sync. error: %v", err)
|
||||
util.HandleError(fmt.Errorf("unexpected sync error: %v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +200,7 @@ func (rm *ReplicationManager) synchronize() {
|
||||
var controllers []api.ReplicationController
|
||||
list, err := rm.kubeClient.ReplicationControllers(api.NamespaceAll).List(labels.Everything())
|
||||
if err != nil {
|
||||
glog.Errorf("Synchronization error: %v (%#v)", err, err)
|
||||
util.HandleError(fmt.Errorf("synchronization error: %v", err))
|
||||
return
|
||||
}
|
||||
controllers = list.Items
|
||||
@@ -211,7 +212,7 @@ func (rm *ReplicationManager) synchronize() {
|
||||
glog.V(4).Infof("periodic sync of %v", controllers[ix].Name)
|
||||
err := rm.syncHandler(controllers[ix])
|
||||
if err != nil {
|
||||
glog.Errorf("Error synchronizing: %v", err)
|
||||
util.HandleError(fmt.Errorf("error synchronizing: %v", err))
|
||||
}
|
||||
}(ix)
|
||||
}
|
||||
|
Reference in New Issue
Block a user