Skip to content

Commit 1af529c

Browse files
committed
Put target health description into pod condition message
1 parent 355dde7 commit 1af529c

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

docs/guide/ingress/pod-conditions.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ nginx-test-5744b9ff84-7ftl9 1/1 Running 0 81s 10.1.2.3 ip-1
9191
If a readiness gate doesn't get ready, you can check the reason via:
9292

9393
```console
94-
$ kubectl get nginx-test-5744b9ff84-7ftl9 pod -o yaml | grep -B4 'type: target-health'
94+
$ kubectl get pod nginx-test-5744b9ff84-7ftl9 -o yaml | grep -B5 'type: target-health'
9595
- lastProbeTime: "2020-02-28T10:05:08Z"
9696
lastTransitionTime: "2020-02-28T10:05:08Z"
97-
reason: "Elb.RegistrationInProgress: Target registration is in progress."
97+
message: Target registration is in progress.
98+
reason: Elb.RegistrationInProgress
9899
status: "False"
99100
type: target-health.alb.ingress.kubernetes.io/nginx-test_nginx-test_80
100101
```

internal/alb/tg/targethealth.go

+6-14
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ func (c *targetHealthController) reconcilePodCondition(ctx context.Context, cond
218218
if cond == nil {
219219
// new condition
220220
targetHealthCondition := api.PodCondition{
221-
Type: conditionType,
222-
Status: conditionStatus,
223-
Reason: podConditionReason(targetHealth),
221+
Type: conditionType,
222+
Status: conditionStatus,
223+
Reason: aws.StringValue(targetHealth.Reason),
224+
Message: aws.StringValue(targetHealth.Description),
224225
}
225226
if updateTimes {
226227
targetHealthCondition.LastProbeTime = now
@@ -236,7 +237,8 @@ func (c *targetHealthController) reconcilePodCondition(ctx context.Context, cond
236237
}
237238
}
238239
cond.Status = conditionStatus
239-
cond.Reason = podConditionReason(targetHealth)
240+
cond.Reason = aws.StringValue(targetHealth.Reason)
241+
cond.Message = aws.StringValue(targetHealth.Description)
240242
pod.Status.Conditions[i] = *cond
241243
}
242244

@@ -316,16 +318,6 @@ func podHasReadinessGate(pod *api.Pod, conditionType api.PodConditionType) bool
316318
return false
317319
}
318320

319-
func podConditionReason(targetHealth *elbv2.TargetHealth) string {
320-
if targetHealth.Reason != nil {
321-
if targetHealth.Description != nil {
322-
return fmt.Sprintf("%s: %s", aws.StringValue(targetHealth.Reason), aws.StringValue(targetHealth.Description))
323-
}
324-
return aws.StringValue(targetHealth.Reason)
325-
}
326-
return ""
327-
}
328-
329321
func podConditionForReadinessGate(pod *api.Pod, conditionType api.PodConditionType) (int, *api.PodCondition) {
330322
for i, condition := range pod.Status.Conditions {
331323
if condition.Type == conditionType {

0 commit comments

Comments
 (0)