forked from argoproj/argo-workflows
/
util.go
608 lines (563 loc) · 20.1 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
package common
import (
"bytes"
"encoding/json"
"fmt"
"io"
"math/rand"
"os/exec"
"regexp"
"strconv"
"strings"
"time"
"github.com/argoproj/argo/errors"
"github.com/argoproj/argo/pkg/apis/workflow"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
"github.com/argoproj/argo/util/retry"
log "github.com/sirupsen/logrus"
"github.com/valyala/fasttemplate"
apiv1 "k8s.io/api/core/v1"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
apivalidation "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/remotecommand"
)
// FindOverlappingVolume looks an artifact path, checks if it overlaps with any
// user specified volumeMounts in the template, and returns the deepest volumeMount
// (if any).
func FindOverlappingVolume(tmpl *wfv1.Template, path string) *apiv1.VolumeMount {
if tmpl.Container == nil {
return nil
}
var volMnt *apiv1.VolumeMount
deepestLen := 0
for _, mnt := range tmpl.Container.VolumeMounts {
if !strings.HasPrefix(path, mnt.MountPath) {
continue
}
if len(mnt.MountPath) > deepestLen {
volMnt = &mnt
deepestLen = len(mnt.MountPath)
}
}
return volMnt
}
// KillPodContainer is a convenience function to issue a kill signal to a container in a pod
// It gives a 15 second grace period before issuing SIGKILL
// NOTE: this only works with containers that have sh
func KillPodContainer(restConfig *rest.Config, namespace string, pod string, container string) error {
exec, err := ExecPodContainer(restConfig, namespace, pod, container, true, true, "sh", "-c", "kill 1; sleep 15; kill -9 1")
if err != nil {
return err
}
// Stream will initiate the command. We do want to wait for the result so we launch as a goroutine
go func() {
_, _, err := GetExecutorOutput(exec)
if err != nil {
log.Warnf("Kill command failed (expected to fail with 137): %v", err)
return
}
log.Infof("Kill of %s (%s) successfully issued", pod, container)
}()
return nil
}
// ExecPodContainer runs a command in a container in a pod and returns the remotecommand.Executor
func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (remotecommand.Executor, error) {
clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return nil, errors.InternalWrapError(err)
}
execRequest := clientset.CoreV1().RESTClient().Post().
Resource("pods").
Name(pod).
Namespace(namespace).
SubResource("exec").
Param("container", container).
Param("stdout", fmt.Sprintf("%v", stdout)).
Param("stderr", fmt.Sprintf("%v", stderr)).
Param("tty", "false")
for _, cmd := range command {
execRequest = execRequest.Param("command", cmd)
}
log.Info(execRequest.URL())
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", execRequest.URL())
if err != nil {
return nil, errors.InternalWrapError(err)
}
return exec, nil
}
// GetExecutorOutput returns the output of an remotecommand.Executor
func GetExecutorOutput(exec remotecommand.Executor) (string, string, error) {
var stdOut bytes.Buffer
var stdErr bytes.Buffer
err := exec.Stream(remotecommand.StreamOptions{
Stdout: &stdOut,
Stderr: &stdErr,
Tty: false,
})
if err != nil {
return "", "", errors.InternalWrapError(err)
}
return stdOut.String(), stdErr.String(), nil
}
// DefaultConfigMapName returns a formulated name for a configmap name based on the workflow-controller deployment name
func DefaultConfigMapName(controllerName string) string {
return fmt.Sprintf("%s-configmap", controllerName)
}
// ProcessArgs sets in the inputs, the values either passed via arguments, or the hardwired values
// It substitutes:
// * parameters in the template from the arguments
// * global parameters (e.g. {{workflow.parameters.XX}}, {{workflow.name}}, {{workflow.status}})
// * local parameters (e.g. {{pod.name}})
func ProcessArgs(tmpl *wfv1.Template, args wfv1.Arguments, globalParams, localParams map[string]string, validateOnly bool) (*wfv1.Template, error) {
// For each input parameter:
// 1) check if was supplied as argument. if so use the supplied value from arg
// 2) if not, use default value.
// 3) if no default value, it is an error
tmpl = tmpl.DeepCopy()
for i, inParam := range tmpl.Inputs.Parameters {
if inParam.Default != nil {
// first set to default value
inParam.Value = inParam.Default
}
// overwrite value from argument (if supplied)
argParam := args.GetParameterByName(inParam.Name)
if argParam != nil && argParam.Value != nil {
newValue := *argParam.Value
inParam.Value = &newValue
}
if inParam.Value == nil {
return nil, errors.Errorf(errors.CodeBadRequest, "inputs.parameters.%s was not supplied", inParam.Name)
}
tmpl.Inputs.Parameters[i] = inParam
}
// Performs substitutions of input artifacts
newInputArtifacts := make([]wfv1.Artifact, len(tmpl.Inputs.Artifacts))
for i, inArt := range tmpl.Inputs.Artifacts {
// if artifact has hard-wired location, we prefer that
if inArt.HasLocation() {
newInputArtifacts[i] = inArt
continue
}
// artifact must be supplied
argArt := args.GetArtifactByName(inArt.Name)
if argArt == nil {
return nil, errors.Errorf(errors.CodeBadRequest, "inputs.artifacts.%s was not supplied", inArt.Name)
}
if !argArt.HasLocation() && !validateOnly {
return nil, errors.Errorf(errors.CodeBadRequest, "inputs.artifacts.%s missing location information", inArt.Name)
}
argArt.Path = inArt.Path
argArt.Mode = inArt.Mode
newInputArtifacts[i] = *argArt
}
tmpl.Inputs.Artifacts = newInputArtifacts
return substituteParams(tmpl, globalParams, localParams)
}
// substituteParams returns a new copy of the template with global, pod, and input parameters substituted
func substituteParams(tmpl *wfv1.Template, globalParams, localParams map[string]string) (*wfv1.Template, error) {
tmplBytes, err := json.Marshal(tmpl)
if err != nil {
return nil, errors.InternalWrapError(err)
}
// First replace globals & locals, then replace inputs because globals could be referenced in the inputs
replaceMap := make(map[string]string)
for k, v := range globalParams {
replaceMap[k] = v
}
for k, v := range localParams {
replaceMap[k] = v
}
fstTmpl := fasttemplate.New(string(tmplBytes), "{{", "}}")
globalReplacedTmplStr, err := Replace(fstTmpl, replaceMap, true)
if err != nil {
return nil, err
}
var globalReplacedTmpl wfv1.Template
err = json.Unmarshal([]byte(globalReplacedTmplStr), &globalReplacedTmpl)
if err != nil {
return nil, errors.InternalWrapError(err)
}
// Now replace the rest of substitutions (the ones that can be made) in the template
replaceMap = make(map[string]string)
for _, inParam := range globalReplacedTmpl.Inputs.Parameters {
if inParam.Value == nil {
return nil, errors.InternalErrorf("inputs.parameters.%s had no value", inParam.Name)
}
replaceMap["inputs.parameters."+inParam.Name] = *inParam.Value
}
fstTmpl = fasttemplate.New(globalReplacedTmplStr, "{{", "}}")
s, err := Replace(fstTmpl, replaceMap, true)
if err != nil {
return nil, err
}
var newTmpl wfv1.Template
err = json.Unmarshal([]byte(s), &newTmpl)
if err != nil {
return nil, errors.InternalWrapError(err)
}
return &newTmpl, nil
}
// Replace executes basic string substitution of a template with replacement values.
// allowUnresolved indicates whether or not it is acceptable to have unresolved variables
// remaining in the substituted template. prefixFilter will apply the replacements only
// to variables with the specified prefix
func Replace(fstTmpl *fasttemplate.Template, replaceMap map[string]string, allowUnresolved bool) (string, error) {
var unresolvedErr error
replacedTmpl := fstTmpl.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
replacement, ok := replaceMap[tag]
if !ok {
if allowUnresolved {
// just write the same string back
return w.Write([]byte(fmt.Sprintf("{{%s}}", tag)))
}
unresolvedErr = errors.Errorf(errors.CodeBadRequest, "failed to resolve {{%s}}", tag)
return 0, nil
}
// The following escapes any special characters (e.g. newlines, tabs, etc...)
// in preparation for substitution
replacement = strconv.Quote(replacement)
replacement = replacement[1 : len(replacement)-1]
return w.Write([]byte(replacement))
})
if unresolvedErr != nil {
return "", unresolvedErr
}
return replacedTmpl, nil
}
// RunCommand is a convenience function to run/log a command and log the stderr upon failure
func RunCommand(name string, arg ...string) error {
cmd := exec.Command(name, arg...)
cmdStr := strings.Join(cmd.Args, " ")
log.Info(cmdStr)
_, err := cmd.Output()
if err != nil {
exErr := err.(*exec.ExitError)
errOutput := string(exErr.Stderr)
log.Errorf("`%s` failed: %s", cmdStr, errOutput)
return errors.InternalError(strings.TrimSpace(errOutput))
}
return nil
}
const patchRetries = 5
// AddPodAnnotation adds an annotation to pod
func AddPodAnnotation(c kubernetes.Interface, podName, namespace, key, value string) error {
return addPodMetadata(c, "annotations", podName, namespace, key, value)
}
// AddPodLabel adds an label to pod
func AddPodLabel(c kubernetes.Interface, podName, namespace, key, value string) error {
return addPodMetadata(c, "labels", podName, namespace, key, value)
}
// addPodMetadata is helper to either add a pod label or annotation to the pod
func addPodMetadata(c kubernetes.Interface, field, podName, namespace, key, value string) error {
metadata := map[string]interface{}{
"metadata": map[string]interface{}{
field: map[string]string{
key: value,
},
},
}
var err error
patch, err := json.Marshal(metadata)
if err != nil {
return errors.InternalWrapError(err)
}
for attempt := 0; attempt < patchRetries; attempt++ {
_, err = c.CoreV1().Pods(namespace).Patch(podName, types.MergePatchType, patch)
if err != nil {
if !apierr.IsConflict(err) {
return err
}
} else {
break
}
time.Sleep(100 * time.Millisecond)
}
return err
}
const workflowFieldNameFmt string = "[a-zA-Z0-9][-a-zA-Z0-9]*"
const workflowFieldNameErrMsg string = "name must consist of alpha-numeric characters or '-', and must start with an alpha-numeric character"
const workflowFieldMaxLength int = 128
var workflowFieldNameRegexp = regexp.MustCompile("^" + workflowFieldNameFmt + "$")
// IsValidWorkflowFieldName : workflow field name must consist of alpha-numeric characters or '-', and must start with an alpha-numeric character
func IsValidWorkflowFieldName(name string) []string {
var errs []string
if len(name) > workflowFieldMaxLength {
errs = append(errs, apivalidation.MaxLenError(workflowFieldMaxLength))
}
if !workflowFieldNameRegexp.MatchString(name) {
msg := workflowFieldNameErrMsg + " (e.g. My-name1-2, 123-NAME)"
errs = append(errs, msg)
}
return errs
}
// IsPodTemplate returns whether the template corresponds to a pod
func IsPodTemplate(tmpl *wfv1.Template) bool {
if tmpl.Container != nil || tmpl.Script != nil || tmpl.Resource != nil {
return true
}
return false
}
// GetTaskAncestry returns a list of taskNames which are ancestors of this task
func GetTaskAncestry(taskName string, tasks []wfv1.DAGTask) []string {
taskByName := make(map[string]wfv1.DAGTask)
for _, task := range tasks {
taskByName[task.Name] = task
}
visited := make(map[string]bool)
var getAncestry func(s string)
getAncestry = func(currTask string) {
task := taskByName[currTask]
for _, depTask := range task.Dependencies {
getAncestry(depTask)
}
if currTask != taskName {
visited[currTask] = true
}
}
getAncestry(taskName)
ancestry := make([]string, 0)
for ancestor := range visited {
ancestry = append(ancestry, ancestor)
}
return ancestry
}
var errSuspendedCompletedWorkflow = errors.Errorf(errors.CodeBadRequest, "cannot suspend completed workflows")
// IsWorkflowSuspended returns whether or not a workflow is considered suspended
func IsWorkflowSuspended(wf *wfv1.Workflow) bool {
if wf.Spec.Suspend != nil && *wf.Spec.Suspend {
return true
}
for _, node := range wf.Status.Nodes {
if node.Type == wfv1.NodeTypeSuspend && node.Phase == wfv1.NodeRunning {
return true
}
}
return false
}
// IsWorkflowCompleted returns whether or not a workflow is considered completed
func IsWorkflowCompleted(wf *wfv1.Workflow) bool {
if wf.ObjectMeta.Labels != nil {
return wf.ObjectMeta.Labels[LabelKeyCompleted] == "true"
}
return false
}
// SuspendWorkflow suspends a workflow by setting spec.suspend to true. Retries conflict errors
func SuspendWorkflow(wfIf v1alpha1.WorkflowInterface, workflowName string) error {
err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
wf, err := wfIf.Get(workflowName, metav1.GetOptions{})
if err != nil {
return false, err
}
if IsWorkflowCompleted(wf) {
return false, errSuspendedCompletedWorkflow
}
if wf.Spec.Suspend == nil || *wf.Spec.Suspend != true {
t := true
wf.Spec.Suspend = &t
wf, err = wfIf.Update(wf)
if err != nil {
if apierr.IsConflict(err) {
return false, nil
}
return false, err
}
}
return true, nil
})
if err != nil {
return err
}
return nil
}
// ResumeWorkflow resumes a workflow by setting spec.suspend to nil and any suspended nodes to Successful.
// Retries conflict errors
func ResumeWorkflow(wfIf v1alpha1.WorkflowInterface, workflowName string) error {
err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
wf, err := wfIf.Get(workflowName, metav1.GetOptions{})
if err != nil {
return false, err
}
updated := false
if wf.Spec.Suspend != nil && *wf.Spec.Suspend {
wf.Spec.Suspend = nil
updated = true
}
// To resume a workflow with a suspended node we simply mark the node as Successful
for nodeID, node := range wf.Status.Nodes {
if node.Type == wfv1.NodeTypeSuspend && node.Phase == wfv1.NodeRunning {
node.Phase = wfv1.NodeSucceeded
node.FinishedAt = metav1.Time{Time: time.Now().UTC()}
wf.Status.Nodes[nodeID] = node
updated = true
}
}
if updated {
wf, err = wfIf.Update(wf)
if err != nil {
if apierr.IsConflict(err) {
return false, nil
}
return false, err
}
}
return true, nil
})
if err != nil {
return err
}
return nil
}
const letters = "abcdefghijklmnopqrstuvwxyz0123456789"
func init() {
rand.Seed(time.Now().UnixNano())
}
func randString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
// FormulateResubmitWorkflow formulate a new workflow from a previous workflow, optionally re-using successful nodes
func FormulateResubmitWorkflow(wf *wfv1.Workflow, memoized bool) (*wfv1.Workflow, error) {
newWF := wfv1.Workflow{}
newWF.TypeMeta = wf.TypeMeta
// Resubmitted workflow will use generated names
if wf.ObjectMeta.GenerateName != "" {
newWF.ObjectMeta.GenerateName = wf.ObjectMeta.GenerateName
} else {
newWF.ObjectMeta.GenerateName = wf.ObjectMeta.Name + "-"
}
// When resubmitting workflow with memoized nodes, we need to use a predetermined workflow name
// in order to formulate the node statuses. Which means we cannot reuse metadata.generateName
// The following simulates the behavior of generateName
if memoized {
switch wf.Status.Phase {
case wfv1.NodeFailed, wfv1.NodeError:
default:
return nil, errors.Errorf(errors.CodeBadRequest, "workflow must be Failed/Error to resubmit in memoized mode")
}
newWF.ObjectMeta.Name = newWF.ObjectMeta.GenerateName + randString(5)
}
// carry over the unmodified spec
newWF.Spec = wf.Spec
// carry over user labels and annotations from previous workflow.
// skip any argoproj.io labels except for the controller instanceID label.
for key, val := range wf.ObjectMeta.Labels {
if strings.HasPrefix(key, workflow.FullName+"/") && key != LabelKeyControllerInstanceID {
continue
}
if newWF.ObjectMeta.Labels == nil {
newWF.ObjectMeta.Labels = make(map[string]string)
}
newWF.ObjectMeta.Labels[key] = val
}
for key, val := range wf.ObjectMeta.Annotations {
if newWF.ObjectMeta.Annotations == nil {
newWF.ObjectMeta.Annotations = make(map[string]string)
}
newWF.ObjectMeta.Annotations[key] = val
}
if !memoized {
return &newWF, nil
}
// Iterate the previous nodes. If it was successful Pod carry it forward
replaceRegexp := regexp.MustCompile("^" + wf.ObjectMeta.Name)
newWF.Status.Nodes = make(map[string]wfv1.NodeStatus)
onExitNodeName := wf.ObjectMeta.Name + ".onExit"
for _, node := range wf.Status.Nodes {
switch node.Phase {
case wfv1.NodeSucceeded, wfv1.NodeSkipped:
if strings.HasPrefix(node.Name, onExitNodeName) {
continue
}
originalID := node.ID
node.Name = replaceRegexp.ReplaceAllString(node.Name, newWF.ObjectMeta.Name)
node.ID = newWF.NodeID(node.Name)
node.BoundaryID = convertNodeID(&newWF, replaceRegexp, node.BoundaryID, wf.Status.Nodes)
node.StartedAt = metav1.Time{Time: time.Now().UTC()}
node.FinishedAt = node.StartedAt
newChildren := make([]string, len(node.Children))
for i, childID := range node.Children {
newChildren[i] = convertNodeID(&newWF, replaceRegexp, childID, wf.Status.Nodes)
}
node.Children = newChildren
newOutboundNodes := make([]string, len(node.OutboundNodes))
for i, outboundID := range node.OutboundNodes {
newOutboundNodes[i] = convertNodeID(&newWF, replaceRegexp, outboundID, wf.Status.Nodes)
}
node.OutboundNodes = newOutboundNodes
if node.Type == wfv1.NodeTypePod {
node.Phase = wfv1.NodeSkipped
node.Type = wfv1.NodeTypeSkipped
node.Message = fmt.Sprintf("original pod: %s", originalID)
}
newWF.Status.Nodes[node.ID] = node
case wfv1.NodeError, wfv1.NodeFailed, wfv1.NodeRunning:
// do not add this status to the node. pretend as if this node never existed.
// NOTE: NodeRunning shouldn't really happen except in weird scenarios where controller
// mismanages state (e.g. panic when operating on a workflow)
default:
return nil, errors.InternalErrorf("Workflow cannot be resubmitted with nodes in %s phase", node, node.Phase)
}
}
return &newWF, nil
}
// convertNodeID converts an old nodeID to a new nodeID
func convertNodeID(newWf *wfv1.Workflow, regex *regexp.Regexp, oldNodeID string, oldNodes map[string]wfv1.NodeStatus) string {
node := oldNodes[oldNodeID]
newNodeName := regex.ReplaceAllString(node.Name, newWf.ObjectMeta.Name)
return newWf.NodeID(newNodeName)
}
// RetryWorkflow updates a workflow, deleting all failed steps as well as the onExit node (and children)
func RetryWorkflow(kubeClient kubernetes.Interface, wfClient v1alpha1.WorkflowInterface, wf *wfv1.Workflow) (*wfv1.Workflow, error) {
switch wf.Status.Phase {
case wfv1.NodeFailed, wfv1.NodeError:
default:
return nil, errors.Errorf(errors.CodeBadRequest, "workflow must be Failed/Error to retry")
}
newWF := wf.DeepCopy()
podIf := kubeClient.CoreV1().Pods(wf.ObjectMeta.Namespace)
// Delete/reset fields which indicate workflow completed
delete(newWF.Labels, LabelKeyCompleted)
delete(newWF.Labels, LabelKeyPhase)
newWF.Status.Phase = wfv1.NodeRunning
newWF.Status.Message = ""
newWF.Status.FinishedAt = metav1.Time{}
// Iterate the previous nodes. If it was successful Pod carry it forward
newWF.Status.Nodes = make(map[string]wfv1.NodeStatus)
onExitNodeName := wf.ObjectMeta.Name + ".onExit"
for _, node := range wf.Status.Nodes {
switch node.Phase {
case wfv1.NodeSucceeded, wfv1.NodeSkipped:
if !strings.HasPrefix(node.Name, onExitNodeName) {
newWF.Status.Nodes[node.ID] = node
continue
}
case wfv1.NodeError, wfv1.NodeFailed:
// do not add this status to the node. pretend as if this node never existed.
// NOTE: NodeRunning shouldn't really happen except in weird scenarios where controller
// mismanages state (e.g. panic when operating on a workflow)
default:
return nil, errors.InternalErrorf("Workflow cannot be retried with nodes in %s phase", node, node.Phase)
}
if node.Type == wfv1.NodeTypePod {
log.Infof("Deleting pod: %s", node.ID)
err := podIf.Delete(node.ID, &metav1.DeleteOptions{})
if err != nil && !apierr.IsNotFound(err) {
return nil, errors.InternalWrapError(err)
}
}
}
newWF, err := wfClient.Update(newWF)
if err != nil {
log.Fatal(err)
}
return newWF, nil
}