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 7a4c51e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 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
2 changes: 0 additions & 2 deletions internal/gatewayapi/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ func TestDeleteStatusKeys(t *testing.T) {
delete(ds.UDPRouteStatusKeys, keys[6])
r.deleteStatusKeys(ds)

require.Equal(t, 0, r.ProviderResources.GatewayStatuses.Len())
require.Equal(t, 0, r.ProviderResources.HTTPRouteStatuses.Len())
require.Equal(t, 0, r.ProviderResources.GRPCRouteStatuses.Len())
require.Equal(t, 0, r.ProviderResources.TLSRouteStatuses.Len())
Expand Down Expand Up @@ -278,7 +277,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 7a4c51e

Please sign in to comment.