Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Huabing Zhao <[email protected]>
  • Loading branch information
zhaohuabing committed Nov 23, 2024
1 parent 7a4c51e commit e406088
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions internal/provider/kubernetes/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,7 @@ func (r *gatewayAPIReconciler) validateServiceForReconcile(obj client.Object) bo
// Check if the Service belongs to a Gateway, if so, update the Gateway status.
gtw := r.findOwningGateway(ctx, labels)
if gtw != nil {
// Trigger a status update for the Gateway.
// The status updater will check the service to get the addresses of the Gateway,
// and check the Deployment/DaemonSet to get the status of the Gateway workload.
r.resources.GatewayStatuses.Store(utils.NamespacedName(gtw), &gtw.Status)
r.updateGatewayStatus(gtw)
return false
}

Expand Down Expand Up @@ -531,10 +528,7 @@ func (r *gatewayAPIReconciler) validateObjectForReconcile(obj client.Object) boo
// Check if the obj belongs to a Gateway, if so, update the Gateway status.
gtw := r.findOwningGateway(ctx, labels)
if gtw != nil {
// Trigger a status update for the Gateway.
// The status updater will check the service to get the addresses of the Gateway,
// and check the Deployment/DaemonSet to get the status of the Gateway workload.
r.resources.GatewayStatuses.Store(utils.NamespacedName(gtw), &gtw.Status)
r.updateGatewayStatus(gtw)
return false
}
}
Expand Down Expand Up @@ -642,12 +636,26 @@ func (r *gatewayAPIReconciler) updateStatusForGatewaysUnderGatewayClass(ctx cont
}

for _, gateway := range gateways.Items {
r.resources.GatewayStatuses.Store(utils.NamespacedName(&gateway), &gateway.Status)
r.updateGatewayStatus(&gateway)

Check warning on line 639 in internal/provider/kubernetes/predicates.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/kubernetes/predicates.go#L639

Added line #L639 was not covered by tests
}

return nil
}

// updateGatewayStatus triggers a status update for the Gateway.
func (r *gatewayAPIReconciler) updateGatewayStatus(gateway *gwapiv1.Gateway) {
// The status added to GatewayStatuses is solely used to trigger the status updater
// and does not reflect the real changed status.
//
// The status updater will check the Envoy Proxy service to get the addresses of the Gateway,
// and check the Envoy Proxy Deployment/DaemonSet to get the status of the Gateway workload.
//
// Since the status does not reflect the actual changed status, we need to delete it first
// to prevent it from being considered unchanged. This ensures that subscribers receive the update event.
r.resources.GatewayStatuses.Delete(utils.NamespacedName(gateway))
r.resources.GatewayStatuses.Store(utils.NamespacedName(gateway), &gateway.Status)
}

func (r *gatewayAPIReconciler) handleNode(obj client.Object) bool {
ctx := context.Background()
node, ok := obj.(*corev1.Node)
Expand Down

0 comments on commit e406088

Please sign in to comment.