diff --git a/pkg/apis/frameworkcontroller/v1/funcs.go b/pkg/apis/frameworkcontroller/v1/funcs.go index b456083e..ba7e779a 100644 --- a/pkg/apis/frameworkcontroller/v1/funcs.go +++ b/pkg/apis/frameworkcontroller/v1/funcs.go @@ -443,6 +443,7 @@ func (f *Framework) NewFrameworkAttemptStatus( return FrameworkAttemptStatus{ ID: frameworkAttemptID, StartTime: meta.Now(), + RunTime: nil, CompletionTime: nil, InstanceUID: nil, ConfigMapName: GetConfigMapName(f.Name), @@ -485,6 +486,7 @@ func (f *Framework) NewTaskAttemptStatus( return TaskAttemptStatus{ ID: taskAttemptID, StartTime: meta.Now(), + RunTime: nil, CompletionTime: nil, InstanceUID: nil, PodName: GetPodName(f.Name, taskRoleName, taskIndex), @@ -594,8 +596,19 @@ func (f *Framework) TransitionFrameworkState(dstState FrameworkState) { return } + now := common.PtrNow() + if dstState == FrameworkAttemptRunning { + f.Status.AttemptStatus.RunTime = now + } + if dstState == FrameworkAttemptCompleted { + f.Status.AttemptStatus.CompletionTime = now + } + if dstState == FrameworkCompleted { + f.Status.CompletionTime = now + } + f.Status.State = dstState - f.Status.TransitionTime = meta.Now() + f.Status.TransitionTime = *now klog.Infof( "[%v]: Transitioned Framework from [%v] to [%v]", @@ -611,8 +624,19 @@ func (f *Framework) TransitionTaskState( return } + now := common.PtrNow() + if dstState == TaskAttemptRunning { + taskStatus.AttemptStatus.RunTime = now + } + if dstState == TaskAttemptCompleted { + taskStatus.AttemptStatus.CompletionTime = now + } + if dstState == TaskCompleted { + taskStatus.CompletionTime = now + } + taskStatus.State = dstState - taskStatus.TransitionTime = meta.Now() + taskStatus.TransitionTime = *now klog.Infof( "[%v][%v][%v]: Transitioned Task from [%v] to [%v]", diff --git a/pkg/apis/frameworkcontroller/v1/types.go b/pkg/apis/frameworkcontroller/v1/types.go index 06fd92be..6d83664f 100644 --- a/pkg/apis/frameworkcontroller/v1/types.go +++ b/pkg/apis/frameworkcontroller/v1/types.go @@ -256,6 +256,7 @@ type FrameworkAttemptStatus struct { ID int32 `json:"id"` StartTime meta.Time `json:"startTime"` + RunTime *meta.Time `json:"runTime"` CompletionTime *meta.Time `json:"completionTime"` // Current associated FrameworkAttemptInstance: @@ -301,6 +302,7 @@ type TaskAttemptStatus struct { ID int32 `json:"id"` StartTime meta.Time `json:"startTime"` + RunTime *meta.Time `json:"runTime"` CompletionTime *meta.Time `json:"completionTime"` // Current associated TaskAttemptInstance: @@ -433,7 +435,7 @@ const ( // ConfigMap exists and is not deleting and // may not have been deletion requested successfully and // FrameworkAttemptCompletionPolicy may not have been satisfied and - // there is no Task in TaskAttemptRunning state. + // no Task of current attempt has ever entered TaskAttemptRunning state. // [AssociatedState] // -> FrameworkAttemptRunning // -> FrameworkAttemptDeletionPending @@ -444,9 +446,8 @@ const ( // ConfigMap exists and is not deleting and // may not have been deletion requested successfully and // FrameworkAttemptCompletionPolicy may not have been satisfied and - // there is at least one Task in TaskAttemptRunning state. + // at least one Task of current attempt has ever entered TaskAttemptRunning state. // [AssociatedState] - // -> FrameworkAttemptPreparing // -> FrameworkAttemptDeletionPending // -> FrameworkAttemptDeleting // -> FrameworkAttemptCompleted diff --git a/pkg/apis/frameworkcontroller/v1/zz_generated.deepcopy.go b/pkg/apis/frameworkcontroller/v1/zz_generated.deepcopy.go index a9c578ab..2129c590 100644 --- a/pkg/apis/frameworkcontroller/v1/zz_generated.deepcopy.go +++ b/pkg/apis/frameworkcontroller/v1/zz_generated.deepcopy.go @@ -139,6 +139,7 @@ func (in *Config) DeepCopyInto(out *Config) { *out = new(int64) **out = **in } + in.LogObjectSnapshot.DeepCopyInto(&out.LogObjectSnapshot) return } @@ -188,6 +189,10 @@ func (in *Framework) DeepCopyObject() runtime.Object { func (in *FrameworkAttemptStatus) DeepCopyInto(out *FrameworkAttemptStatus) { *out = *in in.StartTime.DeepCopyInto(&out.StartTime) + if in.RunTime != nil { + in, out := &in.RunTime, &out.RunTime + *out = (*in).DeepCopy() + } if in.CompletionTime != nil { in, out := &in.CompletionTime, &out.CompletionTime *out = (*in).DeepCopy() @@ -316,6 +321,76 @@ func (in *FrameworkStatus) DeepCopy() *FrameworkStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogFrameworkSnapshot) DeepCopyInto(out *LogFrameworkSnapshot) { + *out = *in + if in.OnTaskRetry != nil { + in, out := &in.OnTaskRetry, &out.OnTaskRetry + *out = new(bool) + **out = **in + } + if in.OnFrameworkRetry != nil { + in, out := &in.OnFrameworkRetry, &out.OnFrameworkRetry + *out = new(bool) + **out = **in + } + if in.OnFrameworkDeletion != nil { + in, out := &in.OnFrameworkDeletion, &out.OnFrameworkDeletion + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogFrameworkSnapshot. +func (in *LogFrameworkSnapshot) DeepCopy() *LogFrameworkSnapshot { + if in == nil { + return nil + } + out := new(LogFrameworkSnapshot) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogObjectSnapshot) DeepCopyInto(out *LogObjectSnapshot) { + *out = *in + in.Framework.DeepCopyInto(&out.Framework) + in.Pod.DeepCopyInto(&out.Pod) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogObjectSnapshot. +func (in *LogObjectSnapshot) DeepCopy() *LogObjectSnapshot { + if in == nil { + return nil + } + out := new(LogObjectSnapshot) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LogPodSnapshot) DeepCopyInto(out *LogPodSnapshot) { + *out = *in + if in.OnPodDeletion != nil { + in, out := &in.OnPodDeletion, &out.OnPodDeletion + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogPodSnapshot. +func (in *LogPodSnapshot) DeepCopy() *LogPodSnapshot { + if in == nil { + return nil + } + out := new(LogPodSnapshot) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RetryDecision) DeepCopyInto(out *RetryDecision) { *out = *in @@ -373,6 +448,10 @@ func (in *RetryPolicyStatus) DeepCopy() *RetryPolicyStatus { func (in *TaskAttemptStatus) DeepCopyInto(out *TaskAttemptStatus) { *out = *in in.StartTime.DeepCopyInto(&out.StartTime) + if in.RunTime != nil { + in, out := &in.RunTime, &out.RunTime + *out = (*in).DeepCopy() + } if in.CompletionTime != nil { in, out := &in.CompletionTime, &out.CompletionTime *out = (*in).DeepCopy() diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 7bf5402c..2e93370d 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -848,7 +848,6 @@ func (c *FrameworkController) syncFrameworkState(f *ci.Framework) (err error) { "Will complete Framework: RetryDecision: %v", retryDecision) - f.Status.CompletionTime = common.PtrNow() f.TransitionFrameworkState(ci.FrameworkCompleted) return nil } @@ -951,11 +950,8 @@ func (c *FrameworkController) syncFrameworkState(f *ci.Framework) (err error) { err := c.syncTaskRoleStatuses(f, cm) - if f.Status.State == ci.FrameworkAttemptPreparing || - f.Status.State == ci.FrameworkAttemptRunning { - if !f.IsAnyTaskRunning() { - f.TransitionFrameworkState(ci.FrameworkAttemptPreparing) - } else { + if f.Status.State == ci.FrameworkAttemptPreparing { + if f.IsAnyTaskRunning() { f.TransitionFrameworkState(ci.FrameworkAttemptRunning) } } @@ -1339,7 +1335,6 @@ func (c *FrameworkController) syncTaskState( "Will complete Task: RetryDecision: %v", retryDecision) - taskStatus.CompletionTime = common.PtrNow() f.TransitionTaskState(taskRoleName, taskIndex, ci.TaskCompleted) } } @@ -1635,7 +1630,6 @@ func (c *FrameworkController) completeTaskAttempt( } if force { - taskStatus.AttemptStatus.CompletionTime = common.PtrNow() f.TransitionTaskState(taskRoleName, taskIndex, ci.TaskAttemptCompleted) if taskStatus.TaskAttemptInstanceUID() == nil { @@ -1693,13 +1687,11 @@ func (c *FrameworkController) completeFrameworkAttempt( if taskStatus.State != ci.TaskAttemptCompleted { c.completeTaskAttempt(f, taskRoleName, taskIndex, true, nil) } - taskStatus.CompletionTime = common.PtrNow() f.TransitionTaskState(taskRoleName, taskIndex, ci.TaskCompleted) } } } - f.Status.AttemptStatus.CompletionTime = common.PtrNow() f.TransitionFrameworkState(ci.FrameworkAttemptCompleted) if f.FrameworkAttemptInstanceUID() == nil {