Skip to content

Commit 08653f9

Browse files
author
Doyoon Kim
committed
Address initial set of PR comments
1 parent 5e73ab1 commit 08653f9

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

pkg/deploy/lattice/targets_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *defaultTargetsManager) Update(ctx context.Context, modelTargets *model.
6767
}
6868
staleTargets := s.findStaleTargets(modelTargets, latticeTargets)
6969

70-
err1 := s.deregisterStaleTargets(ctx, modelTg, staleTargets)
70+
err1 := s.deregisterTargets(ctx, modelTg, staleTargets)
7171
err2 := s.registerTargets(ctx, modelTg, modelTargets.Spec.TargetList)
7272
return errors.Join(err1, err2)
7373
}
@@ -131,7 +131,7 @@ func (s *defaultTargetsManager) registerTargets(
131131
return registerTargetsError
132132
}
133133

134-
func (s *defaultTargetsManager) deregisterStaleTargets(
134+
func (s *defaultTargetsManager) deregisterTargets(
135135
ctx context.Context,
136136
modelTg *model.TargetGroup,
137137
targets []model.Target,

pkg/deploy/lattice/targets_synthesizer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
ReadinessReasonHealthy = "Healthy"
2222
ReadinessReasonUnhealthy = "Unhealthy"
2323
ReadinessReasonUnused = "Unused"
24+
ReadinessReasonInitial = "Initial"
2425
ReadinessReasonHealthCheckUnavailable = "HealthCheckUnavailable"
2526
ReadinessReasonTargetNotFound = "TargetNotFound"
2627
)
@@ -134,7 +135,8 @@ func (t *targetsSynthesizer) syncStatus(ctx context.Context, modelTargets []mode
134135
continue
135136
}
136137

137-
// Step 2: Check if the pod readiness condition is owned by controller.
138+
// Step 2: Check if the pod readiness condition exists with specific condition type.
139+
// The condition is considered false when it does not exist.
138140
cond := utils.FindPodStatusCondition(pod.Status.Conditions, LatticeReadinessGateConditionType)
139141
if cond != nil && cond.Status == corev1.ConditionTrue {
140142
continue
@@ -162,8 +164,12 @@ func (t *targetsSynthesizer) syncStatus(ctx context.Context, modelTargets []mode
162164
newCond.Status = corev1.ConditionTrue
163165
newCond.Reason = ReadinessReasonHealthCheckUnavailable
164166
case vpclattice.TargetStatusUnused:
165-
// For ServiceExport TGs, we do not have to evaluate them as Healthy, but we also do not have to requeue.
167+
// Since this logic is called after HTTPRoute is wired, this only happens for ServiceExport TGs.
168+
// In this case we do not have to evaluate them as Healthy, but we also do not have to requeue.
166169
newCond.Reason = ReadinessReasonUnused
170+
case vpclattice.TargetStatusInitial:
171+
requeue = true
172+
newCond.Reason = ReadinessReasonInitial
167173
default:
168174
requeue = true
169175
newCond.Reason = ReadinessReasonUnhealthy

pkg/deploy/lattice/targets_synthesizer_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,20 @@ func Test_PostSynthesize_Conditions(t *testing.T) {
150150
requeue: false,
151151
},
152152
{
153-
name: "Unhealthy targets do not make pod ready",
153+
name: "Initial targets do not make pod ready",
154154
model: target,
155155
lattice: newLatticeTarget("10.10.1.1", 8675, vpclattice.TargetStatusInitial),
156156
pod: newPod("ns", "pod1", true, false),
157157
expectedStatus: corev1.ConditionFalse,
158+
expectedReason: ReadinessReasonInitial,
159+
requeue: true,
160+
},
161+
{
162+
name: "Unhealthy targets do not make pod ready",
163+
model: target,
164+
lattice: newLatticeTarget("10.10.1.1", 8675, vpclattice.TargetStatusUnhealthy),
165+
pod: newPod("ns", "pod1", true, false),
166+
expectedStatus: corev1.ConditionFalse,
158167
expectedReason: ReadinessReasonUnhealthy,
159168
requeue: true,
160169
},

pkg/utils/pod_condition.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func PodHasReadinessGate(pod *corev1.Pod, conditionType corev1.PodConditionType)
1818
return false
1919
}
2020

21+
// Copied from: k8s.io/apimachinery/pkg/apis/meta
2122
func FindPodStatusCondition(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) *corev1.PodCondition {
2223
for i := range conditions {
2324
if conditions[i].Type == conditionType {
@@ -27,6 +28,7 @@ func FindPodStatusCondition(conditions []corev1.PodCondition, conditionType core
2728
return nil
2829
}
2930

31+
// Copied from: k8s.io/apimachinery/pkg/apis/meta
3032
func SetPodStatusCondition(conditions *[]corev1.PodCondition, newCondition corev1.PodCondition) {
3133
if conditions == nil {
3234
return

0 commit comments

Comments
 (0)