Skip to content

Commit 7d70725

Browse files
Joibelelliotgunton
andauthored
fix!: return latest workflow for retried-persisted workflows (cherry-pick #15030 for 3.7) (#15032)
Signed-off-by: Elliot Gunton <[email protected]> Signed-off-by: Alan Clucas <[email protected]> Co-authored-by: Elliot Gunton <[email protected]>
1 parent eb04756 commit 7d70725

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

persist/sqldb/workflow_archive.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,19 @@ func (r *workflowArchive) GetWorkflow(uid string, namespace string, name string)
384384
}
385385
num := int64(total.Total)
386386
if num > 1 {
387-
return nil, fmt.Errorf("found %d archived workflows with namespace/name: %s/%s", num, namespace, name)
387+
log.WithFields(log.Fields{
388+
"namespace": namespace,
389+
"name": name,
390+
"num": num,
391+
}).Debug("returning latest of archived workflows")
388392
}
389393
err = r.session.SQL().
390394
Select("workflow").
391395
From(archiveTableName).
392396
Where(r.clusterManagedNamespaceAndInstanceID()).
393397
And(namespaceEqual(namespace)).
394398
And(nameEqual(name)).
399+
OrderBy("-startedat").
395400
One(archivedWf)
396401
} else {
397402
return nil, sutils.ToStatusError(fmt.Errorf("both name and namespace are required if uid is not specified"), codes.InvalidArgument)

0 commit comments

Comments
 (0)