Skip to content

Commit

Permalink
fix 503 error caused by outdated endpooints
Browse files Browse the repository at this point in the history
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
  • Loading branch information
zhaohuabing committed Nov 21, 2024
1 parent 2def6a4 commit ce3c8c5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,22 @@ func (r *gatewayAPIReconciler) processBackendRefs(ctx context.Context, gwcResour
} else {
for _, endpointSlice := range endpointSliceList.Items {
key := utils.NamespacedName(&endpointSlice).String()
r.log.Info("added EndpointSlice to resource tree",
"namespace", endpointSlice.Namespace,
"name", endpointSlice.Name)

Check warning on line 459 in internal/provider/kubernetes/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/kubernetes/controller.go#L457-L459

Added lines #L457 - L459 were not covered by tests
if !resourceMappings.allAssociatedEndpointSlices.Has(key) {
resourceMappings.allAssociatedEndpointSlices.Insert(key)
r.log.Info("added EndpointSlice to resource tree",
"namespace", endpointSlice.Namespace,
"name", endpointSlice.Name)
gwcResource.EndpointSlices = append(gwcResource.EndpointSlices, &endpointSlice)
} else {
updated := gwcResource.EndpointSlices
for i, es := range gwcResource.EndpointSlices {
if es.Name == endpointSlice.Name && es.Namespace == endpointSlice.Namespace {
updated = append(updated[:i], updated[i+1:]...)
updated = append(updated, &endpointSlice)
break

Check warning on line 469 in internal/provider/kubernetes/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/kubernetes/controller.go#L463-L469

Added lines #L463 - L469 were not covered by tests
}
}
gwcResource.EndpointSlices = updated

Check warning on line 472 in internal/provider/kubernetes/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/kubernetes/controller.go#L472

Added line #L472 was not covered by tests
}
}
}
Expand Down

0 comments on commit ce3c8c5

Please sign in to comment.