Skip to content

Commit

Permalink
Merge pull request #62 from hex108/update_ready
Browse files Browse the repository at this point in the history
Update pod ready condition to true if readiness gate is updated to true
  • Loading branch information
hex108 authored Dec 11, 2020
2 parents 3d5047c + 760e926 commit 9ccd7a7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/tapp/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,17 +1189,30 @@ func setInPlaceUpdateCondition(kubeclient kubernetes.Interface, pod *corev1.Pod,
return
}

reason := "ReadinessGatesNotReady"
message := fmt.Sprintf("the status of pod readiness gate %q is not \"True\", but %v",
string(tappv1.InPlaceUpdateReady), corev1.ConditionFalse)
// If status is False, we also need to update Ready condition to False immediately
if status == corev1.ConditionFalse {
for i, c := range pod.Status.Conditions {
if c.Type == corev1.PodReady {
if c.Status != corev1.ConditionFalse {
pod.Status.Conditions[i].Status = corev1.ConditionFalse
pod.Status.Conditions[i].LastTransitionTime = metav1.Now()
pod.Status.Conditions[i].Reason = "ReadinessGatesNotReady"
pod.Status.Conditions[i].Message =
fmt.Sprintf("the status of pod readiness gate %q is not \"True\", but %v",
string(tappv1.InPlaceUpdateReady), corev1.ConditionFalse)
pod.Status.Conditions[i].Reason = reason
pod.Status.Conditions[i].Message = message
}
break
}
}
} else {
for i, c := range pod.Status.Conditions {
if c.Type == corev1.PodReady {
if c.Status == corev1.ConditionFalse && c.Reason == reason && c.Message == message {
pod.Status.Conditions[i].Status = corev1.ConditionTrue
pod.Status.Conditions[i].LastTransitionTime = metav1.Now()
pod.Status.Conditions[i].Reason = ""
pod.Status.Conditions[i].Message = ""
}
break
}
Expand Down

0 comments on commit 9ccd7a7

Please # to comment.