@@ -112,14 +112,33 @@ func mergePolicyStatus(aggregated aggregatedPolicyStatus, incoming *gwapiv1.Poli
112112 return aggregated
113113 }
114114
115- aggregated .status .Ancestors = append (aggregated .status .Ancestors , incoming .Ancestors ... )
115+ // Prevent self-merge when aggregated and incoming reference the same object
116+ if aggregated .status != incoming {
117+ aggregated .status .Ancestors = append (aggregated .status .Ancestors , incoming .Ancestors ... )
118+ }
116119 if generation > aggregated .generation {
117120 aggregated .generation = generation
118121 }
119122
120123 return aggregated
121124}
122125
126+ func mergeEnvoyProxyStatus (aggregated , incoming * egv1a1.EnvoyProxyStatus ) * egv1a1.EnvoyProxyStatus {
127+ if incoming == nil {
128+ return aggregated
129+ }
130+
131+ if aggregated == nil {
132+ return incoming
133+ }
134+
135+ // Prevent self-merge when aggregated and incoming reference the same object
136+ if aggregated != incoming {
137+ aggregated .Ancestors = append (aggregated .Ancestors , incoming .Ancestors ... )
138+ }
139+ return aggregated
140+ }
141+
123142func New (cfg * Config ) * Runner {
124143 return & Runner {
125144 Config : * cfg ,
@@ -206,6 +225,13 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
206225 // There is only 1 key which is the controller name
207226 // so when a delete is triggered, delete all keys
208227 if update .Delete || valWrapper == nil || valWrapper .Resources == nil {
228+ // Clear EnvoyProxy statuses before deleting to remove stale ancestor conditions
229+ for key := range r .keyCache .EnvoyProxyStatus {
230+ emptyStatus := & egv1a1.EnvoyProxyStatus {
231+ Ancestors : []egv1a1.EnvoyProxyAncestorStatus {},
232+ }
233+ r .ProviderResources .EnvoyProxyStatuses .Store (key , emptyStatus )
234+ }
209235 r .deleteAllKeys ()
210236 return
211237 }
@@ -229,6 +255,7 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
229255 var tlsRouteStatusCount , tcpRouteStatusCount , udpRouteStatusCount int
230256 var backendTLSPolicyStatusCount , clientTrafficPolicyStatusCount , backendTrafficPolicyStatusCount int
231257 var securityPolicyStatusCount , envoyExtensionPolicyStatusCount , backendStatusCount , extensionServerPolicyStatusCount int
258+ var envoyproxyStatusCount int
232259
233260 // `aggregatedStatuses` aggregates status result of resources from all
234261 // parents/ancestors, and then stores the status once for every resource.
@@ -244,6 +271,7 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
244271 SecurityPolicies map [types.NamespacedName ]aggregatedPolicyStatus
245272 EnvoyExtensionPolicies map [types.NamespacedName ]aggregatedPolicyStatus
246273 ExtensionServerPolicies map [message.NamespacedNameAndGVK ]aggregatedPolicyStatus
274+ EnvoyProxies map [types.NamespacedName ]* egv1a1.EnvoyProxyStatus
247275 }{
248276 HTTPRoutes : make (map [types.NamespacedName ]aggregatedRouteStatus ),
249277 GRPCRoutes : make (map [types.NamespacedName ]aggregatedRouteStatus ),
@@ -256,6 +284,7 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
256284 SecurityPolicies : make (map [types.NamespacedName ]aggregatedPolicyStatus ),
257285 EnvoyExtensionPolicies : make (map [types.NamespacedName ]aggregatedPolicyStatus ),
258286 ExtensionServerPolicies : make (map [message.NamespacedNameAndGVK ]aggregatedPolicyStatus ),
287+ EnvoyProxies : make (map [types.NamespacedName ]* egv1a1.EnvoyProxyStatus ),
259288 }
260289
261290 span .AddEvent ("translate" , trace .WithAttributes (attribute .Int ("resources.count" , len (* val ))))
@@ -447,6 +476,15 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
447476 aggregatedStatuses .ExtensionServerPolicies [key ] = mergePolicyStatus (aggregatedStatuses .ExtensionServerPolicies [key ], & policyStatus , extServerPolicy .GetGeneration ())
448477 }
449478 }
479+ // EnvoyProxy status
480+ for _ , ep := range result .EnvoyProxiesForGateways {
481+ r .Logger .Info ("update envoyproxy status" , "key" , utils .NamespacedName (ep ))
482+ aggregatedStatuses .EnvoyProxies [utils .NamespacedName (ep )] = mergeEnvoyProxyStatus (aggregatedStatuses .EnvoyProxies [utils .NamespacedName (ep )], & ep .Status )
483+ }
484+ if ep := result .EnvoyProxyForGatewayClass ; ep != nil {
485+ r .Logger .Info ("update envoyproxy status" , "key" , utils .NamespacedName (ep ))
486+ aggregatedStatuses .EnvoyProxies [utils .NamespacedName (ep )] = mergeEnvoyProxyStatus (aggregatedStatuses .EnvoyProxies [utils .NamespacedName (ep )], & ep .Status )
487+ }
450488 statusUpdateSpan .End ()
451489 }
452490
@@ -533,6 +571,15 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
533571 delete (keysToDelete .ExtensionServerPolicyStatus , key )
534572 r .keyCache .ExtensionServerPolicyStatus [key ] = true
535573 }
574+ for key , entry := range aggregatedStatuses .EnvoyProxies {
575+ s := egv1a1.EnvoyProxyStatus {
576+ Ancestors : entry .Ancestors ,
577+ }
578+ r .ProviderResources .EnvoyProxyStatuses .Store (key , & s )
579+ envoyproxyStatusCount ++
580+ delete (keysToDelete .EnvoyProxyStatus , key )
581+ r .keyCache .EnvoyProxyStatus [key ] = true
582+ }
536583 // Publish aggregated metrics
537584 message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .InfraIRMessageName }, infraIRCount )
538585 message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .XDSIRMessageName }, xdsIRCount )
@@ -551,6 +598,7 @@ func (r *Runner) subscribeAndTranslate(sub <-chan watchable.Snapshot[string, *re
551598 message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .EnvoyExtensionPolicyStatusMessageName }, envoyExtensionPolicyStatusCount )
552599 message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .BackendStatusMessageName }, backendStatusCount )
553600 message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .ExtensionServerPoliciesStatusMessageName }, extensionServerPolicyStatusCount )
601+ message .PublishMetric (message.Metadata {Runner : r .Name (), Message : message .EnvoyProxyStatusMessageName }, envoyproxyStatusCount )
554602
555603 // Delete keys using mark and sweep
556604 r .deleteKeys (keysToDelete )
@@ -660,6 +708,9 @@ func (r *Runner) deleteAllKeys() {
660708 for key := range r .keyCache .BackendStatus {
661709 r .ProviderResources .BackendStatuses .Delete (key )
662710 }
711+ for key := range r .keyCache .EnvoyProxyStatus {
712+ r .ProviderResources .EnvoyProxyStatuses .Delete (key )
713+ }
663714
664715 // Clear all tracking
665716 r .keyCache = newKeyCache ()
@@ -684,6 +735,7 @@ type KeyCache struct {
684735 SecurityPolicyStatus map [types.NamespacedName ]bool
685736 EnvoyExtensionPolicyStatus map [types.NamespacedName ]bool
686737 ExtensionServerPolicyStatus map [message.NamespacedNameAndGVK ]bool
738+ EnvoyProxyStatus map [types.NamespacedName ]bool
687739
688740 BackendStatus map [types.NamespacedName ]bool
689741}
@@ -737,6 +789,9 @@ func (kc *KeyCache) copy() *KeyCache {
737789 for key := range kc .ExtensionServerPolicyStatus {
738790 copied .ExtensionServerPolicyStatus [key ] = true
739791 }
792+ for key := range kc .EnvoyProxyStatus {
793+ copied .EnvoyProxyStatus [key ] = true
794+ }
740795 for key := range kc .BackendStatus {
741796 copied .BackendStatus [key ] = true
742797 }
@@ -760,6 +815,7 @@ func newKeyCache() *KeyCache {
760815 SecurityPolicyStatus : make (map [types.NamespacedName ]bool ),
761816 EnvoyExtensionPolicyStatus : make (map [types.NamespacedName ]bool ),
762817 ExtensionServerPolicyStatus : make (map [message.NamespacedNameAndGVK ]bool ),
818+ EnvoyProxyStatus : make (map [types.NamespacedName ]bool ),
763819 BackendStatus : make (map [types.NamespacedName ]bool ),
764820 }
765821}
@@ -812,6 +868,9 @@ func (r *Runner) populateKeyCache() {
812868 for key := range r .ProviderResources .ExtensionPolicyStatuses .LoadAll () {
813869 r .keyCache .ExtensionServerPolicyStatus [key ] = true
814870 }
871+ for key := range r .ProviderResources .EnvoyProxyStatuses .LoadAll () {
872+ r .keyCache .EnvoyProxyStatus [key ] = true
873+ }
815874 for key := range r .ProviderResources .BackendStatuses .LoadAll () {
816875 r .keyCache .BackendStatus [key ] = true
817876 }
@@ -879,6 +938,10 @@ func (r *Runner) deleteKeys(kc *KeyCache) {
879938 r .ProviderResources .ExtensionPolicyStatuses .Delete (key )
880939 delete (r .keyCache .ExtensionServerPolicyStatus , key )
881940 }
941+ for key := range kc .EnvoyProxyStatus {
942+ r .ProviderResources .EnvoyProxyStatuses .Delete (key )
943+ delete (r .keyCache .EnvoyProxyStatus , key )
944+ }
882945 for key := range kc .BackendStatus {
883946 r .ProviderResources .BackendStatuses .Delete (key )
884947 delete (r .keyCache .BackendStatus , key )
0 commit comments