Submit a workflow and return outputs with a single API request #12995
-
I have a workflow that returns some data. It's very fast so should complete before any http request timeout. I'd like to trigger the workflow and get the response in a single API request. Is it possible to submit a workflow and get the response in a single API request? const namespace = process.env.ARGO_NAMESPACE;
const templateName = "very-fast-workflow";
const workflow = {
apiVersion: 'argoproj.io/v1alpha1',
kind: 'Workflow',
spec: {
arguments: {
parameters: [
{
name: 'json',
value: JSON.stringify(jsonArgs),
},
],
},
workflowTemplateRef: {
name: templateName,
},
},
};
const payload = { namespace, workflow };
// this resolves once the workflow is submitted, but I want to wait until it finishes and return the results
await axiosArgo.post(`${process.env.ARGO_URL}/api/v1/workflows/${namesapce}`, payload); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The CLI would make multiple requests to achieve your goal. Essentially, |
Beta Was this translation helpful? Give feedback.
-
You can't. Workflows are asynchronous. In general, most k8s resources are. For instance, when you create a Pod, it does not get instantly run, it only gets scheduled to run. Workflows are the same.
You can add |
Beta Was this translation helpful? Give feedback.
You can't. Workflows are asynchronous. In general, most k8s resources are. For instance, when you create a Pod, it does not get instantly run, it only gets scheduled to run. Workflows are the same.
argo wait
performs a k8swatch
. So anargo submit
followed by anargo wait
is 2 API requests.You can add
listOptions.watch
to a get request to watch a resource via the API.