Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Redefine FrameworkAttemptRunning and Record attempt running start time #35

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions pkg/apis/frameworkcontroller/v1/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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]",
Expand All @@ -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]",
Expand Down
7 changes: 4 additions & 3 deletions pkg/apis/frameworkcontroller/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
79 changes: 79 additions & 0 deletions pkg/apis/frameworkcontroller/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -1339,7 +1335,6 @@ func (c *FrameworkController) syncTaskState(
"Will complete Task: RetryDecision: %v",
retryDecision)

taskStatus.CompletionTime = common.PtrNow()
f.TransitionTaskState(taskRoleName, taskIndex, ci.TaskCompleted)
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down