Skip to content

Commit

Permalink
feat: Add resume/suspend endpoints for CronWorkflows (argoproj#4457)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Behar <[email protected]>
  • Loading branch information
simster7 committed Nov 5, 2020
1 parent 42d0605 commit d752e2f
Show file tree
Hide file tree
Showing 12 changed files with 1,063 additions and 72 deletions.
98 changes: 98 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,82 @@
}
}
},
"/api/v1/cron-workflows/{namespace}/{name}/resume": {
"put": {
"tags": [
"CronWorkflowService"
],
"operationId": "ResumeCronWorkflow",
"parameters": [
{
"type": "string",
"name": "namespace",
"in": "path",
"required": true
},
{
"type": "string",
"name": "name",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.CronWorkflowResumeRequest"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.CronWorkflow"
}
}
}
}
},
"/api/v1/cron-workflows/{namespace}/{name}/suspend": {
"put": {
"tags": [
"CronWorkflowService"
],
"operationId": "SuspendCronWorkflow",
"parameters": [
{
"type": "string",
"name": "namespace",
"in": "path",
"required": true
},
{
"type": "string",
"name": "name",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.CronWorkflowSuspendRequest"
}
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.CronWorkflow"
}
}
}
}
},
"/api/v1/events/{namespace}/{discriminator}": {
"post": {
"tags": [
Expand Down Expand Up @@ -2453,6 +2529,17 @@
}
}
},
"io.argoproj.workflow.v1alpha1.CronWorkflowResumeRequest": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string"
}
}
},
"io.argoproj.workflow.v1alpha1.CronWorkflowSpec": {
"description": "CronWorkflowSpec is the specification of a CronWorkflow",
"type": "object",
Expand Down Expand Up @@ -2531,6 +2618,17 @@
}
}
},
"io.argoproj.workflow.v1alpha1.CronWorkflowSuspendRequest": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string"
}
}
},
"io.argoproj.workflow.v1alpha1.DAGTask": {
"description": "DAGTask represents a node in the graph during DAG execution",
"type": "object",
Expand Down
9 changes: 1 addition & 8 deletions cmd/argo/commands/cron/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@ func NewResumeCommand() *cobra.Command {
serviceClient := apiClient.NewCronWorkflowServiceClient()
namespace := client.Namespace()
for _, name := range args {
cronWf, err := serviceClient.GetCronWorkflow(ctx, &cronworkflowpkg.GetCronWorkflowRequest{
_, err := serviceClient.ResumeCronWorkflow(ctx, &cronworkflowpkg.CronWorkflowResumeRequest{
Name: name,
Namespace: namespace,
})
errors.CheckError(err)
cronWf.Spec.Suspend = false
_, err = serviceClient.UpdateCronWorkflow(ctx, &cronworkflowpkg.UpdateCronWorkflowRequest{
Name: cronWf.Name,
Namespace: cronWf.Namespace,
CronWorkflow: cronWf,
})
errors.CheckError(err)
fmt.Printf("CronWorkflow '%s' resumed\n", name)
}
},
Expand Down
8 changes: 1 addition & 7 deletions cmd/argo/commands/cron/suspend.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ func NewSuspendCommand() *cobra.Command {
serviceClient := apiClient.NewCronWorkflowServiceClient()
namespace := client.Namespace()
for _, name := range args {
cronWf, err := serviceClient.GetCronWorkflow(ctx, &cronworkflowpkg.GetCronWorkflowRequest{
cronWf, err := serviceClient.SuspendCronWorkflow(ctx, &cronworkflowpkg.CronWorkflowSuspendRequest{
Name: name,
Namespace: namespace,
})
errors.CheckError(err)
cronWf.Spec.Suspend = true
_, err = serviceClient.UpdateCronWorkflow(ctx, &cronworkflowpkg.UpdateCronWorkflowRequest{
Name: name,
Namespace: namespace,
CronWorkflow: cronWf,
})
errors.CheckError(err)
fmt.Printf("CronWorkflow '%s' suspended\n", name)
}
},
Expand Down
8 changes: 8 additions & 0 deletions pkg/apiclient/argo-kube-cron-workflow-service-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ func (c *argoKubeCronWorkflowServiceClient) UpdateCronWorkflow(ctx context.Conte
func (c *argoKubeCronWorkflowServiceClient) DeleteCronWorkflow(ctx context.Context, req *cronworkflowpkg.DeleteCronWorkflowRequest, _ ...grpc.CallOption) (*cronworkflowpkg.CronWorkflowDeletedResponse, error) {
return c.delegate.DeleteCronWorkflow(ctx, req)
}

func (c *argoKubeCronWorkflowServiceClient) ResumeCronWorkflow(ctx context.Context, req *cronworkflowpkg.CronWorkflowResumeRequest, _ ...grpc.CallOption) (*v1alpha1.CronWorkflow, error) {
return c.delegate.ResumeCronWorkflow(ctx, req)
}

func (c *argoKubeCronWorkflowServiceClient) SuspendCronWorkflow(ctx context.Context, req *cronworkflowpkg.CronWorkflowSuspendRequest, _ ...grpc.CallOption) (*v1alpha1.CronWorkflow, error) {
return c.delegate.SuspendCronWorkflow(ctx, req)
}
Loading

0 comments on commit d752e2f

Please sign in to comment.