Skip to content

Commit 7c64e7b

Browse files
HotsauceLeeyuzisun
andauthored
Last Deployment Status Should Reflect Deployment Status (kserve#4667)
Signed-off-by: Gavin Li <yli1109@bloomberg.net> Signed-off-by: Dan Sun <dsun20@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net>
1 parent f03e437 commit 7c64e7b

File tree

2 files changed

+233
-136
lines changed

2 files changed

+233
-136
lines changed

pkg/apis/serving/v1beta1/inference_service_status.go

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"fmt"
2021
"reflect"
2122
"strings"
2223

@@ -350,18 +351,89 @@ func (ss *InferenceServiceStatus) PropagateRawStatus(
350351
if !ok {
351352
ss.Components[component] = ComponentStatusSpec{}
352353
}
354+
readyCondition := readyConditionsMap[component]
355+
componentReadyCondition := &apis.Condition{
356+
Type: readyCondition,
357+
Status: corev1.ConditionFalse,
358+
Reason: "",
359+
}
353360

354-
condition := getDeploymentCondition(deploymentList, appsv1.DeploymentAvailable)
355-
if condition != nil && condition.Status == corev1.ConditionTrue {
361+
availableCondition := getDeploymentCondition(deploymentList, appsv1.DeploymentAvailable)
362+
if availableCondition != nil && availableCondition.Status == corev1.ConditionTrue {
363+
componentReadyCondition = &apis.Condition{
364+
Type: readyCondition,
365+
Status: corev1.ConditionTrue,
366+
Reason: availableCondition.Reason,
367+
Message: availableCondition.Message,
368+
}
369+
}
370+
fmt.Printf("availableCondition %v\n", componentReadyCondition)
371+
372+
progressingCondition := getDeploymentCondition(deploymentList, appsv1.DeploymentProgressing)
373+
if progressingCondition != nil {
374+
if progressingCondition.IsFalse() {
375+
if len(progressingCondition.Message) > 0 {
376+
// If there is a message, we assume there was a problem, often the time ProgressDeadlineExceeded
377+
componentReadyCondition = &apis.Condition{
378+
Type: readyCondition,
379+
Status: corev1.ConditionFalse,
380+
Reason: progressingCondition.Reason,
381+
Message: progressingCondition.Message,
382+
}
383+
}
384+
} else {
385+
// If progressing condition is True, and the reason is set to NewReplicaSetAvailable, override component as ready.
386+
// This is because progressing condition doesn't get set to false when deployment is complete.
387+
// See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#complete-deployment
388+
if progressingCondition.IsTrue() {
389+
if progressingCondition.Reason == "NewReplicaSetAvailable" {
390+
componentReadyCondition = &apis.Condition{
391+
Type: readyCondition,
392+
Status: corev1.ConditionTrue,
393+
Reason: progressingCondition.Reason,
394+
Message: progressingCondition.Message,
395+
}
396+
} else {
397+
componentReadyCondition = &apis.Condition{
398+
Type: readyCondition,
399+
Status: corev1.ConditionUnknown,
400+
Reason: progressingCondition.Reason,
401+
Message: progressingCondition.Message,
402+
}
403+
}
404+
}
405+
}
406+
}
407+
408+
// The availableCondition being false is a critical signal that your application is not running as expected.
409+
if availableCondition != nil && availableCondition.Status == corev1.ConditionFalse {
410+
componentReadyCondition = &apis.Condition{
411+
Type: readyCondition,
412+
Status: corev1.ConditionFalse,
413+
Reason: availableCondition.Reason,
414+
Message: availableCondition.Message,
415+
}
416+
}
417+
418+
replicaFailureCondition := getDeploymentCondition(deploymentList, appsv1.DeploymentReplicaFailure)
419+
if replicaFailureCondition != nil && replicaFailureCondition.Status == corev1.ConditionTrue {
420+
componentReadyCondition = &apis.Condition{
421+
Type: readyCondition,
422+
Status: corev1.ConditionFalse,
423+
Reason: replicaFailureCondition.Reason,
424+
Message: replicaFailureCondition.Message,
425+
}
426+
}
427+
if componentReadyCondition != nil && componentReadyCondition.Status == corev1.ConditionTrue {
356428
statusSpec.URL = url
357429
}
358-
readyCondition := readyConditionsMap[component]
359-
ss.SetCondition(readyCondition, condition)
430+
fmt.Printf("availableCondition2 %v", componentReadyCondition)
431+
432+
ss.SetCondition(readyCondition, componentReadyCondition)
360433
ss.Components[component] = statusSpec
361434
ss.ObservedGeneration = deploymentList[0].Status.ObservedGeneration
362435
}
363436

364-
//nolint:unparam
365437
func getDeploymentCondition(deploymentList []*appsv1.Deployment, conditionType appsv1.DeploymentConditionType) *apis.Condition {
366438
condition := apis.Condition{}
367439
var messages, reasons []string

0 commit comments

Comments
 (0)