Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/argoproj/argo
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabala1979 committed Feb 21, 2020
2 parents ccc86c7 + 47b4fc2 commit 4702130
Show file tree
Hide file tree
Showing 26 changed files with 534 additions and 547 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ K3D := $(shell if [ "`kubectl config current-context`" = "k3s-
ARGO_TOKEN = $(shell kubectl -n argo get secret -o name | grep argo-server | xargs kubectl -n argo get -o jsonpath='{.data.token}' | base64 --decode)

override LDFLAGS += \
-X ${PACKAGE}.version=$(VERSION) \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}
-X github.com/argoproj/argo.version=$(VERSION) \
-X github.com/argoproj/argo.buildDate=${BUILD_DATE} \
-X github.com/argoproj/argo.gitCommit=${GIT_COMMIT} \
-X github.com/argoproj/argo.gitTreeState=${GIT_TREE_STATE}

ifeq ($(STATIC_BUILD), true)
override LDFLAGS += -extldflags "-static"
endif

ifneq ($(GIT_TAG),)
override LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
override LDFLAGS += -X github.com/argoproj/argo.gitTag=${GIT_TAG}
endif

ARGOEXEC_PKGS := $(shell echo cmd/argoexec && go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo' | cut -c 26-)
Expand Down
4 changes: 0 additions & 4 deletions api/argo-server/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4729,10 +4729,6 @@
"description": "Location in which all files related to the step will be stored (logs, artifacts, etc...).\nCan be overridden by individual items in Outputs. If omitted, will use the default\nartifact repository location configured in the controller, appended with the\n\u003cworkflowname\u003e/\u003cnodename\u003e in the key.",
"$ref": "#/definitions/v1alpha1ArtifactLocation"
},
"arguments": {
"description": "Arguments hold arguments to the template.",
"$ref": "#/definitions/v1alpha1Arguments"
},
"automountServiceAccountToken": {
"description": "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted in pods.\nServiceAccountName of ExecutorConfig must be specified if this value is false.",
"type": "boolean",
Expand Down
4 changes: 0 additions & 4 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,10 +1239,6 @@
"description": "Location in which all files related to the step will be stored (logs, artifacts, etc...). Can be overridden by individual items in Outputs. If omitted, will use the default artifact repository location configured in the controller, appended with the \u003cworkflowname\u003e/\u003cnodename\u003e in the key.",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ArtifactLocation"
},
"arguments": {
"description": "Arguments hold arguments to the template.",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Arguments"
},
"automountServiceAccountToken": {
"description": "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted in pods. ServiceAccountName of ExecutorConfig must be specified if this value is false.",
"type": "boolean"
Expand Down
55 changes: 12 additions & 43 deletions cmd/argo/commands/resubmit.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package commands

import (
"log"
"os"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/argoproj/argo/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
"github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
apiUtil "github.com/argoproj/argo/util/api"
"github.com/argoproj/argo/workflow/util"
)

func NewResubmitCommand() *cobra.Command {
Expand All @@ -21,47 +14,23 @@ func NewResubmitCommand() *cobra.Command {
cliSubmitOpts cliSubmitOpts
)
var command = &cobra.Command{
Use: "resubmit WORKFLOW",
Short: "resubmit a workflow",
Use: "resubmit [WORKFLOW...]",
Short: "resubmit one or more workflows",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
namespace := client.Namespace()

namespace, _, err := client.Config.Namespace()
if err != nil {
log.Fatal(err)
}
var created *v1alpha1.Workflow

if client.ArgoServer != "" {
conn := client.GetClientConn()
defer conn.Close()
apiGRPCClient, ctx := GetWFApiServerGRPCClient(conn)
errors.CheckError(err)
wfReq := workflowpkg.WorkflowGetRequest{
for _, name := range args {
created, err := serviceClient.ResubmitWorkflow(ctx, &workflowpkg.WorkflowResubmitRequest{
Namespace: namespace,
Name: args[0],
}
wf, err := apiGRPCClient.GetWorkflow(ctx, &wfReq)
errors.CheckError(err)
newWF, err := util.FormulateResubmitWorkflow(wf, memoized)
errors.CheckError(err)
newWF.Namespace = namespace
created, err = apiUtil.SubmitWorkflowToAPIServer(apiGRPCClient, ctx, newWF, false)
errors.CheckError(err)
} else {
wfClient := InitWorkflowClient()
wf, err := wfClient.Get(args[0], metav1.GetOptions{})
errors.CheckError(err)
newWF, err := util.FormulateResubmitWorkflow(wf, memoized)
errors.CheckError(err)
created, err = util.SubmitWorkflow(wfClient, wfClientset, namespace, newWF, &util.SubmitOpts{})
Name: name,
Memoized: memoized,
})
errors.CheckError(err)
printWorkflow(created, cliSubmitOpts.output, DefaultStatus)
waitOrWatch([]string{created.Name}, cliSubmitOpts)
}
printWorkflow(created, cliSubmitOpts.output, DefaultStatus)
waitOrWatch([]string{created.Name}, cliSubmitOpts)
},
}

Expand Down
43 changes: 13 additions & 30 deletions cmd/argo/commands/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,32 @@ package commands
import (
"fmt"
"log"
"os"

"github.com/spf13/cobra"

"github.com/argoproj/argo/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
"github.com/argoproj/argo/workflow/util"
)

func NewResumeCommand() *cobra.Command {
var command = &cobra.Command{
Use: "resume WORKFLOW1 WORKFLOW2...",
Short: "resume a workflow",
Short: "resume zero or more workflows",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
namespace, _, _ := client.Config.Namespace()
if client.ArgoServer != "" {
conn := client.GetClientConn()
apiGRPCClient, ctx := GetWFApiServerGRPCClient(conn)
for _, wfName := range args {
wfUptReq := workflowpkg.WorkflowResumeRequest{
Name: wfName,
Namespace: namespace,
}
wf, err := apiGRPCClient.ResumeWorkflow(ctx, &wfUptReq)
if err != nil {
log.Fatalf("Failed to resume %s: %+v", wfName, err)
}
fmt.Printf("workflow %s resumed\n", wf.Name)
}
} else {
InitWorkflowClient()
for _, wfName := range args {
err := util.ResumeWorkflow(wfClient, wfName)
if err != nil {
log.Fatalf("Failed to resume %s: %+v", wfName, err)
}
fmt.Printf("workflow %s resumed\n", wfName)
ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
namespace := client.Namespace()
for _, wfName := range args {
_, err := serviceClient.ResumeWorkflow(ctx, &workflowpkg.WorkflowResumeRequest{
Name: wfName,
Namespace: namespace,
})
if err != nil {
log.Fatalf("Failed to resume %s: %+v", wfName, err)
}
fmt.Printf("workflow %s resumed\n", wfName)
}

},
}
return command
Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If you're using the Argo Server (e.g. because you need large workflow support or
command.AddCommand(NewSubmitCommand())
command.AddCommand(NewSuspendCommand())
command.AddCommand(auth.NewAuthCommand())
command.AddCommand(NewWatchCommand())
command.AddCommand(NewWaitCommand())
command.AddCommand(NewWatchCommand())
command.AddCommand(NewTerminateCommand())
command.AddCommand(archive.NewArchiveCommand())
Expand Down
42 changes: 12 additions & 30 deletions cmd/argo/commands/suspend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,30 @@ package commands
import (
"fmt"
"log"
"os"

"github.com/spf13/cobra"

"github.com/argoproj/argo/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
"github.com/argoproj/argo/workflow/util"
)

func NewSuspendCommand() *cobra.Command {
var command = &cobra.Command{
Use: "suspend WORKFLOW1 WORKFLOW2...",
Short: "suspend a workflow",
Short: "suspend zero or more workflow",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}
namespace, _, _ := client.Config.Namespace()
if client.ArgoServer != "" {
conn := client.GetClientConn()
apiGRPCClient, ctx := GetWFApiServerGRPCClient(conn)
for _, wfName := range args {
wfUptReq := workflowpkg.WorkflowSuspendRequest{
Name: wfName,
Namespace: namespace,
}
wf, err := apiGRPCClient.SuspendWorkflow(ctx, &wfUptReq)
if err != nil {
log.Fatalf("Failed to suspended %s: %+v", wfName, err)
}
fmt.Printf("workflow %s suspended\n", wf.Name)
}
} else {
InitWorkflowClient()
for _, wfName := range args {
err := util.SuspendWorkflow(wfClient, wfName)
if err != nil {
log.Fatalf("Failed to suspend %s: %v", wfName, err)
}
fmt.Printf("workflow %s suspended\n", wfName)
ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
namespace := client.Namespace()
for _, wfName := range args {
_, err := serviceClient.SuspendWorkflow(ctx, &workflowpkg.WorkflowSuspendRequest{
Name: wfName,
Namespace: namespace,
})
if err != nil {
log.Fatalf("Failed to suspended %s: %+v", wfName, err)
}
fmt.Printf("workflow %s suspended\n", wfName)
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions persist/sqldb/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (m migrate) Exec(ctx context.Context) error {
ansiSQLChange(`alter table argo_archived_workflows alter column finishedat set not null`),
),
ansiSQLChange(`alter table argo_archived_workflows add clustername varchar(64)`), // DNS entry can only be max 63 bytes
ansiSQLChange(`update argo_archived_workflows set clustername = ` + m.clusterName + ` where clustername is null`),
ansiSQLChange(`update argo_archived_workflows set clustername = '` + m.clusterName + `' where clustername is null`),
ternary(dbType == MySQL,
ansiSQLChange(`alter table argo_archived_workflows modify column clustername varchar(64) not null`),
ansiSQLChange(`alter table argo_archived_workflows alter column clustername set not null`),
Expand All @@ -157,7 +157,7 @@ func (m migrate) Exec(ctx context.Context) error {
ansiSQLChange(`alter table `+m.tableName+` alter column namespace set not null`),
),
ansiSQLChange(`alter table ` + m.tableName + ` add column clustername varchar(64)`), // DNS cannot be longer than 64 bytes
ansiSQLChange(`update ` + m.tableName + ` set clustername = ` + m.clusterName + ` where clustername is null`),
ansiSQLChange(`update ` + m.tableName + ` set clustername = '` + m.clusterName + `' where clustername is null`),
ternary(dbType == MySQL,
ansiSQLChange(`alter table `+m.tableName+` modify column clustername varchar(64) not null`),
ansiSQLChange(`alter table `+m.tableName+` alter column clustername set not null`),
Expand Down
47 changes: 36 additions & 11 deletions pkg/apiclient/classic-workflow-service-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ func (k *classicWorkflowServiceClient) checkServerVersionForDryRun() (bool, erro
return true, nil
}

func (k *classicWorkflowServiceClient) GetWorkflow(_ context.Context, in *workflowpkg.WorkflowGetRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
options := metav1.GetOptions{}
if in.GetOptions != nil {
options = *in.GetOptions
func (k *classicWorkflowServiceClient) GetWorkflow(_ context.Context, req *workflowpkg.WorkflowGetRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
return k.getWorkflow(req.Namespace, req.Name, req.GetOptions)
}

func (k *classicWorkflowServiceClient) getWorkflow(namespace, name string, options *metav1.GetOptions) (*v1alpha1.Workflow, error) {
if options == nil {
options = &metav1.GetOptions{}
}
wf, err := k.ArgoprojV1alpha1().Workflows(in.Namespace).Get(in.Name, options)
wf, err := k.Interface.ArgoprojV1alpha1().Workflows(namespace).Get(name, *options)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -121,16 +124,38 @@ func (k *classicWorkflowServiceClient) RetryWorkflow(_ context.Context, _ *workf
panic("implement me")
}

func (k *classicWorkflowServiceClient) ResubmitWorkflow(_ context.Context, _ *workflowpkg.WorkflowResubmitRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
panic("implement me")
func (k *classicWorkflowServiceClient) ResubmitWorkflow(_ context.Context, req *workflowpkg.WorkflowResubmitRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
wf, err := k.getWorkflow(req.Namespace, req.Name, nil)
if err != nil {
return nil, err
}
newWF, err := util.FormulateResubmitWorkflow(wf, req.Memoized)
if err != nil {
return nil, err
}
created, err := util.SubmitWorkflow(k.Interface.ArgoprojV1alpha1().Workflows(req.Namespace), k.Interface, req.Namespace, newWF, &util.SubmitOpts{})
if err != nil {
return nil, err
}
return created, nil
}

func (k *classicWorkflowServiceClient) ResumeWorkflow(_ context.Context, _ *workflowpkg.WorkflowResumeRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
panic("implement me")
func (k *classicWorkflowServiceClient) ResumeWorkflow(_ context.Context, req *workflowpkg.WorkflowResumeRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
workflowInterface := k.Interface.ArgoprojV1alpha1().Workflows(req.Namespace)
err := util.ResumeWorkflow(workflowInterface, req.Name)
if err != nil {
return nil, err
}
return workflowInterface.Get(req.Name, metav1.GetOptions{})
}

func (k *classicWorkflowServiceClient) SuspendWorkflow(_ context.Context, _ *workflowpkg.WorkflowSuspendRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
panic("implement me")
func (k *classicWorkflowServiceClient) SuspendWorkflow(_ context.Context, req *workflowpkg.WorkflowSuspendRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
workflowInterface := k.Interface.ArgoprojV1alpha1().Workflows(req.Namespace)
err := util.SuspendWorkflow(workflowInterface, req.Name)
if err != nil {
return nil, err
}
return workflowInterface.Get(req.Name, metav1.GetOptions{})
}

func (k *classicWorkflowServiceClient) TerminateWorkflow(_ context.Context, _ *workflowpkg.WorkflowTerminateRequest, _ ...grpc.CallOption) (*v1alpha1.Workflow, error) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/apiclient/cronworkflow/cron-workflow.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3628,10 +3628,6 @@
"type": "string",
"description": "Template is the name of the template which is used as the base of this template."
},
"arguments": {
"$ref": "#/definitions/v1alpha1Arguments",
"description": "Arguments hold arguments to the template."
},
"templateRef": {
"$ref": "#/definitions/v1alpha1TemplateRef",
"description": "TemplateRef is the reference to the template resource which is used as the base of this template."
Expand Down
4 changes: 0 additions & 4 deletions pkg/apiclient/workflow/workflow.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3935,10 +3935,6 @@
"type": "string",
"description": "Template is the name of the template which is used as the base of this template."
},
"arguments": {
"$ref": "#/definitions/v1alpha1Arguments",
"description": "Arguments hold arguments to the template."
},
"templateRef": {
"$ref": "#/definitions/v1alpha1TemplateRef",
"description": "TemplateRef is the reference to the template resource which is used as the base of this template."
Expand Down
4 changes: 0 additions & 4 deletions pkg/apiclient/workflowarchive/workflow-archive.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3265,10 +3265,6 @@
"type": "string",
"description": "Template is the name of the template which is used as the base of this template."
},
"arguments": {
"$ref": "#/definitions/v1alpha1Arguments",
"description": "Arguments hold arguments to the template."
},
"templateRef": {
"$ref": "#/definitions/v1alpha1TemplateRef",
"description": "TemplateRef is the reference to the template resource which is used as the base of this template."
Expand Down
4 changes: 0 additions & 4 deletions pkg/apiclient/workflowtemplate/workflow-template.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3298,10 +3298,6 @@
"type": "string",
"description": "Template is the name of the template which is used as the base of this template."
},
"arguments": {
"$ref": "#/definitions/v1alpha1Arguments",
"description": "Arguments hold arguments to the template."
},
"templateRef": {
"$ref": "#/definitions/v1alpha1TemplateRef",
"description": "TemplateRef is the reference to the template resource which is used as the base of this template."
Expand Down
Loading

0 comments on commit 4702130

Please sign in to comment.