/
condition_application_not_healthy.go
47 lines (38 loc) · 1.47 KB
/
condition_application_not_healthy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package conditions
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ApplicationNotHealthyCondition struct {
condition
}
var _ Condition = &ApplicationNotHealthyCondition{}
func NewApplicationNotHealthyCondition() *ApplicationNotHealthyCondition {
this := &ApplicationNotHealthyCondition{}
this.SetType(CONDITION_TYPE_APPLICATION_NOT_HEALTHY)
this.Reset()
return this
}
func (this *ApplicationNotHealthyCondition) IsActive() bool {
return this.data.Status == metav1.ConditionTrue
}
// Transitions in decreasing order of priority
func (this *ApplicationNotHealthyCondition) TransitionNotReady() {
this.data.Status = metav1.ConditionTrue
this.data.Reason = string(APPLICATION_NOT_HEALTHY_REASON_READINESS)
this.data.Message = "Readiness probe is failing. Please check application logs."
}
func (this *ApplicationNotHealthyCondition) TransitionNotLive() {
if this.data.Reason != string(APPLICATION_NOT_HEALTHY_REASON_READINESS) {
this.data.Status = metav1.ConditionTrue
this.data.Reason = string(APPLICATION_NOT_HEALTHY_REASON_LIVENESS)
this.data.Message = "Liveness probe is failing. Please check application logs."
}
}
func (this *ApplicationNotHealthyCondition) TransitionHealthy() {
if this.data.Reason != string(APPLICATION_NOT_HEALTHY_REASON_READINESS) &&
this.data.Reason != string(APPLICATION_NOT_HEALTHY_REASON_LIVENESS) {
this.data.Status = metav1.ConditionFalse
this.data.Reason = "" // The condition will be inactive
this.data.Message = ""
}
}