@@ -67,7 +67,8 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
6767 return fmt .Errorf ("GatewayRefs must be specified when using Gateway API as a provider." )
6868 }
6969
70- apexSvcName , primarySvcName , canarySvcName := canary .GetServiceNames ()
70+ _ , primarySvcName , canarySvcName := canary .GetServiceNames ()
71+ routeName := canary .GetHTTPRouteName ()
7172
7273 hrNamespace := canary .Namespace
7374
@@ -138,7 +139,7 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
138139 }
139140
140141 httpRoute , err := gwr .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes (hrNamespace ).Get (
141- context .TODO (), apexSvcName , metav1.GetOptions {},
142+ context .TODO (), routeName , metav1.GetOptions {},
142143 )
143144
144145 newMetadata := canary .Spec .Service .Apex
@@ -156,7 +157,7 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
156157 if errors .IsNotFound (err ) {
157158 route := & v1.HTTPRoute {
158159 ObjectMeta : metav1.ObjectMeta {
159- Name : apexSvcName ,
160+ Name : routeName ,
160161 Namespace : hrNamespace ,
161162 Labels : newMetadata .Labels ,
162163 Annotations : newMetadata .Annotations ,
@@ -178,13 +179,13 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
178179 Create (context .TODO (), route , metav1.CreateOptions {})
179180
180181 if err != nil {
181- return fmt .Errorf ("HTTPRoute %s.%s create error: %w" , apexSvcName , hrNamespace , err )
182+ return fmt .Errorf ("HTTPRoute %s.%s create error: %w" , routeName , hrNamespace , err )
182183 }
183184 gwr .logger .With ("canary" , fmt .Sprintf ("%s.%s" , canary .Name , canary .Namespace )).
184185 Infof ("HTTPRoute %s.%s created" , route .GetName (), hrNamespace )
185186 return nil
186187 } else if err != nil {
187- return fmt .Errorf ("HTTPRoute %s.%s get error: %w" , apexSvcName , hrNamespace , err )
188+ return fmt .Errorf ("HTTPRoute %s.%s get error: %w" , routeName , hrNamespace , err )
188189 }
189190
190191 ignoreCmpOptions := []cmp.Option {
@@ -266,11 +267,12 @@ func (gwr *GatewayAPIRouter) GetRoutes(canary *flaggerv1.Canary) (
266267 mirrored bool ,
267268 err error ,
268269) {
269- apexSvcName , primarySvcName , canarySvcName := canary .GetServiceNames ()
270+ _ , primarySvcName , canarySvcName := canary .GetServiceNames ()
271+ routeName := canary .GetHTTPRouteName ()
270272 hrNamespace := canary .Namespace
271- httpRoute , err := gwr .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes (hrNamespace ).Get (context .TODO (), apexSvcName , metav1.GetOptions {})
273+ httpRoute , err := gwr .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes (hrNamespace ).Get (context .TODO (), routeName , metav1.GetOptions {})
272274 if err != nil {
273- err = fmt .Errorf ("HTTPRoute %s.%s get error: %w" , apexSvcName , hrNamespace , err )
275+ err = fmt .Errorf ("HTTPRoute %s.%s get error: %w" , routeName , hrNamespace , err )
274276 return
275277 }
276278
@@ -285,7 +287,7 @@ func (gwr *GatewayAPIRouter) GetRoutes(canary *flaggerv1.Canary) (
285287 if condition .Type == string (v1 .RouteConditionAccepted ) && (condition .Status != metav1 .ConditionTrue || condition .ObservedGeneration < currentGeneration ) {
286288 err = fmt .Errorf (
287289 "HTTPRoute %s.%s parent %s is not ready (status: %s, observed generation: %d, current generation: %d)" ,
288- apexSvcName , hrNamespace , parentRef .Name , string (condition .Status ), condition .ObservedGeneration , currentGeneration ,
290+ routeName , hrNamespace , parentRef .Name , string (condition .Status ), condition .ObservedGeneration , currentGeneration ,
289291 )
290292 return 0 , 0 , false , err
291293 }
@@ -346,11 +348,12 @@ func (gwr *GatewayAPIRouter) SetRoutes(
346348) error {
347349 pWeight := int32 (primaryWeight )
348350 cWeight := int32 (canaryWeight )
349- apexSvcName , primarySvcName , canarySvcName := canary .GetServiceNames ()
351+ _ , primarySvcName , canarySvcName := canary .GetServiceNames ()
352+ routeName := canary .GetHTTPRouteName ()
350353 hrNamespace := canary .Namespace
351- httpRoute , err := gwr .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes (hrNamespace ).Get (context .TODO (), apexSvcName , metav1.GetOptions {})
354+ httpRoute , err := gwr .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes (hrNamespace ).Get (context .TODO (), routeName , metav1.GetOptions {})
352355 if err != nil {
353- return fmt .Errorf ("HTTPRoute %s.%s get error: %w" , apexSvcName , hrNamespace , err )
356+ return fmt .Errorf ("HTTPRoute %s.%s get error: %w" , routeName , hrNamespace , err )
354357 }
355358 hrClone := httpRoute .DeepCopy ()
356359 hostNames := []v1.Hostname {}
0 commit comments