Skip to content

Commit

Permalink
fix: make sure the time duration is positive (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <[email protected]>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Mar 16, 2023
1 parent f8ded59 commit 6d177b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/argoworkflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/linuxsuren/gogit/argoworkflow/template"
"github.com/linuxsuren/gogit/pkg"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"

Expand Down Expand Up @@ -146,7 +147,7 @@ func (e *DefaultPluginExecutor) Execute(args executor.ExecuteTemplateArgs, wf *w
}

fmt.Println("send status", repo)
wait.PollImmediate(time.Second*2, time.Second*30, func() (bool, error) {
wait.PollImmediate(time.Second, time.Second*10, func() (bool, error) {
err := pkg.CreateStatus(ctx, repo)
return err == nil, nil
})
Expand All @@ -168,6 +169,11 @@ func (e *DefaultPluginExecutor) Execute(args executor.ExecuteTemplateArgs, wf *w
if strings.HasSuffix(val.Name, ".onExit") || strings.Contains(val.Name, ".hooks.") {
toRemoves = append(toRemoves, key)
}

if val.FinishedAt.IsZero() {
val.FinishedAt = metav1.Now()
wf.Status.Nodes[key] = val
}
}
// remove useless nodes
delete(wf.Status.Nodes, wf.Name)
Expand All @@ -193,6 +199,10 @@ func (e *DefaultPluginExecutor) Execute(args executor.ExecuteTemplateArgs, wf *w
wf.Spec.WorkflowTemplateRef.Name)
wf.Annotations["workflow.link"] = targetAddress
wf.Annotations["workflow.templatelink"] = targetTemplateAddress
if wf.Status.FinishedAt.IsZero() {
// make sure the duration is positive
wf.Status.FinishedAt = metav1.Now()
}

deleteRetryNodes(wf)

Expand Down Expand Up @@ -284,7 +294,6 @@ func plugin(p PluginExecutor, client *wfclientset.Clientset) func(w http.Respons
}

go func(c *wfclientset.Clientset, args executor.ExecuteTemplateArgs) {
time.Sleep(3 * time.Second)
wfName := args.Workflow.ObjectMeta.Name
wfNamespace := args.Workflow.ObjectMeta.Namespace

Expand Down

0 comments on commit 6d177b2

Please sign in to comment.