Skip to content

Commit

Permalink
fix: overall last transition time not correct (#1416)
Browse files Browse the repository at this point in the history
Co-authored-by: zhujian <zhujian@caicloud.io>
  • Loading branch information
caicloud-bot and zhujian7 committed Apr 21, 2020
1 parent 3aabd02 commit a006e56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/server/handler/init.go
Expand Up @@ -2,9 +2,11 @@ package handler

import (
"encoding/json"
"time"

"github.com/caicloud/cyclone/pkg/apis/cyclone/v1alpha1"
"github.com/caicloud/cyclone/pkg/k8s/clientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
Expand Down Expand Up @@ -51,8 +53,11 @@ type JSONPatch struct {

// BuildWfrStatusPatch builds patch for updating status of workflowrun
func BuildWfrStatusPatch(statusPhase v1alpha1.StatusPhase) ([]byte, error) {
now := metav1.Time{Time: time.Now()}

p := map[string]string{
"/status/overall/phase": string(statusPhase),
"/status/overall/phase": string(statusPhase),
"/status/overall/lastTransitionTime": now.UTC().Format(time.RFC3339),
}
return BuildPatch(p)
}
4 changes: 4 additions & 0 deletions pkg/workflow/workflowrun/operator.go
Expand Up @@ -184,6 +184,10 @@ func (o *operator) Update() error {

if !reflect.DeepEqual(staticStatus(&latest.Status), staticStatus(&combined.Status)) ||
len(latest.OwnerReferences) != len(combined.OwnerReferences) {

// If status has any change, the overall last transition time need to update
combined.Status.Overall.LastTransitionTime = metav1.Time{Time: time.Now()}

_, err = o.client.CycloneV1alpha1().WorkflowRuns(latest.Namespace).Update(combined)
if err == nil {
log.WithField("wfr", latest.Name).
Expand Down

0 comments on commit a006e56

Please sign in to comment.