mirror of
				https://github.com/onepanelio/onepanel.git
				synced 2025-11-01 01:02:32 +08:00 
			
		
		
		
	fix: handle case for watching workflow where a timeout occurs
This commit is contained in:
		| @@ -1130,8 +1130,27 @@ func (c *Client) WatchWorkflowExecution(namespace, uid string) (<-chan *Workflow | |||||||
| 		var next watch.Event | 		var next watch.Event | ||||||
| 		done := false | 		done := false | ||||||
|  |  | ||||||
|  | 		timeouts := 0 | ||||||
|  |  | ||||||
| 		for !done { | 		for !done { | ||||||
| 			for next = range watcher.ResultChan() { | 			for next = range watcher.ResultChan() { | ||||||
|  | 				watchEvent, ok := next.Object.(*metav1.Status) | ||||||
|  | 				if ok { | ||||||
|  | 					// If a timeout occurred, retry. | ||||||
|  | 					if strings.Contains(watchEvent.Message, "Client.Timeout or context cancellation") { | ||||||
|  | 						if timeouts > 5 { | ||||||
|  | 							done = true | ||||||
|  | 							break | ||||||
|  | 						} | ||||||
|  |  | ||||||
|  | 						timeouts += 1 | ||||||
|  | 						continue | ||||||
|  | 					} | ||||||
|  |  | ||||||
|  | 					done = true | ||||||
|  | 					break | ||||||
|  | 				} | ||||||
|  |  | ||||||
| 				workflow, ok := next.Object.(*wfv1.Workflow) | 				workflow, ok := next.Object.(*wfv1.Workflow) | ||||||
| 				if !ok { | 				if !ok { | ||||||
| 					done = true | 					done = true | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andrey Melnikov
					Andrey Melnikov