Skip to content

Commit

Permalink
feat: Replace patch pod with create workflowtaskresult. Fixes #3961
Browse files Browse the repository at this point in the history
… (#8000)

Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec authored Mar 2, 2022
1 parent 9aa04a1 commit 662a729
Show file tree
Hide file tree
Showing 60 changed files with 5,252 additions and 774 deletions.
3 changes: 3 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6157,6 +6157,9 @@
},
"phase": {
"type": "string"
},
"progress": {
"type": "string"
}
},
"type": "object"
Expand Down
3 changes: 3 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -10420,6 +10420,9 @@
},
"phase": {
"type": "string"
},
"progress": {
"type": "string"
}
}
},
Expand Down
19 changes: 18 additions & 1 deletion cmd/argoexec/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
kubecli "github.com/argoproj/pkg/kube/cli"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/argoproj/argo-workflows/v3"
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned"
"github.com/argoproj/argo-workflows/v3/util"
"github.com/argoproj/argo-workflows/v3/util/cmd"
"github.com/argoproj/argo-workflows/v3/util/logs"
Expand Down Expand Up @@ -125,7 +127,22 @@ func initExecutor() *executor.WorkflowExecutor {
}
checkErr(err)

wfExecutor := executor.NewExecutor(clientset, restClient, podName, namespace, cre, *tmpl, includeScriptOutput, deadline, annotationPatchTickDuration, progressFileTickDuration)
wfExecutor := executor.NewExecutor(
clientset,
versioned.NewForConfigOrDie(config).ArgoprojV1alpha1().WorkflowTaskResults(namespace),
restClient,
podName,
os.Getenv(common.EnvVarWorkflowName),
os.Getenv(common.EnvVarNodeID),
namespace,
types.UID(os.Getenv(common.EnvVarWorkflowUID)),
cre,
*tmpl,
includeScriptOutput,
deadline,
annotationPatchTickDuration,
progressFileTickDuration,
)

log.
WithField("version", version.String()).
Expand Down
2 changes: 1 addition & 1 deletion cmd/argoexec/commands/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func waitContainer(ctx context.Context) error {
wfExecutor.AddError(err)
}
// Annotating pod with output
err = wfExecutor.AnnotateOutputs(ctx, logArt)
err = wfExecutor.ReportOutputs(ctx, logArt)
if err != nil {
wfExecutor.AddError(err)
}
Expand Down
21 changes: 21 additions & 0 deletions docs/workflow-rbac.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ permissions added to it you do not want. Instead, create a service account only

The minimum for the executor to function:

For >= v3.4:

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: executor
rules:
- apiGroups:
- argoproj.io
resources:
- workflowtaskresult
verbs:
- create
- patch
```
For <= v3.3 use.
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand All @@ -25,6 +44,8 @@ rules:
- patch
```
Warning: For many organisations, it may not be acceptable to give a workflow the `pod patch` permission, see [#3961](https://github.com/argoproj/argo-workflows/issues/3961)

If you are not using the emissary, you'll need additional permissions.
See [executor](https://github.com/argoproj/argo-workflows/tree/master/manifests/quick-start/base/executor) for suitable
permissions.
6 changes: 0 additions & 6 deletions hack/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ func cleanCRD(filename string) {
properties := schema["properties"].(obj)["spec"].(obj)["properties"].(obj)["templates"].(obj)["items"].(obj)["properties"]
properties.(obj)["container"].(obj)["required"] = []string{"image"}
properties.(obj)["script"].(obj)["required"] = []string{"image", "source"}
case "workfloweventbindings.argoproj.io":
// noop
case "workflowtasksets.argoproj.io":
// noop
default:
panic(name)
}
data, err = yaml.Marshal(crd)
if err != nil {
Expand Down
Loading

0 comments on commit 662a729

Please sign in to comment.