mirror of
https://github.com/rancher/steve.git
synced 2025-04-27 11:00:48 +00:00
Merge pull request #52 from cmurphy/watch-logging-2.5
[2.5] Return websocket error and add logging for watches
This commit is contained in:
commit
e0e6c3209b
@ -320,6 +320,9 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
||||
obj, err := s.byID(apiOp, schema, rel.Namespace, rel.Name)
|
||||
if err == nil {
|
||||
result <- s.toAPIEvent(apiOp, schema, watch.Modified, obj)
|
||||
} else {
|
||||
logrus.Debugf("notifier watch error: %v", err)
|
||||
returnErr(errors.Wrapf(err, "notifier watch error: %v", err), result)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("closed")
|
||||
@ -329,6 +332,12 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
||||
eg.Go(func() error {
|
||||
for event := range watcher.ResultChan() {
|
||||
if event.Type == watch.Error {
|
||||
if status, ok := event.Object.(*metav1.Status); ok {
|
||||
logrus.Debugf("event watch error: %s", status.Message)
|
||||
returnErr(fmt.Errorf("event watch error: %s", status.Message), result)
|
||||
} else {
|
||||
logrus.Debugf("event watch error: could not decode event object %T", event.Object)
|
||||
}
|
||||
continue
|
||||
}
|
||||
result <- s.toAPIEvent(apiOp, schema, event.Type, event.Object)
|
||||
|
Loading…
Reference in New Issue
Block a user