Changed name to uid for WatchWorkflowExecution.

This commit is contained in:
Aleksandr Melnikov
2020-05-13 11:48:12 -07:00
committed by rushtehrani
parent 2048b7a4eb
commit c1ce0ad17b
2 changed files with 10 additions and 10 deletions

View File

@@ -646,25 +646,25 @@ func (c *Client) CountWorkflowExecutions(namespace, workflowTemplateUID, workflo
return
}
func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *WorkflowExecution, error) {
_, err := c.GetWorkflowExecution(namespace, name)
func (c *Client) WatchWorkflowExecution(namespace, uid string) (<-chan *WorkflowExecution, error) {
_, err := c.GetWorkflowExecution(namespace, uid)
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"Name": name,
"UID": uid,
"Error": err.Error(),
}).Error("Workflow template not found.")
return nil, util.NewUserError(codes.NotFound, "Workflow not found.")
}
fieldSelector, _ := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", name))
fieldSelector, _ := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", uid))
watcher, err := c.ArgoprojV1alpha1().Workflows(namespace).Watch(metav1.ListOptions{
FieldSelector: fieldSelector.String(),
})
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"Name": name,
"UID": uid,
"Error": err.Error(),
}).Error("Watch Workflow error.")
return nil, util.NewUserError(codes.Unknown, "Error with watching workflow.")
@@ -688,11 +688,11 @@ func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *Workflo
}
if workflow == nil && !ok {
workflow, err = c.ArgoprojV1alpha1().Workflows(namespace).Get(name, metav1.GetOptions{})
workflow, err = c.ArgoprojV1alpha1().Workflows(namespace).Get(uid, metav1.GetOptions{})
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"Name": name,
"UID": uid,
"Workflow": workflow,
"Error": err.Error(),
}).Error("Unable to get workflow.")
@@ -709,7 +709,7 @@ func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *Workflo
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"Name": name,
"UID": uid,
"Workflow": workflow,
"Error": err.Error(),
}).Error("Error with trying to JSON Marshal workflow.Status.")

View File

@@ -160,12 +160,12 @@ func (s *WorkflowServer) GetWorkflowExecution(ctx context.Context, req *api.GetW
func (s *WorkflowServer) WatchWorkflowExecution(req *api.WatchWorkflowExecutionRequest, stream api.WorkflowService_WatchWorkflowExecutionServer) error {
client := stream.Context().Value("kubeClient").(*v1.Client)
allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "workflows", req.Name)
allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "workflows", req.Uid)
if err != nil || !allowed {
return err
}
watcher, err := client.WatchWorkflowExecution(req.Namespace, req.Name)
watcher, err := client.WatchWorkflowExecution(req.Namespace, req.Uid)
if err != nil {
return err
}