Skip to content

Commit

Permalink
chore: wait to create pod rather than exit with Failed status when po…
Browse files Browse the repository at this point in the history
…d scheduling is blocked during instance rebuilding. (apecloud#7361)
  • Loading branch information
wangyelei authored May 16, 2024
1 parent 5a4a1ae commit df81dff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion controllers/apps/operations/rebuild_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ func (r rebuildInstanceOpsHandler) instanceIsAvailable(
if !targetPod.DeletionTimestamp.IsZero() {
return false, nil
}
isFailed, isTimeout, _ := intctrlutil.IsPodFailedAndTimedOut(targetPod)
isFailed, isTimeout, _ := intctrlutil.IsPodFailedAndTimedOut(targetPod, true)
if isFailed && isTimeout {
return false, intctrlutil.NewFatalError(fmt.Sprintf(`the new instance "%s" is failed, please check it`, targetPod.Name))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/instanceset/reconciler_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func buildFailureCondition(its *workloads.InstanceSet, pods []*corev1.Pod) (*met
continue
}
// KubeBlocks says the Pod is 'Failed'
isFailed, isTimedOut, _ := intctrlutil.IsPodFailedAndTimedOut(pod)
isFailed, isTimedOut, _ := intctrlutil.IsPodFailedAndTimedOut(pod, false)
if isFailed && isTimedOut {
failureNames = append(failureNames, pod.Name)
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/controllerutil/pod_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,11 @@ func GetPodContainer(pod *corev1.Pod, containerName string) *corev1.Container {
}

// IsPodFailedAndTimedOut checks if the pod is failed and timed out.
func IsPodFailedAndTimedOut(pod *corev1.Pod) (bool, bool, string) {
if isFailed, isTimedOut, message := isPodScheduledFailedAndTimedOut(pod); isFailed {
return isFailed, isTimedOut, message
func IsPodFailedAndTimedOut(pod *corev1.Pod, ignoreScheduledCheck bool) (bool, bool, string) {
if !ignoreScheduledCheck {
if isFailed, isTimedOut, message := isPodScheduledFailedAndTimedOut(pod); isFailed {
return isFailed, isTimedOut, message
}
}
initContainerFailed, message := isAnyContainerFailed(pod.Status.InitContainerStatuses)
if initContainerFailed {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dataprotection/action/action_stateful.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ func (s *StatefulSetAction) stsIsFailed(ctx ActionContext) bool {
Namespace: s.ObjectMeta.Namespace}, pod); err != nil {
return false
}
isFailed, isTimeout, _ := intctrlutil.IsPodFailedAndTimedOut(pod)
isFailed, isTimeout, _ := intctrlutil.IsPodFailedAndTimedOut(pod, false)
return isFailed && isTimeout
}

0 comments on commit df81dff

Please sign in to comment.