Skip to content

Commit 066d132

Browse files
authored
Merge pull request #4383 from shuqz/shuqz-grpcroute
[feat gw-api]update gateway status based on observation generation
2 parents 0eb4a91 + 2bd1683 commit 066d132

File tree

3 files changed

+141
-44
lines changed

3 files changed

+141
-44
lines changed

controllers/gateway/gateway_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ func (r *gatewayReconciler) updateGatewayStatusFailure(ctx context.Context, gw *
440440
gw.Status.Listeners = ListenerStatuses
441441
needPatch = true
442442
}
443+
gwProgrammedNeedPatch := r.gatewayConditionUpdater(gw, string(gwv1.GatewayConditionProgrammed), metav1.ConditionFalse, string(gwv1.GatewayConditionProgrammed), errMessage)
444+
needPatch = needPatch || gwProgrammedNeedPatch
443445
}
444446

445447
if needPatch {

controllers/gateway/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ func updateGatewayClassAcceptedCondition(ctx context.Context, k8sClient client.C
7979
storedStatus := gwClass.Status.Conditions[indxToUpdate].Status
8080
storedMessage := gwClass.Status.Conditions[indxToUpdate].Message
8181
storedReason := gwClass.Status.Conditions[indxToUpdate].Reason
82+
storedObservedGeneration := gwClass.Status.Conditions[indxToUpdate].ObservedGeneration
8283

83-
if storedStatus == newStatus && storedMessage == message && storedReason == reason {
84+
if storedStatus == newStatus && storedMessage == message && storedReason == reason && storedObservedGeneration == gwClass.Generation {
8485
return nil
8586
}
8687

@@ -99,7 +100,6 @@ func updateGatewayClassAcceptedCondition(ctx context.Context, k8sClient client.C
99100

100101
// prepareGatewayConditionUpdate inserts the necessary data into the condition field of the gateway. The caller should patch the corresponding gateway. Returns false when no change was performed.
101102
func prepareGatewayConditionUpdate(gw *gwv1.Gateway, targetConditionType string, newStatus metav1.ConditionStatus, reason string, message string) bool {
102-
103103
indxToUpdate := -1
104104
var derivedCondition metav1.Condition
105105
for i, condition := range gw.Status.Conditions {
@@ -114,7 +114,7 @@ func prepareGatewayConditionUpdate(gw *gwv1.Gateway, targetConditionType string,
114114
truncatedMessage := truncateMessage(message)
115115

116116
if indxToUpdate != -1 {
117-
if derivedCondition.Status != newStatus || derivedCondition.Message != truncatedMessage || derivedCondition.Reason != reason {
117+
if derivedCondition.Status != newStatus || derivedCondition.Message != truncatedMessage || derivedCondition.Reason != reason || derivedCondition.ObservedGeneration != gw.Generation {
118118
gw.Status.Conditions[indxToUpdate].LastTransitionTime = metav1.NewTime(time.Now())
119119
gw.Status.Conditions[indxToUpdate].ObservedGeneration = gw.Generation
120120
gw.Status.Conditions[indxToUpdate].Status = newStatus

0 commit comments

Comments
 (0)