in pkg/controller/controller.go [2226:2291]
func (c *FrameworkController) completeFrameworkAttempt(
f *ci.Framework, force bool, completionStatus *ci.FrameworkAttemptCompletionStatus) {
logPfx := fmt.Sprintf(
"[%v]: completeFrameworkAttempt: force: %v: ",
f.Key(), force)
// CompletionStatus should be immutable after set.
if f.Status.AttemptStatus.CompletionStatus == nil {
f.Status.AttemptStatus.CompletionStatus = completionStatus
}
for _, taskRoleStatus := range f.TaskRoleStatuses() {
for _, taskStatus := range taskRoleStatus.TaskStatuses {
if taskStatus.AttemptStatus.CompletionStatus == nil {
taskStatus.AttemptStatus.CompletionStatus =
ci.CompletionCodeFrameworkAttemptCompletion.
NewTaskAttemptCompletionStatus(
"Stop to complete current FrameworkAttempt", nil)
}
}
}
if force {
for _, taskRoleStatus := range f.TaskRoleStatuses() {
taskRoleName := taskRoleStatus.Name
for _, taskStatus := range taskRoleStatus.TaskStatuses {
taskIndex := taskStatus.Index
if taskStatus.State != ci.TaskCompleted {
if taskStatus.State != ci.TaskAttemptCompleted {
c.completeTaskAttempt(f, taskRoleName, taskIndex, true, nil)
}
taskStatus.RetryPolicyStatus.RetryDelaySec = nil
f.TransitionTaskState(taskRoleName, taskIndex, ci.TaskCompleted)
}
}
}
f.TransitionFrameworkState(ci.FrameworkAttemptCompleted)
if f.FrameworkAttemptInstanceUID() == nil {
klog.Infof(logPfx+
"FrameworkAttempt %v is completed with CompletionStatus: %v",
f.FrameworkAttemptID(),
common.ToJson(f.Status.AttemptStatus.CompletionStatus))
} else {
klog.Infof(logPfx+
"FrameworkAttemptInstance %v is completed with CompletionStatus: %v",
*f.FrameworkAttemptInstanceUID(),
common.ToJson(f.Status.AttemptStatus.CompletionStatus))
}
// To ensure FrameworkAttemptCompleted is persisted before exposed its
// FrameworkAttempt, we need to wait until next sync to expose the
// FrameworkAttempt, so manually enqueue a sync.
c.enqueueFrameworkSync(f, "FrameworkAttemptCompleted")
klog.Infof(logPfx + "Waiting FrameworkAttemptCompleted to be persisted")
} else {
f.TransitionFrameworkState(ci.FrameworkAttemptDeletionPending)
// To ensure FrameworkAttemptDeletionPending is persisted before deleting
// its cm, we need to wait until next sync to delete the cm, so manually
// enqueue a sync.
c.enqueueFrameworkSync(f, "FrameworkAttemptDeletionPending")
klog.Infof(logPfx + "Waiting FrameworkAttemptDeletionPending to be persisted")
}
}