@@ -150,7 +150,7 @@ func (s *workflowServer) GetWorkflow(ctx context.Context, req *workflowpkg.Workf
150150 wfGetOption = * req .GetOptions
151151 }
152152 wfClient := auth .GetWfClient (ctx )
153- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , wfGetOption )
153+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , req . Uid , wfGetOption )
154154 if err != nil {
155155 return nil , sutils .ToStatusError (err , codes .Internal )
156156 }
@@ -311,7 +311,7 @@ func (s *workflowServer) WatchWorkflows(req *workflowpkg.WatchWorkflowsRequest,
311311 if wfName != "" {
312312 // If we are using an alias (such as `@latest`) we need to dereference it.
313313 // s.getWorkflow does that for us
314- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , wfName , metav1.GetOptions {})
314+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , wfName , "" , metav1.GetOptions {})
315315 if err != nil {
316316 return sutils .ToStatusError (err , codes .Internal )
317317 }
@@ -432,7 +432,7 @@ func (s *workflowServer) WatchEvents(req *workflowpkg.WatchEventsRequest, ws wor
432432
433433func (s * workflowServer ) DeleteWorkflow (ctx context.Context , req * workflowpkg.WorkflowDeleteRequest ) (* workflowpkg.WorkflowDeleteResponse , error ) {
434434 wfClient := auth .GetWfClient (ctx )
435- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
435+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
436436 if err != nil {
437437 return nil , sutils .ToStatusError (err , codes .Internal )
438438 }
@@ -467,7 +467,7 @@ func (s *workflowServer) RetryWorkflow(ctx context.Context, req *workflowpkg.Wor
467467 wfClient := auth .GetWfClient (ctx )
468468 kubeClient := auth .GetKubeClient (ctx )
469469
470- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
470+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
471471 if err != nil {
472472 return nil , sutils .ToStatusError (err , codes .Internal )
473473 }
@@ -525,7 +525,7 @@ func (s *workflowServer) RetryWorkflow(ctx context.Context, req *workflowpkg.Wor
525525
526526func (s * workflowServer ) ResubmitWorkflow (ctx context.Context , req * workflowpkg.WorkflowResubmitRequest ) (* wfv1.Workflow , error ) {
527527 wfClient := auth .GetWfClient (ctx )
528- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
528+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
529529 if err != nil {
530530 return nil , sutils .ToStatusError (err , codes .Internal )
531531 }
@@ -550,7 +550,7 @@ func (s *workflowServer) ResubmitWorkflow(ctx context.Context, req *workflowpkg.
550550
551551func (s * workflowServer ) ResumeWorkflow (ctx context.Context , req * workflowpkg.WorkflowResumeRequest ) (* wfv1.Workflow , error ) {
552552 wfClient := auth .GetWfClient (ctx )
553- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
553+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
554554 if err != nil {
555555 return nil , sutils .ToStatusError (err , codes .Internal )
556556 }
@@ -579,7 +579,7 @@ func (s *workflowServer) ResumeWorkflow(ctx context.Context, req *workflowpkg.Wo
579579func (s * workflowServer ) SuspendWorkflow (ctx context.Context , req * workflowpkg.WorkflowSuspendRequest ) (* wfv1.Workflow , error ) {
580580 wfClient := auth .GetWfClient (ctx )
581581
582- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
582+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
583583 if err != nil {
584584 return nil , sutils .ToStatusError (err , codes .Internal )
585585 }
@@ -605,7 +605,7 @@ func (s *workflowServer) SuspendWorkflow(ctx context.Context, req *workflowpkg.W
605605func (s * workflowServer ) TerminateWorkflow (ctx context.Context , req * workflowpkg.WorkflowTerminateRequest ) (* wfv1.Workflow , error ) {
606606 wfClient := auth .GetWfClient (ctx )
607607
608- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
608+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
609609 if err != nil {
610610 return nil , sutils .ToStatusError (err , codes .Internal )
611611 }
@@ -629,7 +629,7 @@ func (s *workflowServer) TerminateWorkflow(ctx context.Context, req *workflowpkg
629629
630630func (s * workflowServer ) StopWorkflow (ctx context.Context , req * workflowpkg.WorkflowStopRequest ) (* wfv1.Workflow , error ) {
631631 wfClient := auth .GetWfClient (ctx )
632- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
632+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
633633 if err != nil {
634634 return nil , sutils .ToStatusError (err , codes .Internal )
635635 }
@@ -651,7 +651,7 @@ func (s *workflowServer) StopWorkflow(ctx context.Context, req *workflowpkg.Work
651651
652652func (s * workflowServer ) SetWorkflow (ctx context.Context , req * workflowpkg.WorkflowSetRequest ) (* wfv1.Workflow , error ) {
653653 wfClient := auth .GetWfClient (ctx )
654- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
654+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
655655 if err != nil {
656656 return nil , sutils .ToStatusError (err , codes .Internal )
657657 }
@@ -715,7 +715,7 @@ func (s *workflowServer) PodLogs(req *workflowpkg.WorkflowLogRequest, ws workflo
715715 ctx := ws .Context ()
716716 wfClient := auth .GetWfClient (ctx )
717717 kubeClient := auth .GetKubeClient (ctx )
718- wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , metav1.GetOptions {})
718+ wf , err := s .getWorkflow (ctx , wfClient , req .Namespace , req .Name , "" , metav1.GetOptions {})
719719 if err != nil {
720720 return sutils .ToStatusError (err , codes .Internal )
721721 }
@@ -738,7 +738,7 @@ func (s *workflowServer) WorkflowLogs(req *workflowpkg.WorkflowLogRequest, ws wo
738738 return sutils .ToStatusError (s .PodLogs (req , ws ), codes .Internal )
739739}
740740
741- func (s * workflowServer ) getWorkflow (ctx context.Context , wfClient versioned.Interface , namespace string , name string , options metav1.GetOptions ) (* wfv1.Workflow , error ) {
741+ func (s * workflowServer ) getWorkflow (ctx context.Context , wfClient versioned.Interface , namespace string , name string , uid string , options metav1.GetOptions ) (* wfv1.Workflow , error ) {
742742 logger := logging .RequireLoggerFromContext (ctx )
743743 if name == latestAlias {
744744 latest , err := getLatestWorkflow (ctx , wfClient , namespace )
@@ -751,7 +751,7 @@ func (s *workflowServer) getWorkflow(ctx context.Context, wfClient versioned.Int
751751
752752 wf , origErr := wfClient .ArgoprojV1alpha1 ().Workflows (namespace ).Get (ctx , name , options )
753753 // fallback to retrieve from archived workflows
754- if wf == nil || origErr != nil {
754+ if wf == nil || origErr != nil || ( uid != "" && string ( wf . UID ) != uid ) {
755755 allowed , err := auth .CanI (ctx , "get" , workflow .WorkflowPlural , namespace , name )
756756 if err != nil {
757757 return nil , getWorkflowOrigErr (ctx , origErr , err )
@@ -761,7 +761,7 @@ func (s *workflowServer) getWorkflow(ctx context.Context, wfClient versioned.Int
761761 return nil , getWorkflowOrigErr (ctx , origErr , err )
762762 }
763763
764- wf , err = s .wfArchive .GetWorkflow (ctx , "" , namespace , name )
764+ wf , err = s .wfArchive .GetWorkflow (ctx , uid , namespace , name )
765765 if wf == nil || err != nil {
766766 return nil , getWorkflowOrigErr (ctx , origErr , err )
767767 }
0 commit comments