@@ -92,8 +92,16 @@ func (c *Controller) syncGateway(key string) error {
92
92
93
93
// Update configuration
94
94
resources := map [resourcev3.Type ][]envoyproxytypes.Resource {}
95
- conditions := []metav1.Condition {}
96
- for _ , listener := range gw .Spec .Listeners {
95
+ gwConditions := []metav1.Condition {{
96
+ Type : string (gatewayv1 .GatewayConditionAccepted ),
97
+ Status : metav1 .ConditionTrue ,
98
+ Reason : string (gatewayv1 .GatewayReasonAccepted ),
99
+ ObservedGeneration : gw .Generation ,
100
+ LastTransitionTime : metav1 .Now (),
101
+ }}
102
+
103
+ lisStatus := make ([]gatewayv1.ListenerStatus , len (gw .Spec .Listeners ))
104
+ for i , listener := range gw .Spec .Listeners {
97
105
// Determine the Envoy protocol based on the Gateway API protocol
98
106
var envoyProto corev3.SocketAddress_Protocol
99
107
switch listener .Protocol {
@@ -115,19 +123,56 @@ func (c *Controller) syncGateway(key string) error {
115
123
})
116
124
117
125
// Process HTTP Routes
126
+ var attachedRoutes int32
118
127
for _ , route := range c .getHTTPRoutesForListener (gw , listener ) {
119
128
klog .V (2 ).Infof ("Processing http route %s/%s for gw %s/%s" , route .Namespace , route .Name , gw .Namespace , gw .Name )
120
- conditions = append (conditions , metav1.Condition {})
129
+ gwConditions = append (gwConditions , metav1.Condition {})
121
130
}
122
131
123
132
for _ , route := range c .getGRPCRoutesForListener (gw , listener ) {
124
133
klog .V (2 ).Infof ("Processing grpc route %s/%s for gw %s/%s" , route .Namespace , route .Name , gw .Namespace , gw .Name )
125
- conditions = append (conditions , metav1.Condition {})
134
+ gwConditions = append (gwConditions , metav1.Condition {})
126
135
}
127
136
128
- // Process GRPC Routes
137
+ lisStatus [i ] = gatewayv1.ListenerStatus {
138
+ Name : listener .Name ,
139
+ AttachedRoutes : attachedRoutes ,
140
+ Conditions : []metav1.Condition {{
141
+ Type : string (gatewayv1 .ListenerConditionAccepted ),
142
+ Status : metav1 .ConditionTrue ,
143
+ Reason : string (gatewayv1 .ListenerReasonAccepted ),
144
+ ObservedGeneration : gw .Generation ,
145
+ LastTransitionTime : metav1 .Now (),
146
+ }},
147
+ }
129
148
}
130
- return c .UpdateXDSServer (context .Background (), containerName , resources )
149
+
150
+ err = c .UpdateXDSServer (context .Background (), containerName , resources )
151
+ if err != nil {
152
+ gwConditions , _ = UpdateConditionIfChanged (gwConditions , metav1.Condition {
153
+ Type : string (gatewayv1 .GatewayConditionProgrammed ),
154
+ Status : metav1 .ConditionFalse ,
155
+ Reason : string (gatewayv1 .GatewayReasonProgrammed ),
156
+ Message : err .Error (),
157
+ ObservedGeneration : gw .Generation ,
158
+ LastTransitionTime : metav1 .Now (),
159
+ })
160
+
161
+ } else {
162
+ gwConditions , _ = UpdateConditionIfChanged (gwConditions , metav1.Condition {
163
+ Type : string (gatewayv1 .GatewayConditionProgrammed ),
164
+ Status : metav1 .ConditionTrue ,
165
+ Reason : string (gatewayv1 .GatewayReasonProgrammed ),
166
+ ObservedGeneration : gw .Generation ,
167
+ LastTransitionTime : metav1 .Now (),
168
+ })
169
+ }
170
+
171
+ gw .Status .Listeners = lisStatus
172
+ gw .Status .Conditions = gwConditions
173
+
174
+ _ , err = c .gwClient .GatewayV1 ().Gateways (gw .Namespace ).UpdateStatus (context .Background (), gw , metav1.UpdateOptions {})
175
+ return err
131
176
}
132
177
133
178
// getHTTPRoutesForListener returns a slice of HTTPRoutes that reference the given Gateway and listener.
0 commit comments