-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(controller): Fixes resource version misuse. Fixes #4714 #4741
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package workflow | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"sort" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
@@ -210,13 +211,7 @@ func (s *workflowServer) WatchWorkflows(req *workflowpkg.WatchWorkflowsRequest, | |
return nil | ||
case event, open := <-watch.ResultChan(): | ||
if !open { | ||
log.Debug("Re-establishing workflow watch") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as the client must have re-connection logic, we should not try and mask/mitigate the problem here |
||
watch.Stop() | ||
watch, err = wfIf.Watch(*opts) | ||
if err != nil { | ||
return err | ||
} | ||
continue | ||
return io.EOF | ||
} | ||
log.Debug("Received workflow event") | ||
wf, ok := event.Object.(*wfv1.Workflow) | ||
|
@@ -234,8 +229,6 @@ func (s *workflowServer) WatchWorkflows(req *workflowpkg.WatchWorkflowsRequest, | |
if err != nil { | ||
return err | ||
} | ||
// when we re-establish, we want to start at the same place | ||
opts.ResourceVersion = wf.ResourceVersion | ||
} | ||
} | ||
} | ||
|
@@ -264,13 +257,7 @@ func (s *workflowServer) WatchEvents(req *workflowpkg.WatchEventsRequest, ws wor | |
return nil | ||
case event, open := <-watch.ResultChan(): | ||
if !open { | ||
log.Debug("Re-establishing event watch") | ||
watch.Stop() | ||
watch, err = eventInterface.Watch(*opts) | ||
if err != nil { | ||
return err | ||
} | ||
continue | ||
return io.EOF | ||
} | ||
log.Debug("Received event") | ||
e, ok := event.Object.(*corev1.Event) | ||
|
@@ -283,8 +270,6 @@ func (s *workflowServer) WatchEvents(req *workflowpkg.WatchEventsRequest, ws wor | |
if err != nil { | ||
return err | ||
} | ||
// when we re-establish, we want to start at the same place | ||
opts.ResourceVersion = e.ResourceVersion | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,22 @@ export default { | |
return Observable.create((observer: Observer<any>) => { | ||
const eventSource = new EventSource(url); | ||
eventSource.onmessage = x => observer.next(x.data); | ||
eventSource.onerror = x => observer.error(x); | ||
eventSource.onerror = x => { | ||
switch (eventSource.readyState) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some users are creating "unknown error" issues - lets provide clearer error message |
||
case EventSource.CONNECTING: | ||
observer.error(new Error('Failed to connect to ' + url)); | ||
break; | ||
case EventSource.OPEN: | ||
observer.error(new Error('Error in open connection to ' + url)); | ||
break; | ||
case EventSource.CLOSED: | ||
observer.error(new Error('Connection closed to ' + url)); | ||
break; | ||
default: | ||
observer.error(new Error('Unknown error with ' + url)); | ||
} | ||
}; | ||
|
||
return () => { | ||
eventSource.close(); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"0" means, start from the latest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nifty trick