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 bccc70c commit bb391aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 9 additions & 5 deletions internal/gatewayapi/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ type StatusesToDelete struct {
func (r *Runner) getAllStatuses() *StatusesToDelete {
// Maps storing status keys to be deleted
ds := &StatusesToDelete{
GatewayStatusKeys: make(map[types.NamespacedName]bool),
HTTPRouteStatusKeys: make(map[types.NamespacedName]bool),
GRPCRouteStatusKeys: make(map[types.NamespacedName]bool),
TLSRouteStatusKeys: make(map[types.NamespacedName]bool),
Expand All @@ -386,11 +387,9 @@ func (r *Runner) getAllStatuses() *StatusesToDelete {
}

// Get current status keys
// Do not delete the status keys for the Gateway because the Gateway status has also been stored into the ProviderResources
// by the kubernetes provider to update the address and workload status.
//
// TODO: zhaohuabing It's not a big issue as the Gateway status typically does not occupy a lot of memory.
// but it's better to move all the status handling to Gateway API translator layer to avoid this.
for key := range r.ProviderResources.GatewayStatuses.LoadAll() {
ds.GatewayStatusKeys[key] = true
}
for key := range r.ProviderResources.HTTPRouteStatuses.LoadAll() {
ds.HTTPRouteStatusKeys[key] = true
}
Expand Down Expand Up @@ -429,6 +428,11 @@ func (r *Runner) getAllStatuses() *StatusesToDelete {
}

func (r *Runner) deleteStatusKeys(ds *StatusesToDelete) {
// Do not delete the status keys for the Gateway because the Gateway status has also been stored into the ProviderResources
// by the kubernetes provider to update the address and workload status.
//
// TODO: zhaohuabing this is acceptable as the Gateway status typically does not occupy a lot of memory,
// but it's better to move all the status handling to Gateway API translator layer to avoid this.
for key := range ds.HTTPRouteStatusKeys {
r.ProviderResources.HTTPRouteStatuses.Delete(key)
delete(ds.HTTPRouteStatusKeys, key)
Expand Down
1 change: 0 additions & 1 deletion internal/gatewayapi/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func TestDeleteAllStatusKeys(t *testing.T) {
// Checks that the keys are successfully stored to DeletableStatus and watchable maps
ds := r.getAllStatuses()

require.True(t, ds.GatewayStatusKeys[keys[0]])
require.True(t, ds.HTTPRouteStatusKeys[keys[1]])
require.True(t, ds.GRPCRouteStatusKeys[keys[2]])
require.True(t, ds.TLSRouteStatusKeys[keys[3]])
Expand Down

0 comments on commit bb391aa

Please sign in to comment.