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

Fix TaskCompleted may transition to TaskAttemptCompleted #10

Merged
merged 1 commit into from
Feb 14, 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
16 changes: 11 additions & 5 deletions pkg/apis/frameworkcontroller/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,17 @@ const (
FrameworkAttemptDeleting FrameworkState = "AttemptDeleting"

// ConfigMap does not exist and
// has been creation requested and is not expected to exist.
// has been creation requested and is not expected to exist and
// current attempt is not the last attempt or to be determined.
// [AttemptFinalState]
// [AssociatedState]
// -> FrameworkAttemptCreationPending
// -> FrameworkCompleted
FrameworkAttemptCompleted FrameworkState = "AttemptCompleted"

// Last FrameworkAttempt is completed.
// ConfigMap does not exist and
// has been creation requested and is not expected to exist and
// current attempt is the last attempt.
// [FinalState]
// [AssociatedState]
FrameworkCompleted FrameworkState = "Completed"
Expand Down Expand Up @@ -480,8 +483,8 @@ const (
// has not been deletion requested and
// is PodPending or PodUnknown afterwards.
// [AssociatedState]
// -> TaskAttemptDeletionPending
// -> TaskAttemptRunning
// -> TaskAttemptDeletionPending
// -> TaskAttemptDeleting
// -> TaskAttemptCompleted
TaskAttemptPreparing TaskState = "AttemptPreparing"
Expand Down Expand Up @@ -517,14 +520,17 @@ const (
TaskAttemptDeleting TaskState = "AttemptDeleting"

// Pod does not exist and
// has been creation requested and is not expected to exist.
// has been creation requested and is not expected to exist and
// current attempt is not the last attempt or to be determined.
// [AttemptFinalState]
// [AssociatedState]
// -> TaskAttemptCreationPending
// -> TaskCompleted
TaskAttemptCompleted TaskState = "AttemptCompleted"

// Last TaskAttempt is completed.
// Pod does not exist and
// has been creation requested and is not expected to exist and
// current attempt is the last attempt.
// [FinalState]
// [AssociatedState]
TaskCompleted TaskState = "Completed"
Expand Down
15 changes: 12 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,17 @@ func (c *FrameworkController) syncTaskState(
taskRoleStatus := f.TaskRoleStatus(taskRoleName)
taskStatus := f.TaskStatus(taskRoleName, taskIndex)

if taskStatus.State == ci.TaskCompleted {
// The TaskCompleted should not trigger FrameworkAttemptDeletionPending, so
// it is safe to skip the attemptToCompleteFrameworkAttempt.
// Otherwise, given it is impossible that the TaskCompleted is persisted
// but the FrameworkAttemptDeletionPending is not persisted, the TaskCompleted
// should have already triggered and persisted FrameworkAttemptDeletionPending
// in previous sync, so current sync should have already been skipped but not.
log.Infof(logPfx + "Skipped: Task is already completed")
return false, nil
}

// Get the ground truth readonly pod
pod, err := c.getOrCleanupPod(f, cm, taskRoleName, taskIndex)
if err != nil {
Expand Down Expand Up @@ -1156,7 +1167,7 @@ func (c *FrameworkController) syncTaskState(
}
}
// At this point, taskStatus.State must be in:
// {TaskCompleted, TaskAttemptCreationPending, TaskAttemptCompleted}
// {TaskAttemptCreationPending, TaskAttemptCompleted}

if taskStatus.State == ci.TaskAttemptCompleted {
// attemptToRetryTask
Expand Down Expand Up @@ -1207,8 +1218,6 @@ func (c *FrameworkController) syncTaskState(
// At this point, taskStatus.State must be in:
// {TaskCompleted, TaskAttemptCreationPending}

// Totally reconstruct actions triggered by TaskCompleted in case these actions
// are missed due to FrameworkController restart.
if taskStatus.State == ci.TaskCompleted {
// attemptToCompleteFrameworkAttempt
completionPolicy := taskRoleSpec.FrameworkAttemptCompletionPolicy
Expand Down