Repository: kubernetes-sigs/kueue

Issue:
Flaky E2E Test: Should suspend the pods of a deployment created in the test namespace
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!

If the matter is security related, please disclose it privately via https://kubernetes.io/security/
-->


**What happened**:
End To End Custom Configs handling Suite: kindest/node:v1.31.1: [It] ManageJobsWithoutQueueName when manageJobsWithoutQueueName=true should suspend the pods of a deployment created in the test namespace 

```
{Timed out after 10.001s.
The function passed to Eventually failed at /home/prow/go/src/sigs.k8s.io/kueue/test/e2e/customconfigs/skipjobswithoutqueuename_test.go:312 with:
Expected object to be comparable, diff:   map[string]string{
- 	"app":                    "test-deploy-pod",
  	"kueue.x-k8s.io/managed": "true",
- 	"pod-template-hash":      "776f58548",
  }
 failed [FAILED] Timed out after 10.001s.
The function passed to Eventually failed at /home/prow/go/src/sigs.k8s.io/kueue/test/e2e/customconfigs/skipjobswithoutqueuename_test.go:312 with:
Expected object to be comparable, diff:   map[string]string{
- 	"app":                    "test-deploy-pod",
  	"kueue.x-k8s.io/managed": "true",
- 	"pod-template-hash":      "776f58548",
  }
In [It] at: /home/prow/go/src/sigs.k8s.io/kueue/test/e2e/customconfigs/skipjobswithoutqueuename_test.go:315 @ 03/03/25 10:47:10.881
}
```

**What you expected to happen**:
No error

**How to reproduce it (as minimally and precisely as possible)**:
https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_kueue/4457/pull-kueue-test-e2e-customconfigs-main/1896509651114004480

**Anything else we need to know?**:

**Environment**:
- Kubernetes version (use `kubectl version`):
- Kueue version (use `git describe --tags --dirty --always`):
- Cloud provider or hardware configuration:
- OS (e.g: `cat /etc/os-release`):
- Kernel (e.g. `uname -a`):
- Install tools:
- Others:

Hints from issue comments:
@mbobrovskyi: /kind flake@mbobrovskyi: cc: @kaisoz @kaisoz: /assign

I'll have a look! Thanks for reporting!@mimowo: another occurance; https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_kueue/4464/pull-kueue-test-e2e-customconfigs-main/1896574710532018176

Solution patch:
diff --git a/cmd/experimental/kueue-viz/.gitignore b/cmd/experimental/kueue-viz/.gitignore
index eaeec3187..1a527756f 100644
--- a/cmd/experimental/kueue-viz/.gitignore
+++ b/cmd/experimental/kueue-viz/.gitignore
@@ -1,2 +1,2 @@
 kubeconfig
-
+kueue_ws_app
diff --git a/cmd/experimental/kueue-viz/backend/README.md b/cmd/experimental/kueue-viz/backend/README.md
index 3b3219ae3..2e21bdb10 100644
--- a/cmd/experimental/kueue-viz/backend/README.md
+++ b/cmd/experimental/kueue-viz/backend/README.md
@@ -1,12 +1,15 @@
 # Kueue WebSocket Application
 
 ## Description
+
 This Go application provides WebSocket endpoints for interacting with Kueue resources in a Kubernetes cluster. It uses the Gin framework for HTTP and WebSocket handling and the Kubernetes Go client for API interactions.
 
 ## Features
+
 - Fetch and broadcast `localqueues` over WebSocket.
 
 ## Prerequisites
+
 - A Kubernetes cluster
 - Go 1.19+
 - `kubectl` configured to access the cluster
@@ -19,6 +22,7 @@ This Go application provides WebSocket endpoints for interacting with Kueue reso
 ## Build
 
 Run the following command to build the application:
+
 ```bash
 CGO_ENABLED=0 go build -o kueue_ws_app
 ```
@@ -26,29 +30,36 @@ CGO_ENABLED=0 go build -o kueue_ws_app
 ## Run
 
 Run the application:
+
 ```bash
+# Start with default value
 ./kueue_ws_app
+
+# Start on port 8181
+KUEUE_VIZ_PORT=8181 ./kueue_ws_app
 ```
 
-The application starts on port `8080`.
+## Variables
+
+| Environment variables | Description              | Default value |
+| --------------------- | ------------------------ | ------------- |
+| `KUEUE_VIZ_PORT`      | Default application port | 8080          |
 
 ## Endpoints
 
 ### WebSocket
-## WebSocket Endpoints
-
-| Endpoint                                     | Description                          |
-|---------------------------------------------|--------------------------------------|
-| `/ws/local-queues`                          | Streams updates for local queues     |
-| `/ws/cluster-queues`                        | Streams updates for cluster queues   |
-| `/ws/workloads`                             | Streams updates for workloads        |
-| `/ws/resource-flavors`                      | Streams updates for resource flavors |
-| `/ws/resource-flavor/{flavor_name}`         | Streams updates for a specific flavor|
-| `/ws/local-queue/{namespace}/{queue_name}`  | Streams updates for a specific queue|
-| `/ws/cohorts`                               | Streams updates for cohorts          |
-| `/ws/cohort/{cohort_name}`                  | Streams updates for a specific cohort|
-| `/ws/workload/{namespace}/{workload_name}`  | Streams updates for a specific workload|
-| `/ws/workload/{namespace}/{workload_name}/events` | Streams events for a specific workload|
-
 
+## WebSocket Endpoints
 
+| Endpoint                                          | Description                             |
+| ------------------------------------------------- | --------------------------------------- |
+| `/ws/local-queues`                                | Streams updates for local queues        |
+| `/ws/cluster-queues`                              | Streams updates for cluster queues      |
+| `/ws/workloads`                                   | Streams updates for workloads           |
+| `/ws/resource-flavors`                            | Streams updates for resource flavors    |
+| `/ws/resource-flavor/{flavor_name}`               | Streams updates for a specific flavor   |
+| `/ws/local-queue/{namespace}/{queue_name}`        | Streams updates for a specific queue    |
+| `/ws/cohorts`                                     | Streams updates for cohorts             |
+| `/ws/cohort/{cohort_name}`                        | Streams updates for a specific cohort   |
+| `/ws/workload/{namespace}/{workload_name}`        | Streams updates for a specific workload |
+| `/ws/workload/{namespace}/{workload_name}/events` | Streams events for a specific workload  |
diff --git a/cmd/experimental/kueue-viz/backend/go.mod b/cmd/experimental/kueue-viz/backend/go.mod
index 8d4858412..9f38a929d 100644
--- a/cmd/experimental/kueue-viz/backend/go.mod
+++ b/cmd/experimental/kueue-viz/backend/go.mod
@@ -10,6 +10,23 @@ require (
 	k8s.io/client-go v0.32.2
 )
 
+require (
+	github.com/fsnotify/fsnotify v1.7.0 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
+	github.com/sagikazarmark/locafero v0.4.0 // indirect
+	github.com/sagikazarmark/slog-shim v0.1.0 // indirect
+	github.com/sourcegraph/conc v0.3.0 // indirect
+	github.com/spf13/afero v1.11.0 // indirect
+	github.com/spf13/cast v1.6.0 // indirect
+	github.com/subosito/gotenv v1.6.0 // indirect
+	go.uber.org/atomic v1.9.0 // indirect
+	go.uber.org/multierr v1.9.0 // indirect
+	golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
+	gopkg.in/ini.v1 v1.67.0 // indirect
+)
+
 require (
 	github.com/bytedance/sonic v1.11.6 // indirect
 	github.com/bytedance/sonic/loader v0.1.1 // indirect
@@ -46,6 +63,7 @@ require (
 	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/spf13/viper v1.19.0
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
 	github.com/ugorji/go/codec v1.2.12 // indirect
 	github.com/x448/float16 v0.8.4 // indirect
diff --git a/cmd/experimental/kueue-viz/backend/go.sum b/cmd/experimental/kueue-viz/backend/go.sum
index a4907b28e..68ac4699c 100644
--- a/cmd/experimental/kueue-viz/backend/go.sum
+++ b/cmd/experimental/kueue-viz/backend/go.sum
@@ -13,6 +13,10 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
 github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
+github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
+github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
+github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
+github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
 github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
 github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
 github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
@@ -61,6 +65,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
 github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
 github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -80,10 +86,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
 github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
+github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
+github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
 github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -104,8 +114,20 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
 github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
 github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
+github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
+github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
+github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
+github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
+github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
+github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
+github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
+github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
+github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
+github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
+github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -118,6 +140,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
 github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
+github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
 github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
 github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
 github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -126,6 +150,10 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
 github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
+go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
+go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
 golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
 golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
 golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
@@ -134,6 +162,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
 golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
+golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
+golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
 golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -181,6 +211,8 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
 gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
 gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
 gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
+gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/cmd/experimental/kueue-viz/backend/main.go b/cmd/experimental/kueue-viz/backend/main.go
index 261d422d2..672cadfdb 100644
--- a/cmd/experimental/kueue-viz/backend/main.go
+++ b/cmd/experimental/kueue-viz/backend/main.go
@@ -17,17 +17,20 @@ limitations under the License.
 package main
 
 import (
+	"fmt"
 	"log"
 
 	"kueue-viz/handlers"
 
 	"github.com/gin-gonic/gin"
+	"github.com/spf13/viper"
 
 	"net/http"
 	_ "net/http/pprof"
 )
 
 func main() {
+	viper.AutomaticEnv()
 	// Start pprof server for profiling
 	go func() {
 		log.Println("Starting pprof server on :6060")
@@ -46,7 +49,8 @@ func main() {
 
 	handlers.InitializeWebSocketRoutes(r, dynamicClient, k8sClient)
 
-	if err := r.Run(":8080"); err != nil {
+	viper.SetDefault("KUEUE_VIZ_PORT", "8080")
+	if err := r.Run(fmt.Sprintf(":%s", viper.GetString("KUEUE_VIZ_PORT"))); err != nil {
 		log.Fatalf("Failed to start server: %v", err)
 	}
 
diff --git a/hack/internal/tools/go.mod b/hack/internal/tools/go.mod
index c90c702a3..d52da1a84 100644
--- a/hack/internal/tools/go.mod
+++ b/hack/internal/tools/go.mod
@@ -6,7 +6,7 @@ toolchain go1.23.2
 
 require (
 	github.com/gohugoio/hugo v0.145.0
-	github.com/golangci/golangci-lint v1.63.4
+	github.com/golangci/golangci-lint v1.64.6
 	github.com/mikefarah/yq/v4 v4.45.1
 	github.com/onsi/ginkgo/v2 v2.22.2
 	gopkg.in/yaml.v3 v3.0.1
@@ -78,7 +78,7 @@ require (
 	github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
 	github.com/magiconair/properties v1.8.9 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
-	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-colorable v0.1.14 // indirect
 	github.com/mattn/go-isatty v0.0.20 // indirect
 	github.com/mitchellh/copystructure v1.2.0 // indirect
 	github.com/mitchellh/go-wordwrap v1.0.1 // indirect
@@ -96,7 +96,7 @@ require (
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/russross/blackfriday/v2 v2.1.0 // indirect
 	github.com/shopspring/decimal v1.4.0 // indirect
-	github.com/spf13/afero v1.11.0 // indirect
+	github.com/spf13/afero v1.12.0 // indirect
 	github.com/spf13/cast v1.7.1 // indirect
 	github.com/spf13/cobra v1.9.1 // indirect
 	github.com/spf13/pflag v1.0.6 // indirect
diff --git a/hack/internal/tools/go.sum b/hack/internal/tools/go.sum
index 1401bc9b4..03f43e9da 100644
--- a/hack/internal/tools/go.sum
+++ b/hack/internal/tools/go.sum
@@ -102,8 +102,8 @@ github.com/gohugoio/hugo v0.145.0 h1:1M/AnPdCY0W/XTVaw6Ahw44vYVc111eE5fWTgt4TpIM
 github.com/gohugoio/hugo v0.145.0/go.mod h1:TjeMFx+RGO3SI7z4HCGrkjSfDzTPZ4i+89EoVkxs8Ws=
 github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
 github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
-github.com/golangci/golangci-lint v1.63.4 h1:bJQFQ3hSfUto597dkL7ipDzOxsGEpiWdLiZ359OWOBI=
-github.com/golangci/golangci-lint v1.63.4/go.mod h1:Hx0B7Lg5/NXbaOHem8+KU+ZUIzMI6zNj/7tFwdnn10I=
+github.com/golangci/golangci-lint v1.64.6 h1:jOLaQN41IV7bMzXuNC4UnQGll7N1xY6eFDXkXEPGKAs=
+github.com/golangci/golangci-lint v1.64.6/go.mod h1:Wz9q+6EVuqGQ94GQ96RB2mjpcZYTOGhBhbt4O7REPu4=
 github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0 h1:4gjrh/PN2MuWCCElk8/I4OCKRKWCCo2zEct3VKCbibU=
 github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
 github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
@@ -158,8 +158,9 @@ github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a
 github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
 github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
-github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
 github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
+github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
 github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
@@ -218,8 +219,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
 github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
 github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
 github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
-github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
-github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
+github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
+github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
 github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
 github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go
index 52e981aca..d6172a602 100644
--- a/pkg/cache/cache.go
+++ b/pkg/cache/cache.go
@@ -192,7 +192,7 @@ func (c *Cache) PodsReadyForAllAdmittedWorkloads(log logr.Logger) bool {
 }
 
 func (c *Cache) podsReadyForAllAdmittedWorkloads(log logr.Logger) bool {
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if len(cq.WorkloadsNotReady) > 0 {
 			log.V(3).Info("There is a ClusterQueue with not ready workloads", "clusterQueue", klog.KRef("", cq.Name))
 			return false
@@ -215,7 +215,7 @@ func (c *Cache) CleanUpOnContext(ctx context.Context) {
 func (c *Cache) updateClusterQueues() sets.Set[string] {
 	cqs := sets.New[string]()
 
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		prevStatus := cq.Status
 		// We call update on all ClusterQueues irrespective of which CQ actually use this flavor
 		// because it is not expensive to do so, and is not worth tracking which ClusterQueues use
@@ -234,7 +234,7 @@ func (c *Cache) ActiveClusterQueues() sets.Set[string] {
 	c.RLock()
 	defer c.RUnlock()
 	cqs := sets.New[string]()
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if cq.Status == active {
 			cqs.Insert(cq.Name)
 		}
@@ -306,8 +306,8 @@ func (c *Cache) DeleteAdmissionCheck(ac *kueue.AdmissionCheck) sets.Set[string]
 func (c *Cache) AdmissionChecksForClusterQueue(cqName string) []AdmissionCheck {
 	c.RLock()
 	defer c.RUnlock()
-	cq, ok := c.hm.ClusterQueues[cqName]
-	if !ok || len(cq.AdmissionChecks) == 0 {
+	cq := c.hm.ClusterQueue(cqName)
+	if cq == nil || len(cq.AdmissionChecks) == 0 {
 		return nil
 	}
 	acs := make([]AdmissionCheck, 0, len(cq.AdmissionChecks))
@@ -330,7 +330,7 @@ func (c *Cache) ClusterQueueTerminating(name string) bool {
 func (c *Cache) ClusterQueueReadiness(name string) (metav1.ConditionStatus, string, string) {
 	c.RLock()
 	defer c.RUnlock()
-	cq := c.hm.ClusterQueues[name]
+	cq := c.hm.ClusterQueue(name)
 	if cq == nil {
 		return metav1.ConditionFalse, "NotFound", "ClusterQueue not found"
 	}
@@ -345,17 +345,17 @@ func (c *Cache) clusterQueueInStatus(name string, status metrics.ClusterQueueSta
 	c.RLock()
 	defer c.RUnlock()
 
-	cq, exists := c.hm.ClusterQueues[name]
-	if !exists {
+	cq := c.hm.ClusterQueue(name)
+	if cq == nil {
 		return false
 	}
-	return cq != nil && cq.Status == status
+	return cq.Status == status
 }
 
 func (c *Cache) TerminateClusterQueue(name string) {
 	c.Lock()
 	defer c.Unlock()
-	if cq, exists := c.hm.ClusterQueues[name]; exists {
+	if cq := c.hm.ClusterQueue(name); cq != nil {
 		cq.Status = terminating
 		metrics.ReportClusterQueueStatus(cq.Name, cq.Status)
 	}
@@ -367,8 +367,8 @@ func (c *Cache) TerminateClusterQueue(name string) {
 func (c *Cache) ClusterQueueEmpty(name string) bool {
 	c.RLock()
 	defer c.RUnlock()
-	cq, exists := c.hm.ClusterQueues[name]
-	if !exists {
+	cq := c.hm.ClusterQueue(name)
+	if cq == nil {
 		return true
 	}
 	return len(cq.Workloads) == 0
@@ -378,7 +378,7 @@ func (c *Cache) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) err
 	c.Lock()
 	defer c.Unlock()
 
-	if _, ok := c.hm.ClusterQueues[cq.Name]; ok {
+	if oldCq := c.hm.ClusterQueue(cq.Name); oldCq != nil {
 		return errors.New("ClusterQueue already exists")
 	}
 	cqImpl, err := c.newClusterQueue(cq)
@@ -422,8 +422,8 @@ func (c *Cache) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) err
 func (c *Cache) UpdateClusterQueue(cq *kueue.ClusterQueue) error {
 	c.Lock()
 	defer c.Unlock()
-	cqImpl, ok := c.hm.ClusterQueues[cq.Name]
-	if !ok {
+	cqImpl := c.hm.ClusterQueue(cq.Name)
+	if cqImpl == nil {
 		return ErrCqNotFound
 	}
 	oldParent := cqImpl.Parent()
@@ -443,12 +443,12 @@ func (c *Cache) UpdateClusterQueue(cq *kueue.ClusterQueue) error {
 func (c *Cache) DeleteClusterQueue(cq *kueue.ClusterQueue) {
 	c.Lock()
 	defer c.Unlock()
-	_, ok := c.hm.ClusterQueues[cq.Name]
-	if !ok {
+	curCq := c.hm.ClusterQueue(cq.Name)
+	if curCq == nil {
 		return
 	}
 	if features.Enabled(features.LocalQueueMetrics) {
-		for _, q := range c.hm.ClusterQueues[cq.Name].localQueues {
+		for _, q := range c.hm.ClusterQueue(cq.Name).localQueues {
 			metrics.ClearLocalQueueCacheMetrics(metrics.LQRefFromLocalQueueKey(q.key))
 		}
 	}
@@ -460,7 +460,7 @@ func (c *Cache) AddOrUpdateCohort(apiCohort *kueuealpha.Cohort) error {
 	c.Lock()
 	defer c.Unlock()
 	c.hm.AddCohort(apiCohort.Name)
-	cohort := c.hm.Cohorts[apiCohort.Name]
+	cohort := c.hm.Cohort(apiCohort.Name)
 	oldParent := cohort.Parent()
 	c.hm.UpdateCohortEdge(apiCohort.Name, apiCohort.Spec.Parent)
 	return cohort.updateCohort(c.hm.CycleChecker, apiCohort, oldParent)
@@ -474,7 +474,7 @@ func (c *Cache) DeleteCohort(cohortName string) {
 	// If the cohort still exists after deletion, it means
 	// that it has one or more children referencing it.
 	// We need to run update algorithm.
-	if cohort, ok := c.hm.Cohorts[cohortName]; ok {
+	if cohort := c.hm.Cohort(cohortName); cohort != nil {
 		updateCohortResourceNode(cohort)
 	}
 }
@@ -482,8 +482,8 @@ func (c *Cache) DeleteCohort(cohortName string) {
 func (c *Cache) AddLocalQueue(q *kueue.LocalQueue) error {
 	c.Lock()
 	defer c.Unlock()
-	cq, ok := c.hm.ClusterQueues[string(q.Spec.ClusterQueue)]
-	if !ok {
+	cq := c.hm.ClusterQueue(string(q.Spec.ClusterQueue))
+	if cq == nil {
 		return nil
 	}
 	return cq.addLocalQueue(q)
@@ -492,8 +492,8 @@ func (c *Cache) AddLocalQueue(q *kueue.LocalQueue) error {
 func (c *Cache) DeleteLocalQueue(q *kueue.LocalQueue) {
 	c.Lock()
 	defer c.Unlock()
-	cq, ok := c.hm.ClusterQueues[string(q.Spec.ClusterQueue)]
-	if !ok {
+	cq := c.hm.ClusterQueue(string(q.Spec.ClusterQueue))
+	if cq == nil {
 		return
 	}
 	cq.deleteLocalQueue(q)
@@ -505,12 +505,12 @@ func (c *Cache) UpdateLocalQueue(oldQ, newQ *kueue.LocalQueue) error {
 	}
 	c.Lock()
 	defer c.Unlock()
-	cq, ok := c.hm.ClusterQueues[string(oldQ.Spec.ClusterQueue)]
-	if ok {
+	cq := c.hm.ClusterQueue(string(oldQ.Spec.ClusterQueue))
+	if cq != nil {
 		cq.deleteLocalQueue(oldQ)
 	}
-	cq, ok = c.hm.ClusterQueues[string(newQ.Spec.ClusterQueue)]
-	if ok {
+	cq = c.hm.ClusterQueue(string(newQ.Spec.ClusterQueue))
+	if cq != nil {
 		return cq.addLocalQueue(newQ)
 	}
 	return nil
@@ -527,8 +527,8 @@ func (c *Cache) addOrUpdateWorkload(w *kueue.Workload) bool {
 		return false
 	}
 
-	clusterQueue, ok := c.hm.ClusterQueues[string(w.Status.Admission.ClusterQueue)]
-	if !ok {
+	clusterQueue := c.hm.ClusterQueue(string(w.Status.Admission.ClusterQueue))
+	if clusterQueue == nil {
 		return false
 	}
 
@@ -548,8 +548,8 @@ func (c *Cache) UpdateWorkload(oldWl, newWl *kueue.Workload) error {
 	c.Lock()
 	defer c.Unlock()
 	if workload.HasQuotaReservation(oldWl) {
-		cq, ok := c.hm.ClusterQueues[string(oldWl.Status.Admission.ClusterQueue)]
-		if !ok {
+		cq := c.hm.ClusterQueue(string(oldWl.Status.Admission.ClusterQueue))
+		if cq == nil {
 			return errors.New("old ClusterQueue doesn't exist")
 		}
 		cq.deleteWorkload(oldWl)
@@ -559,8 +559,8 @@ func (c *Cache) UpdateWorkload(oldWl, newWl *kueue.Workload) error {
 	if !workload.HasQuotaReservation(newWl) {
 		return nil
 	}
-	cq, ok := c.hm.ClusterQueues[string(newWl.Status.Admission.ClusterQueue)]
-	if !ok {
+	cq := c.hm.ClusterQueue(string(newWl.Status.Admission.ClusterQueue))
+	if cq == nil {
 		return errors.New("new ClusterQueue doesn't exist")
 	}
 	if c.podsReadyTracking {
@@ -595,7 +595,7 @@ func (c *Cache) IsAssumedOrAdmittedWorkload(w workload.Info) bool {
 	if _, assumed := c.assumedWorkloads[k]; assumed {
 		return true
 	}
-	if cq, exists := c.hm.ClusterQueues[w.ClusterQueue]; exists {
+	if cq := c.hm.ClusterQueue(w.ClusterQueue); cq != nil {
 		if _, admitted := cq.Workloads[k]; admitted {
 			return true
 		}
@@ -617,8 +617,8 @@ func (c *Cache) AssumeWorkload(w *kueue.Workload) error {
 		return fmt.Errorf("the workload is already assumed to ClusterQueue %q", assumedCq)
 	}
 
-	cq, ok := c.hm.ClusterQueues[string(w.Status.Admission.ClusterQueue)]
-	if !ok {
+	cq := c.hm.ClusterQueue(string(w.Status.Admission.ClusterQueue))
+	if cq == nil {
 		return ErrCqNotFound
 	}
 
@@ -642,8 +642,8 @@ func (c *Cache) ForgetWorkload(w *kueue.Workload) error {
 		return errWorkloadNotAdmitted
 	}
 
-	cq, ok := c.hm.ClusterQueues[string(w.Status.Admission.ClusterQueue)]
-	if !ok {
+	cq := c.hm.ClusterQueue(string(w.Status.Admission.ClusterQueue))
+	if cq == nil {
 		return ErrCqNotFound
 	}
 	cq.deleteWorkload(w)
@@ -666,7 +666,7 @@ func (c *Cache) Usage(cqObj *kueue.ClusterQueue) (*ClusterQueueUsageStats, error
 	c.RLock()
 	defer c.RUnlock()
 
-	cq := c.hm.ClusterQueues[cqObj.Name]
+	cq := c.hm.ClusterQueue(cqObj.Name)
 	if cq == nil {
 		return nil, ErrCqNotFound
 	}
@@ -733,8 +733,8 @@ func (c *Cache) LocalQueueUsage(qObj *kueue.LocalQueue) (*LocalQueueUsageStats,
 	c.RLock()
 	defer c.RUnlock()
 
-	cqImpl, ok := c.hm.ClusterQueues[string(qObj.Spec.ClusterQueue)]
-	if !ok {
+	cqImpl := c.hm.ClusterQueue(string(qObj.Spec.ClusterQueue))
+	if cqImpl == nil {
 		return &LocalQueueUsageStats{}, nil
 	}
 	qImpl, ok := cqImpl.localQueues[queueKey(qObj)]
@@ -811,7 +811,7 @@ func (c *Cache) cleanupAssumedState(w *kueue.Workload) {
 		// If the workload's assigned ClusterQueue is different from the assumed
 		// one, then we should also clean up the assumed one.
 		if workload.HasQuotaReservation(w) && assumedCQName != string(w.Status.Admission.ClusterQueue) {
-			if assumedCQ, exist := c.hm.ClusterQueues[assumedCQName]; exist {
+			if assumedCQ := c.hm.ClusterQueue(assumedCQName); assumedCQ != nil {
 				assumedCQ.deleteWorkload(w)
 			}
 		}
@@ -821,10 +821,10 @@ func (c *Cache) cleanupAssumedState(w *kueue.Workload) {
 
 func (c *Cache) clusterQueueForWorkload(w *kueue.Workload) *clusterQueue {
 	if workload.HasQuotaReservation(w) {
-		return c.hm.ClusterQueues[string(w.Status.Admission.ClusterQueue)]
+		return c.hm.ClusterQueue(string(w.Status.Admission.ClusterQueue))
 	}
 	wKey := workload.Key(w)
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if cq.Workloads[wKey] != nil {
 			return cq
 		}
@@ -837,7 +837,7 @@ func (c *Cache) ClusterQueuesUsingFlavor(flavor kueue.ResourceFlavorReference) [
 	defer c.RUnlock()
 	var cqs []string
 
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if cq.flavorInUse(flavor) {
 			cqs = append(cqs, cq.Name)
 		}
@@ -850,7 +850,7 @@ func (c *Cache) ClusterQueuesUsingTopology(tName kueue.TopologyReference) []stri
 	defer c.RUnlock()
 	var cqs []string
 
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		for _, tRef := range cq.tasFlavors {
 			if tRef == tName {
 				cqs = append(cqs, cq.Name)
@@ -865,7 +865,7 @@ func (c *Cache) ClusterQueuesUsingAdmissionCheck(ac string) []string {
 	defer c.RUnlock()
 	var cqs []string
 
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if _, found := cq.AdmissionChecks[ac]; found {
 			cqs = append(cqs, cq.Name)
 		}
@@ -878,7 +878,7 @@ func (c *Cache) MatchingClusterQueues(nsLabels map[string]string) sets.Set[strin
 	defer c.RUnlock()
 
 	cqs := sets.New[string]()
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if cq.NamespaceSelector.Matches(labels.Set(nsLabels)) {
 			cqs.Insert(cq.Name)
 		}
diff --git a/pkg/cache/clusterqueue_snapshot.go b/pkg/cache/clusterqueue_snapshot.go
index 5da1013b4..9e899c559 100644
--- a/pkg/cache/clusterqueue_snapshot.go
+++ b/pkg/cache/clusterqueue_snapshot.go
@@ -68,6 +68,24 @@ func (c *ClusterQueueSnapshot) RGByResource(resource corev1.ResourceName) *Resou
 	return nil
 }
 
+// SimulateUsageRemoval the snapshot by removing the usage corresponding to the
+// list of workloads. It returns the function which can be used to restore
+// the usage.
+func (c *ClusterQueueSnapshot) SimulateUsageRemoval(workloads []*workload.Info) func() {
+	var usage []workload.Usage
+	for _, w := range workloads {
+		usage = append(usage, w.Usage())
+	}
+	for _, u := range usage {
+		c.removeUsage(u)
+	}
+	return func() {
+		for _, u := range usage {
+			c.AddUsage(u)
+		}
+	}
+}
+
 func (c *ClusterQueueSnapshot) AddUsage(usage workload.Usage) {
 	for fr, q := range usage.Quota {
 		addUsage(c, fr, q)
diff --git a/pkg/cache/snapshot.go b/pkg/cache/snapshot.go
index d1ee360a7..c19bd3a89 100644
--- a/pkg/cache/snapshot.go
+++ b/pkg/cache/snapshot.go
@@ -42,7 +42,7 @@ type Snapshot struct {
 // RemoveWorkload removes a workload from its corresponding ClusterQueue and
 // updates resource usage.
 func (s *Snapshot) RemoveWorkload(wl *workload.Info) {
-	cq := s.ClusterQueues[wl.ClusterQueue]
+	cq := s.ClusterQueue(wl.ClusterQueue)
 	delete(cq.Workloads, workload.Key(wl.Obj))
 	cq.removeUsage(wl.Usage())
 }
@@ -50,13 +50,13 @@ func (s *Snapshot) RemoveWorkload(wl *workload.Info) {
 // AddWorkload adds a workload from its corresponding ClusterQueue and
 // updates resource usage.
 func (s *Snapshot) AddWorkload(wl *workload.Info) {
-	cq := s.ClusterQueues[wl.ClusterQueue]
+	cq := s.ClusterQueue(wl.ClusterQueue)
 	cq.Workloads[workload.Key(wl.Obj)] = wl
 	cq.AddUsage(wl.Usage())
 }
 
 func (s *Snapshot) Log(log logr.Logger) {
-	for name, cq := range s.ClusterQueues {
+	for name, cq := range s.ClusterQueues() {
 		cohortName := "<none>"
 		if cq.HasParent() {
 			cohortName = cq.Parent().Name
@@ -70,7 +70,7 @@ func (s *Snapshot) Log(log logr.Logger) {
 			"workloads", slices.Collect(maps.Keys(cq.Workloads)),
 		)
 	}
-	for name, cohort := range s.Cohorts {
+	for name, cohort := range s.Cohorts() {
 		log.Info("Found cohort",
 			"cohort", name,
 			"resources", cohort.ResourceNode.SubtreeQuota,
@@ -88,13 +88,13 @@ func (c *Cache) Snapshot(ctx context.Context) (*Snapshot, error) {
 		ResourceFlavors:          make(map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor, len(c.resourceFlavors)),
 		InactiveClusterQueueSets: sets.New[string](),
 	}
-	for _, cohort := range c.hm.Cohorts {
+	for _, cohort := range c.hm.Cohorts() {
 		if c.hm.CycleChecker.HasCycle(cohort) {
 			continue
 		}
 		snap.AddCohort(cohort.Name)
-		snap.Cohorts[cohort.Name].ResourceNode = cohort.resourceNode.Clone()
-		snap.Cohorts[cohort.Name].FairWeight = cohort.FairWeight
+		snap.Cohort(cohort.Name).ResourceNode = cohort.resourceNode.Clone()
+		snap.Cohort(cohort.Name).FairWeight = cohort.FairWeight
 		if cohort.HasParent() {
 			snap.UpdateCohortEdge(cohort.Name, cohort.Parent().Name)
 		}
@@ -110,7 +110,7 @@ func (c *Cache) Snapshot(ctx context.Context) (*Snapshot, error) {
 			}
 		}
 	}
-	for _, cq := range c.hm.ClusterQueues {
+	for _, cq := range c.hm.ClusterQueues() {
 		if !cq.Active() || (cq.HasParent() && c.hm.CycleChecker.HasCycle(cq.Parent())) {
 			snap.InactiveClusterQueueSets.Insert(cq.Name)
 			continue
diff --git a/pkg/cache/tas_flavor_snapshot.go b/pkg/cache/tas_flavor_snapshot.go
index ab9c0c461..a04e97cde 100644
--- a/pkg/cache/tas_flavor_snapshot.go
+++ b/pkg/cache/tas_flavor_snapshot.go
@@ -411,23 +411,21 @@ func (s *TASFlavorSnapshot) findLevelWithFitDomains(levelIdx int, required bool,
 		topDomain = sortedDomain[findMostAllocatedDomainIdx(sortedDomain, count)]
 	}
 	if topDomain.state < count {
-		results := []*domain{topDomain}
 		if required {
 			return 0, nil, s.notFitMessage(topDomain.state, count)
 		}
 		if levelIdx > 0 {
 			return s.findLevelWithFitDomains(levelIdx-1, required, count)
 		}
-		lastIdx := 0
-		remainingCount := count - sortedDomain[lastIdx].state
-		for remainingCount > 0 && lastIdx < len(sortedDomain)-1 && sortedDomain[lastIdx].state > 0 {
-			lastIdx++
+		results := []*domain{}
+		remainingCount := count
+		for idx := 0; remainingCount > 0 && idx < len(sortedDomain) && sortedDomain[idx].state > 0; idx++ {
 			offset := 0
-			if !features.Enabled(features.TASLeastAllocated) && sortedDomain[lastIdx].state >= remainingCount {
-				offset = findMostAllocatedDomainIdx(sortedDomain[lastIdx:], remainingCount)
+			if !features.Enabled(features.TASLeastAllocated) && sortedDomain[idx].state >= remainingCount {
+				offset = findMostAllocatedDomainIdx(sortedDomain[idx:], remainingCount)
 			}
-			results = append(results, sortedDomain[lastIdx+offset])
-			remainingCount -= sortedDomain[lastIdx].state
+			results = append(results, sortedDomain[idx+offset])
+			remainingCount -= sortedDomain[idx].state
 		}
 		if remainingCount > 0 {
 			return 0, nil, s.notFitMessage(count-remainingCount, count)
diff --git a/pkg/hierarchy/manager.go b/pkg/hierarchy/manager.go
index 9c96aadc4..18c6c6e47 100644
--- a/pkg/hierarchy/manager.go
+++ b/pkg/hierarchy/manager.go
@@ -16,11 +16,13 @@ limitations under the License.
 
 package hierarchy
 
+import "maps"
+
 // Manager stores Cohorts and ClusterQueues, and maintains the edges
 // between them.
 type Manager[CQ clusterQueueNode[C], C cohortNode[CQ, C]] struct {
-	Cohorts       map[string]C
-	ClusterQueues map[string]CQ
+	cohorts       map[string]C
+	clusterQueues map[string]CQ
 	cohortFactory func(string) C
 	CycleChecker  CycleChecker
 }
@@ -38,11 +40,27 @@ func NewManager[CQ clusterQueueNode[C], C cohortNode[CQ, C]](newCohort func(stri
 }
 
 func (m *Manager[CQ, C]) AddClusterQueue(cq CQ) {
-	m.ClusterQueues[cq.GetName()] = cq
+	m.clusterQueues[cq.GetName()] = cq
+}
+
+func (m *Manager[CQ, C]) ClusterQueue(name string) CQ {
+	return m.clusterQueues[name]
+}
+
+func (m *Manager[CQ, C]) ClusterQueuesNames() []string {
+	clusterQueuesNames := make([]string, 0, len(m.clusterQueues))
+	for k := range m.clusterQueues {
+		clusterQueuesNames = append(clusterQueuesNames, k)
+	}
+	return clusterQueuesNames
+}
+
+func (m *Manager[CQ, C]) ClusterQueues() map[string]CQ {
+	return maps.Clone(m.clusterQueues)
 }
 
 func (m *Manager[CQ, C]) UpdateClusterQueueEdge(name, parentName string) {
-	cq := m.ClusterQueues[name]
+	cq := m.clusterQueues[name]
 	m.detachClusterQueueFromParent(cq)
 	if parentName != "" {
 		parent := m.getOrCreateCohort(parentName)
@@ -52,26 +70,34 @@ func (m *Manager[CQ, C]) UpdateClusterQueueEdge(name, parentName string) {
 }
 
 func (m *Manager[CQ, C]) DeleteClusterQueue(name string) {
-	if cq, ok := m.ClusterQueues[name]; ok {
+	if cq, ok := m.clusterQueues[name]; ok {
 		m.detachClusterQueueFromParent(cq)
-		delete(m.ClusterQueues, name)
+		delete(m.clusterQueues, name)
 	}
 }
 
 func (m *Manager[CQ, C]) AddCohort(cohortName string) {
-	oldCohort, ok := m.Cohorts[cohortName]
+	oldCohort, ok := m.cohorts[cohortName]
 	if ok && oldCohort.isExplicit() {
 		return
 	}
 	if !ok {
-		m.Cohorts[cohortName] = m.cohortFactory(cohortName)
+		m.cohorts[cohortName] = m.cohortFactory(cohortName)
 	}
-	m.Cohorts[cohortName].markExplicit()
+	m.cohorts[cohortName].markExplicit()
+}
+
+func (m *Manager[CQ, C]) Cohort(name string) C {
+	return m.cohorts[name]
+}
+
+func (m *Manager[CQ, C]) Cohorts() map[string]C {
+	return maps.Clone(m.cohorts)
 }
 
 func (m *Manager[CQ, C]) UpdateCohortEdge(name, parentName string) {
 	m.resetCycleChecker()
-	cohort := m.Cohorts[name]
+	cohort := m.cohorts[name]
 	m.detachCohortFromParent(cohort)
 	if parentName != "" {
 		parent := m.getOrCreateCohort(parentName)
@@ -82,17 +108,17 @@ func (m *Manager[CQ, C]) UpdateCohortEdge(name, parentName string) {
 
 func (m *Manager[CQ, C]) DeleteCohort(name string) {
 	m.resetCycleChecker()
-	cohort, ok := m.Cohorts[name]
+	cohort, ok := m.cohorts[name]
 	if !ok {
 		return
 	}
-	delete(m.Cohorts, name)
+	delete(m.cohorts, name)
 	m.detachCohortFromParent(cohort)
 	if !cohort.hasChildren() {
 		return
 	}
 	implicitCohort := m.cohortFactory(name)
-	m.Cohorts[implicitCohort.GetName()] = implicitCohort
+	m.cohorts[implicitCohort.GetName()] = implicitCohort
 	m.transferChildren(cohort, implicitCohort)
 }
 
@@ -130,20 +156,28 @@ func (m *Manager[CQ, C]) detachCohortFromParent(cohort C) {
 }
 
 func (m *Manager[CQ, C]) getOrCreateCohort(cohortName string) C {
-	if _, ok := m.Cohorts[cohortName]; !ok {
-		m.Cohorts[cohortName] = m.cohortFactory(cohortName)
+	if _, ok := m.cohorts[cohortName]; !ok {
+		m.cohorts[cohortName] = m.cohortFactory(cohortName)
 	}
-	return m.Cohorts[cohortName]
+	return m.cohorts[cohortName]
 }
 
 func (m *Manager[CQ, C]) cleanupCohort(cohort C) {
 	if !cohort.isExplicit() && !cohort.hasChildren() {
-		delete(m.Cohorts, cohort.GetName())
+		delete(m.cohorts, cohort.GetName())
 	}
 }
 
 func (m *Manager[CQ, C]) resetCycleChecker() {
-	m.CycleChecker = CycleChecker{make(map[string]bool, len(m.Cohorts))}
+	m.CycleChecker = CycleChecker{make(map[string]bool, len(m.cohorts))}
+}
+
+// A special constructor for using in tests
+func NewManagerForTest[CQ clusterQueueNode[C], C cohortNode[CQ, C]](cohorts map[string]C, clusterQueues map[string]CQ) Manager[CQ, C] {
+	return Manager[CQ, C]{
+		cohorts:       cohorts,
+		clusterQueues: clusterQueues,
+	}
 }
 
 type nodeBase interface {
diff --git a/pkg/queue/dumper.go b/pkg/queue/dumper.go
index 2cf66b847..29153754d 100644
--- a/pkg/queue/dumper.go
+++ b/pkg/queue/dumper.go
@@ -26,7 +26,7 @@ import (
 func (m *Manager) LogDump(log logr.Logger) {
 	m.Lock()
 	defer m.Unlock()
-	for name, cq := range m.hm.ClusterQueues {
+	for name, cq := range m.hm.ClusterQueues() {
 		pending, _ := cq.Dump()
 		inadmissible, _ := cq.DumpInadmissible()
 		log.Info("Found pending and inadmissible workloads in ClusterQueue",
@@ -41,11 +41,12 @@ func (m *Manager) LogDump(log logr.Logger) {
 func (m *Manager) Dump() map[string][]string {
 	m.Lock()
 	defer m.Unlock()
-	if len(m.hm.ClusterQueues) == 0 {
+	clusterQueues := m.hm.ClusterQueues()
+	if len(clusterQueues) == 0 {
 		return nil
 	}
-	dump := make(map[string][]string, len(m.hm.ClusterQueues))
-	for key, cq := range m.hm.ClusterQueues {
+	dump := make(map[string][]string, len(clusterQueues))
+	for key, cq := range clusterQueues {
 		if elements, ok := cq.Dump(); ok {
 			dump[key] = elements
 		}
@@ -61,11 +62,12 @@ func (m *Manager) Dump() map[string][]string {
 func (m *Manager) DumpInadmissible() map[string][]string {
 	m.Lock()
 	defer m.Unlock()
-	if len(m.hm.ClusterQueues) == 0 {
+	clusterQueues := m.hm.ClusterQueues()
+	if len(clusterQueues) == 0 {
 		return nil
 	}
-	dump := make(map[string][]string, len(m.hm.ClusterQueues))
-	for key, cq := range m.hm.ClusterQueues {
+	dump := make(map[string][]string, len(clusterQueues))
+	for key, cq := range clusterQueues {
 		if elements, ok := cq.DumpInadmissible(); ok {
 			dump[key] = elements
 		}
diff --git a/pkg/queue/manager.go b/pkg/queue/manager.go
index c752ac624..0f42a3f76 100644
--- a/pkg/queue/manager.go
+++ b/pkg/queue/manager.go
@@ -141,7 +141,7 @@ func (m *Manager) AddOrUpdateCohort(ctx context.Context, cohort *kueuealpha.Coho
 	defer m.Unlock()
 	m.hm.AddCohort(cohort.Name)
 	m.hm.UpdateCohortEdge(cohort.Name, cohort.Spec.Parent)
-	if m.requeueWorkloadsCohort(ctx, m.hm.Cohorts[cohort.Name]) {
+	if m.requeueWorkloadsCohort(ctx, m.hm.Cohort(cohort.Name)) {
 		m.Broadcast()
 	}
 }
@@ -156,7 +156,7 @@ func (m *Manager) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) e
 	m.Lock()
 	defer m.Unlock()
 
-	if _, ok := m.hm.ClusterQueues[cq.Name]; ok {
+	if cq := m.hm.ClusterQueue(cq.Name); cq != nil {
 		return errClusterQueueAlreadyExists
 	}
 
@@ -204,8 +204,8 @@ func (m *Manager) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) e
 func (m *Manager) UpdateClusterQueue(ctx context.Context, cq *kueue.ClusterQueue, specUpdated bool) error {
 	m.Lock()
 	defer m.Unlock()
-	cqImpl, ok := m.hm.ClusterQueues[cq.Name]
-	if !ok {
+	cqImpl := m.hm.ClusterQueue(cq.Name)
+	if cqImpl == nil {
 		return ErrClusterQueueDoesNotExist
 	}
 
@@ -235,7 +235,7 @@ func (m *Manager) UpdateClusterQueue(ctx context.Context, cq *kueue.ClusterQueue
 func (m *Manager) DeleteClusterQueue(cq *kueue.ClusterQueue) {
 	m.Lock()
 	defer m.Unlock()
-	cqImpl := m.hm.ClusterQueues[cq.Name]
+	cqImpl := m.hm.ClusterQueue(cq.Name)
 	if cqImpl == nil {
 		return
 	}
@@ -274,7 +274,7 @@ func (m *Manager) AddLocalQueue(ctx context.Context, q *kueue.LocalQueue) error
 		workload.AdjustResources(ctx, m.client, &w)
 		qImpl.AddOrUpdate(workload.NewInfo(&w, m.workloadInfoOptions...))
 	}
-	cq := m.hm.ClusterQueues[qImpl.ClusterQueue]
+	cq := m.hm.ClusterQueue(qImpl.ClusterQueue)
 	if cq != nil && cq.AddFromLocalQueue(qImpl) {
 		m.Broadcast()
 	}
@@ -289,11 +289,11 @@ func (m *Manager) UpdateLocalQueue(q *kueue.LocalQueue) error {
 		return ErrLocalQueueDoesNotExistOrInactive
 	}
 	if qImpl.ClusterQueue != string(q.Spec.ClusterQueue) {
-		oldCQ := m.hm.ClusterQueues[qImpl.ClusterQueue]
+		oldCQ := m.hm.ClusterQueue(qImpl.ClusterQueue)
 		if oldCQ != nil {
 			oldCQ.DeleteFromLocalQueue(qImpl)
 		}
-		newCQ := m.hm.ClusterQueues[string(q.Spec.ClusterQueue)]
+		newCQ := m.hm.ClusterQueue(string(q.Spec.ClusterQueue))
 		if newCQ != nil && newCQ.AddFromLocalQueue(qImpl) {
 			m.Broadcast()
 		}
@@ -310,7 +310,7 @@ func (m *Manager) DeleteLocalQueue(q *kueue.LocalQueue) {
 	if qImpl == nil {
 		return
 	}
-	cq := m.hm.ClusterQueues[qImpl.ClusterQueue]
+	cq := m.hm.ClusterQueue(qImpl.ClusterQueue)
 	if cq != nil {
 		cq.DeleteFromLocalQueue(qImpl)
 	}
@@ -336,8 +336,8 @@ func (m *Manager) Pending(cq *kueue.ClusterQueue) (int, error) {
 	m.RLock()
 	defer m.RUnlock()
 
-	cqImpl, ok := m.hm.ClusterQueues[cq.Name]
-	if !ok {
+	cqImpl := m.hm.ClusterQueue(cq.Name)
+	if cqImpl == nil {
 		return 0, ErrClusterQueueDoesNotExist
 	}
 
@@ -361,7 +361,7 @@ func (m *Manager) ClusterQueueForWorkload(wl *kueue.Workload) (string, bool) {
 	if !ok {
 		return "", false
 	}
-	_, ok = m.hm.ClusterQueues[q.ClusterQueue]
+	ok = m.hm.ClusterQueue(q.ClusterQueue) != nil
 	return q.ClusterQueue, ok
 }
 
@@ -381,7 +381,7 @@ func (m *Manager) AddOrUpdateWorkloadWithoutLock(w *kueue.Workload) error {
 	}
 	wInfo := workload.NewInfo(w, m.workloadInfoOptions...)
 	q.AddOrUpdate(wInfo)
-	cq := m.hm.ClusterQueues[q.ClusterQueue]
+	cq := m.hm.ClusterQueue(q.ClusterQueue)
 	if cq == nil {
 		return ErrClusterQueueDoesNotExist
 	}
@@ -415,7 +415,7 @@ func (m *Manager) RequeueWorkload(ctx context.Context, info *workload.Info, reas
 	}
 	info.Update(&w)
 	q.AddOrUpdate(info)
-	cq := m.hm.ClusterQueues[q.ClusterQueue]
+	cq := m.hm.ClusterQueue(q.ClusterQueue)
 	if cq == nil {
 		return false
 	}
@@ -443,7 +443,7 @@ func (m *Manager) deleteWorkloadFromQueueAndClusterQueue(w *kueue.Workload, qKey
 		return
 	}
 	delete(q.items, workload.Key(w))
-	cq := m.hm.ClusterQueues[q.ClusterQueue]
+	cq := m.hm.ClusterQueue(q.ClusterQueue)
 	if cq != nil {
 		cq.Delete(w)
 		m.reportPendingWorkloads(q.ClusterQueue, cq)
@@ -470,7 +470,7 @@ func (m *Manager) QueueAssociatedInadmissibleWorkloadsAfter(ctx context.Context,
 	if q == nil {
 		return
 	}
-	cq := m.hm.ClusterQueues[q.ClusterQueue]
+	cq := m.hm.ClusterQueue(q.ClusterQueue)
 	if cq == nil {
 		return
 	}
@@ -492,8 +492,8 @@ func (m *Manager) QueueInadmissibleWorkloads(ctx context.Context, cqNames sets.S
 
 	var queued bool
 	for name := range cqNames {
-		cq, exists := m.hm.ClusterQueues[name]
-		if !exists {
+		cq := m.hm.ClusterQueue(name)
+		if cq == nil {
 			continue
 		}
 		if m.requeueWorkloadsCQ(ctx, cq) {
@@ -600,7 +600,7 @@ func (m *Manager) Heads(ctx context.Context) []workload.Info {
 
 func (m *Manager) heads() []workload.Info {
 	var workloads []workload.Info
-	for cqName, cq := range m.hm.ClusterQueues {
+	for cqName, cq := range m.hm.ClusterQueues() {
 		// Cache might be nil in tests, if cache is nil, we'll skip the check.
 		if m.statusChecker != nil && !m.statusChecker.ClusterQueueActive(cqName) {
 			continue
@@ -649,22 +649,18 @@ func (m *Manager) reportPendingWorkloads(cqName string, cq *ClusterQueue) {
 func (m *Manager) GetClusterQueueNames() []string {
 	m.RLock()
 	defer m.RUnlock()
-	clusterQueueNames := make([]string, 0, len(m.hm.ClusterQueues))
-	for k := range m.hm.ClusterQueues {
-		clusterQueueNames = append(clusterQueueNames, k)
-	}
-	return clusterQueueNames
+	return m.hm.ClusterQueuesNames()
 }
 
 func (m *Manager) getClusterQueue(cqName string) *ClusterQueue {
 	m.RLock()
 	defer m.RUnlock()
-	return m.hm.ClusterQueues[cqName]
+	return m.hm.ClusterQueue(cqName)
 }
 
 func (m *Manager) getClusterQueueLockless(cqName string) (val *ClusterQueue, ok bool) {
-	val, ok = m.hm.ClusterQueues[cqName]
-	return
+	val = m.hm.ClusterQueue(cqName)
+	return val, val != nil
 }
 
 func (m *Manager) PendingWorkloadsInfo(cqName string) []*workload.Info {
diff --git a/pkg/scheduler/preemption/preemption.go b/pkg/scheduler/preemption/preemption.go
index 8dac52e1b..5cae76804 100644
--- a/pkg/scheduler/preemption/preemption.go
+++ b/pkg/scheduler/preemption/preemption.go
@@ -124,7 +124,7 @@ type Target struct {
 // GetTargets returns the list of workloads that should be evicted in
 // order to make room for wl.
 func (p *Preemptor) GetTargets(log logr.Logger, wl workload.Info, assignment flavorassigner.Assignment, snapshot *cache.Snapshot) []*Target {
-	cq := snapshot.ClusterQueues[wl.ClusterQueue]
+	cq := snapshot.ClusterQueue(wl.ClusterQueue)
 	tasRequests := assignment.WorkloadsTopologyRequests(&wl, cq)
 	return p.getTargets(&preemptionCtx{
 		log:               log,
@@ -259,7 +259,7 @@ func minimalPreemptions(preemptionCtx *preemptionCtx, candidates []*workload.Inf
 	var targets []*Target
 	fits := false
 	for _, candWl := range candidates {
-		candCQ := preemptionCtx.snapshot.ClusterQueues[candWl.ClusterQueue]
+		candCQ := preemptionCtx.snapshot.ClusterQueue(candWl.ClusterQueue)
 		reason := kueue.InClusterQueueReason
 		if preemptionCtx.preemptorCQ != candCQ {
 			if !cqIsBorrowing(candCQ, preemptionCtx.frsNeedPreemption) {
@@ -472,7 +472,7 @@ func cqHeapFromCandidates(candidates []*workload.Info, firstOnly bool, snapshot
 	for _, cand := range candidates {
 		candCQ := cqHeap.GetByKey(cand.ClusterQueue)
 		if candCQ == nil {
-			cq := snapshot.ClusterQueues[cand.ClusterQueue]
+			cq := snapshot.ClusterQueue(cand.ClusterQueue)
 			share, _ := cq.DominantResourceShare()
 			candCQ = &candidateCQ{
 				cq:        cq,
diff --git a/pkg/scheduler/preemption/preemption_oracle.go b/pkg/scheduler/preemption/preemption_oracle.go
index e8f5f7ba8..7d03b4747 100644
--- a/pkg/scheduler/preemption/preemption_oracle.go
+++ b/pkg/scheduler/preemption/preemption_oracle.go
@@ -44,7 +44,7 @@ func (p *PreemptionOracle) IsReclaimPossible(log logr.Logger, cq *cache.ClusterQ
 	for _, candidate := range p.preemptor.getTargets(&preemptionCtx{
 		log:               log,
 		preemptor:         wl,
-		preemptorCQ:       p.snapshot.ClusterQueues[wl.ClusterQueue],
+		preemptorCQ:       p.snapshot.ClusterQueue(wl.ClusterQueue),
 		snapshot:          p.snapshot,
 		frsNeedPreemption: sets.New(fr),
 		requests:          resources.FlavorResourceQuantities{fr: quantity},
diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go
index 1483f650d..24adaef58 100644
--- a/pkg/scheduler/scheduler.go
+++ b/pkg/scheduler/scheduler.go
@@ -20,6 +20,7 @@ import (
 	"context"
 	"fmt"
 	"maps"
+	"slices"
 	"sort"
 	"testing"
 
@@ -218,7 +219,7 @@ func (s *Scheduler) schedule(ctx context.Context) wait.SpeedSignal {
 			continue
 		}
 
-		cq := snapshot.ClusterQueues[e.ClusterQueue]
+		cq := snapshot.ClusterQueue(e.ClusterQueue)
 		log := log.WithValues("workload", klog.KObj(e.Obj), "clusterQueue", klog.KRef("", e.ClusterQueue))
 		ctx := ctrl.LoggerInto(ctx, log)
 
@@ -238,8 +239,8 @@ func (s *Scheduler) schedule(ctx context.Context) wait.SpeedSignal {
 			continue
 		}
 
-		usage := e.netUsage()
-		if !cq.Fits(usage) {
+		usage := e.usage()
+		if !fits(cq, &usage, preemptedWorkloads, e.preemptionTargets) {
 			setSkipped(e, "Workload no longer fits after processing another workload")
 			if mode == flavorassigner.Preempt {
 				skippedPreemptions[cq.Name]++
@@ -325,30 +326,8 @@ type entry struct {
 	preemptionTargets     []*preemption.Target
 }
 
-func (e *entry) netUsage() workload.Usage {
-	return workload.Usage{
-		Quota: e.netQuotaUsage(),
-	}
-}
-
-// netQuotaUsage returns how much capacity this entry will require from the ClusterQueue/Cohort.
-// When a workload is preempting, it subtracts the preempted resources from the resources
-// required, as the remaining quota is all we need from the CQ/Cohort.
-func (e *entry) netQuotaUsage() resources.FlavorResourceQuantities {
-	if e.assignment.RepresentativeMode() == flavorassigner.Fit {
-		return e.assignment.Usage
-	}
-
-	usage := maps.Clone(e.assignment.Usage)
-	for target := range e.preemptionTargets {
-		for fr, v := range e.preemptionTargets[target].WorkloadInfo.FlavorResourceUsage() {
-			if _, uses := usage[fr]; !uses {
-				continue
-			}
-			usage[fr] = max(0, usage[fr]-v)
-		}
-	}
-	return usage
+func (e *entry) usage() workload.Usage {
+	return workload.Usage{Quota: e.assignment.Usage}
 }
 
 // nominate returns the workloads with their requirements (resource flavors, borrowing) if
@@ -358,7 +337,7 @@ func (s *Scheduler) nominate(ctx context.Context, workloads []workload.Info, sna
 	entries := make([]entry, 0, len(workloads))
 	for _, w := range workloads {
 		log := log.WithValues("workload", klog.KObj(w.Obj), "clusterQueue", klog.KRef("", w.ClusterQueue))
-		cq := snap.ClusterQueues[w.ClusterQueue]
+		cq := snap.ClusterQueue(w.ClusterQueue)
 		ns := corev1.Namespace{}
 		e := entry{Info: w}
 		if s.cache.IsAssumedOrAdmittedWorkload(w) {
@@ -392,6 +371,16 @@ func (s *Scheduler) nominate(ctx context.Context, workloads []workload.Info, sna
 	return entries
 }
 
+func fits(cq *cache.ClusterQueueSnapshot, usage *workload.Usage, preemptedWorkloads preemptedWorkloads, newTargets []*preemption.Target) bool {
+	workloads := slices.Collect(maps.Values(preemptedWorkloads))
+	for _, target := range newTargets {
+		workloads = append(workloads, target.WorkloadInfo)
+	}
+	revertUsage := cq.SimulateUsageRemoval(workloads)
+	defer revertUsage()
+	return cq.Fits(*usage)
+}
+
 // resourcesToReserve calculates how much of the available resources in cq/cohort assignment should be reserved.
 func resourcesToReserve(e *entry, cq *cache.ClusterQueueSnapshot) workload.Usage {
 	return workload.Usage{
@@ -425,7 +414,7 @@ type partialAssignment struct {
 }
 
 func (s *Scheduler) getAssignments(log logr.Logger, wl *workload.Info, snap *cache.Snapshot) (flavorassigner.Assignment, []*preemption.Target) {
-	cq := snap.ClusterQueues[wl.ClusterQueue]
+	cq := snap.ClusterQueue(wl.ClusterQueue)
 	flvAssigner := flavorassigner.New(wl, cq, snap.ResourceFlavors, s.fairSharing.Enable, preemption.NewOracle(s.preemptor, snap))
 	fullAssignment := flvAssigner.Assign(log, nil)
 



Test patch:
diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go
index 789af7bca..a1540fc5a 100644
--- a/pkg/cache/cache_test.go
+++ b/pkg/cache/cache_test.go
@@ -1107,7 +1107,7 @@ func TestCacheClusterQueueOperations(t *testing.T) {
 			if err := tc.operation(cache); err != nil {
 				t.Errorf("Unexpected error during test operation: %s", err)
 			}
-			if diff := cmp.Diff(tc.wantClusterQueues, cache.hm.ClusterQueues,
+			if diff := cmp.Diff(tc.wantClusterQueues, cache.hm.ClusterQueues(),
 				cmpopts.IgnoreFields(clusterQueue{}, "ResourceGroups"),
 				cmpopts.IgnoreFields(workload.Info{}, "Obj", "LastAssignment"),
 				cmpopts.IgnoreUnexported(clusterQueue{}, hierarchy.ClusterQueue[*cohort]{}),
@@ -1115,8 +1115,9 @@ func TestCacheClusterQueueOperations(t *testing.T) {
 				t.Errorf("Unexpected clusterQueues (-want,+got):\n%s", diff)
 			}
 
-			gotCohorts := make(map[string]sets.Set[string], len(cache.hm.Cohorts))
-			for name, cohort := range cache.hm.Cohorts {
+			cohorts := cache.hm.Cohorts()
+			gotCohorts := make(map[string]sets.Set[string], len(cohorts))
+			for name, cohort := range cohorts {
 				gotCohort := sets.New[string]()
 				for _, cq := range cohort.ChildCQs() {
 					gotCohort.Insert(cq.Name)
@@ -1681,7 +1682,7 @@ func TestCacheWorkloadOperations(t *testing.T) {
 				t.Errorf("Unexpected error (-want,+got):\n%s", diff)
 			}
 			gotResult := make(map[string]result)
-			for name, cq := range cache.hm.ClusterQueues {
+			for name, cq := range cache.hm.ClusterQueues() {
 				gotResult[name] = result{
 					Workloads:     sets.KeySet(cq.Workloads),
 					UsedResources: cq.resourceNode.Usage,
@@ -2725,7 +2726,7 @@ func TestCacheQueueOperations(t *testing.T) {
 				}
 			}
 			cacheQueues := make(map[string]*queue)
-			for _, cacheCQ := range cache.hm.ClusterQueues {
+			for _, cacheCQ := range cache.hm.ClusterQueues() {
 				for qKey, cacheQ := range cacheCQ.localQueues {
 					if _, ok := cacheQueues[qKey]; ok {
 						t.Fatalf("The cache have a duplicated localQueue %q across multiple clusterQueues", qKey)
@@ -2979,7 +2980,7 @@ func TestCachePodsReadyForAllAdmittedWorkloads(t *testing.T) {
 				return nil
 			},
 			operation: func(cache *Cache) error {
-				wl := cache.hm.ClusterQueues["one"].Workloads["/a"].Obj
+				wl := cache.hm.ClusterQueue("one").Workloads["/a"].Obj
 				newWl := wl.DeepCopy()
 				apimeta.SetStatusCondition(&newWl.Status.Conditions, metav1.Condition{
 					Type:   kueue.WorkloadPodsReady,
@@ -3002,7 +3003,7 @@ func TestCachePodsReadyForAllAdmittedWorkloads(t *testing.T) {
 				return nil
 			},
 			operation: func(cache *Cache) error {
-				wl := cache.hm.ClusterQueues["one"].Workloads["/a"].Obj
+				wl := cache.hm.ClusterQueue("one").Workloads["/a"].Obj
 				newWl := wl.DeepCopy()
 				apimeta.SetStatusCondition(&newWl.Status.Conditions, metav1.Condition{
 					Type:   kueue.WorkloadPodsReady,
@@ -3049,7 +3050,7 @@ func TestCachePodsReadyForAllAdmittedWorkloads(t *testing.T) {
 				return nil
 			},
 			operation: func(cache *Cache) error {
-				wl2 := cache.hm.ClusterQueues["two"].Workloads["/b"].Obj
+				wl2 := cache.hm.ClusterQueue("two").Workloads["/b"].Obj
 				newWl2 := wl2.DeepCopy()
 				apimeta.SetStatusCondition(&newWl2.Status.Conditions, metav1.Condition{
 					Type:   kueue.WorkloadPodsReady,
@@ -3072,7 +3073,7 @@ func TestCachePodsReadyForAllAdmittedWorkloads(t *testing.T) {
 				return nil
 			},
 			operation: func(cache *Cache) error {
-				wl := cache.hm.ClusterQueues["one"].Workloads["/a"].Obj
+				wl := cache.hm.ClusterQueue("one").Workloads["/a"].Obj
 				return cache.DeleteWorkload(wl)
 			},
 			wantReady: true,
@@ -3089,7 +3090,7 @@ func TestCachePodsReadyForAllAdmittedWorkloads(t *testing.T) {
 				return cache.AssumeWorkload(wl)
 			},
 			operation: func(cache *Cache) error {
-				wl := cache.hm.ClusterQueues["one"].Workloads["/a"].Obj
+				wl := cache.hm.ClusterQueue("one").Workloads["/a"].Obj
 				return cache.ForgetWorkload(wl)
 			},
 			wantReady: true,
@@ -3231,7 +3232,9 @@ func TestIsAssumedOrAdmittedCheckWorkload(t *testing.T) {
 	for _, tc := range tests {
 		t.Run(tc.name, func(t *testing.T) {
 			cache := New(utiltesting.NewFakeClient())
-			cache.hm.ClusterQueues = tc.clusterQueues
+			for _, cq := range tc.clusterQueues {
+				cache.hm.AddClusterQueue(cq)
+			}
 			cache.assumedWorkloads = tc.assumedWorkloads
 			if cache.IsAssumedOrAdmittedWorkload(tc.workload) != tc.expected {
 				t.Error("Unexpected response")
@@ -3542,7 +3545,7 @@ func TestCohortCycles(t *testing.T) {
 		}
 
 		// cohort's SubtreeQuota contains resources from cq.
-		gotResource := cache.hm.Cohorts["cohort"].getResourceNode()
+		gotResource := cache.hm.Cohort("cohort").getResourceNode()
 		wantResource := ResourceNode{
 			Quotas: map[resources.FlavorResource]ResourceQuota{
 				{Flavor: "arm", Resource: corev1.ResourceCPU}: {Nominal: 10_000},
@@ -3579,7 +3582,7 @@ func TestCohortCycles(t *testing.T) {
 		}
 
 		// cohort's SubtreeQuota contains resources from cq
-		gotResource := cache.hm.Cohorts["cohort"].getResourceNode()
+		gotResource := cache.hm.Cohort("cohort").getResourceNode()
 		wantResource := ResourceNode{
 			Quotas: map[resources.FlavorResource]ResourceQuota{
 				{Flavor: "arm", Resource: corev1.ResourceCPU}: {Nominal: 10_000},
@@ -3600,7 +3603,7 @@ func TestCohortCycles(t *testing.T) {
 		}
 
 		// Cohort's SubtreeQuota no longer contains resources from CQ.
-		gotResource = cache.hm.Cohorts["cohort"].getResourceNode()
+		gotResource = cache.hm.Cohort("cohort").getResourceNode()
 		wantResource = ResourceNode{
 			Quotas: map[resources.FlavorResource]ResourceQuota{
 				{Flavor: "arm", Resource: corev1.ResourceCPU}: {Nominal: 10_000},
@@ -3646,10 +3649,10 @@ func TestCohortCycles(t *testing.T) {
 				SubtreeQuota: resources.FlavorResourceQuantities{},
 				Usage:        resources.FlavorResourceQuantities{},
 			}
-			if diff := cmp.Diff(wantRoot1, cache.hm.Cohorts["root1"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot1, cache.hm.Cohort("root1").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
-			if diff := cmp.Diff(wantRoot2, cache.hm.Cohorts["root2"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot2, cache.hm.Cohort("root2").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
 		}
@@ -3671,10 +3674,10 @@ func TestCohortCycles(t *testing.T) {
 				},
 				Usage: resources.FlavorResourceQuantities{},
 			}
-			if diff := cmp.Diff(wantRoot1, cache.hm.Cohorts["root1"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot1, cache.hm.Cohort("root1").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
-			if diff := cmp.Diff(wantRoot2, cache.hm.Cohorts["root2"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot2, cache.hm.Cohort("root2").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
 		}
@@ -3708,7 +3711,7 @@ func TestCohortCycles(t *testing.T) {
 			},
 			Usage: resources.FlavorResourceQuantities{},
 		}
-		if diff := cmp.Diff(wantRoot, cache.hm.Cohorts["root"].getResourceNode()); diff != "" {
+		if diff := cmp.Diff(wantRoot, cache.hm.Cohort("root").getResourceNode()); diff != "" {
 			t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 		}
 	})
@@ -3739,7 +3742,7 @@ func TestCohortCycles(t *testing.T) {
 				},
 				Usage: resources.FlavorResourceQuantities{},
 			}
-			if diff := cmp.Diff(wantRoot, cache.hm.Cohorts["root"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot, cache.hm.Cohort("root").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
 		}
@@ -3756,7 +3759,7 @@ func TestCohortCycles(t *testing.T) {
 				SubtreeQuota: resources.FlavorResourceQuantities{},
 				Usage:        resources.FlavorResourceQuantities{},
 			}
-			if diff := cmp.Diff(wantRoot, cache.hm.Cohorts["root"].getResourceNode()); diff != "" {
+			if diff := cmp.Diff(wantRoot, cache.hm.Cohort("root").getResourceNode()); diff != "" {
 				t.Errorf("Unexpected resource (-want,+got):\n%s", diff)
 			}
 		}
diff --git a/pkg/cache/clusterqueue_test.go b/pkg/cache/clusterqueue_test.go
index 5e4bdbb4f..87cfdd74a 100644
--- a/pkg/cache/clusterqueue_test.go
+++ b/pkg/cache/clusterqueue_test.go
@@ -169,7 +169,7 @@ func TestClusterQueueUpdate(t *testing.T) {
 			}
 			if diff := cmp.Diff(
 				tc.wantLastAssignmentGeneration,
-				snapshot.ClusterQueues["eng-alpha"].AllocatableResourceGeneration); diff != "" {
+				snapshot.ClusterQueue("eng-alpha").AllocatableResourceGeneration); diff != "" {
 				t.Errorf("Unexpected assigned clusterQueues in cache (-want,+got):\n%s", diff)
 			}
 		})
diff --git a/pkg/cache/fair_sharing_test.go b/pkg/cache/fair_sharing_test.go
index e7a7c2de9..055d0f0f2 100644
--- a/pkg/cache/fair_sharing_test.go
+++ b/pkg/cache/fair_sharing_test.go
@@ -641,8 +641,10 @@ func TestDominantResourceShare(t *testing.T) {
 				i++
 			}
 
-			gotCache := make([]fairSharingResult, 0, len(snapshot.ClusterQueues)+len(snapshot.Cohorts))
-			for _, cq := range cache.hm.ClusterQueues {
+			cacheClusterQueuesMap := cache.hm.ClusterQueues()
+			cacheCohortsMap := cache.hm.Cohorts()
+			gotCache := make([]fairSharingResult, 0, len(cacheClusterQueuesMap)+len(cacheCohortsMap))
+			for _, cq := range cacheClusterQueuesMap {
 				drVal, drName := dominantResourceShare(cq, tc.flvResQ)
 				gotCache = append(gotCache, fairSharingResult{
 					Name:     cq.Name,
@@ -651,7 +653,7 @@ func TestDominantResourceShare(t *testing.T) {
 					DrName:   drName,
 				})
 			}
-			for _, cohort := range cache.hm.Cohorts {
+			for _, cohort := range cacheCohortsMap {
 				drVal, drName := dominantResourceShare(cohort, tc.flvResQ)
 				gotCache = append(gotCache, fairSharingResult{
 					Name:     cohort.Name,
@@ -664,8 +666,10 @@ func TestDominantResourceShare(t *testing.T) {
 				t.Errorf("dominantResourceShare cache mismatch: %s", diff)
 			}
 
-			gotSnapshot := make([]fairSharingResult, 0, len(snapshot.ClusterQueues)+len(snapshot.Cohorts))
-			for _, cq := range snapshot.ClusterQueues {
+			snapshotClusterQueuesMap := snapshot.ClusterQueues()
+			snapshotCohortsMap := snapshot.Cohorts()
+			gotSnapshot := make([]fairSharingResult, 0, len(snapshotClusterQueuesMap)+len(snapshotCohortsMap))
+			for _, cq := range snapshotClusterQueuesMap {
 				drVal, drName := dominantResourceShare(cq, tc.flvResQ)
 				gotSnapshot = append(gotSnapshot, fairSharingResult{
 					Name:     cq.Name,
@@ -674,7 +678,7 @@ func TestDominantResourceShare(t *testing.T) {
 					DrName:   drName,
 				})
 			}
-			for _, cohort := range snapshot.Cohorts {
+			for _, cohort := range snapshotCohortsMap {
 				drVal, drName := dominantResourceShare(cohort, tc.flvResQ)
 				gotSnapshot = append(gotSnapshot, fairSharingResult{
 					Name:     cohort.Name,
diff --git a/pkg/cache/resource_node_test.go b/pkg/cache/resource_node_test.go
index bcdcb5f11..3b5454895 100644
--- a/pkg/cache/resource_node_test.go
+++ b/pkg/cache/resource_node_test.go
@@ -58,7 +58,7 @@ func TestCohortLendable(t *testing.T) {
 		"example.com/gpu":  3,
 	}
 
-	lendable := calculateLendable(cache.hm.Cohorts["test-cohort"])
+	lendable := calculateLendable(cache.hm.Cohort("test-cohort"))
 	if diff := cmp.Diff(wantLendable, lendable); diff != "" {
 		t.Errorf("Unexpected cohort lendable (-want,+got):\n%s", diff)
 	}
diff --git a/pkg/cache/resource_test.go b/pkg/cache/resource_test.go
index 9babe43c9..b3ea2f7ac 100644
--- a/pkg/cache/resource_test.go
+++ b/pkg/cache/resource_test.go
@@ -379,9 +379,10 @@ func TestAvailable(t *testing.T) {
 			}
 			// before adding usage
 			{
-				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				for _, cq := range snapshot.ClusterQueues {
+				clusterQueues := snapshot.ClusterQueues()
+				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				for _, cq := range clusterQueues {
 					numFrs := len(cq.ResourceNode.Quotas)
 					gotAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
 					gotPotentiallyAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
@@ -402,11 +403,12 @@ func TestAvailable(t *testing.T) {
 			// add usage
 			{
 				for cqName, usage := range tc.usage {
-					snapshot.ClusterQueues[cqName].AddUsage(workload.Usage{Quota: usage})
+					snapshot.ClusterQueue(cqName).AddUsage(workload.Usage{Quota: usage})
 				}
-				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				for _, cq := range snapshot.ClusterQueues {
+				clusterQueues := snapshot.ClusterQueues()
+				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				for _, cq := range clusterQueues {
 					numFrs := len(cq.ResourceNode.Quotas)
 					gotAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
 					gotPotentiallyAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
@@ -426,11 +428,12 @@ func TestAvailable(t *testing.T) {
 			// remove usage
 			{
 				for cqName, usage := range tc.usage {
-					snapshot.ClusterQueues[cqName].removeUsage(workload.Usage{Quota: usage})
+					snapshot.ClusterQueue(cqName).removeUsage(workload.Usage{Quota: usage})
 				}
-				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(snapshot.ClusterQueues))
-				for _, cq := range snapshot.ClusterQueues {
+				clusterQueues := snapshot.ClusterQueues()
+				gotAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				gotPotentiallyAvailable := make(map[string]resources.FlavorResourceQuantities, len(clusterQueues))
+				for _, cq := range clusterQueues {
 					numFrs := len(cq.ResourceNode.Quotas)
 					gotAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
 					gotPotentiallyAvailable[cq.Name] = make(resources.FlavorResourceQuantities, numFrs)
diff --git a/pkg/cache/snapshot_test.go b/pkg/cache/snapshot_test.go
index d2bafbef1..36ab6bb0a 100644
--- a/pkg/cache/snapshot_test.go
+++ b/pkg/cache/snapshot_test.go
@@ -69,8 +69,9 @@ func TestSnapshot(t *testing.T) {
 					ReserveQuota(&kueue.Admission{ClusterQueue: "b"}).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{},
+					map[string]*ClusterQueueSnapshot{
 						"a": {
 							Name:                          "a",
 							NamespaceSelector:             labels.Everything(),
@@ -100,7 +101,7 @@ func TestSnapshot(t *testing.T) {
 							FairWeight: oneQuantity,
 						},
 					},
-				},
+				),
 			},
 		},
 		"inactive clusterQueues": {
@@ -127,9 +128,10 @@ func TestSnapshot(t *testing.T) {
 				utiltesting.MakeResourceFlavor("default").Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{},
-				},
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{},
+					map[string]*ClusterQueueSnapshot{},
+				),
 				ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 					"demand": utiltesting.MakeResourceFlavor("demand").
 						NodeLabel("a", "b").
@@ -226,11 +228,11 @@ func TestSnapshot(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"borrowing": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"a": {
 								Name:                          "a",
 								AllocatableResourceGeneration: 2,
@@ -354,7 +356,7 @@ func TestSnapshot(t *testing.T) {
 								Status:            active,
 							},
 						},
-					},
+					),
 					ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 						"demand":  utiltesting.MakeResourceFlavor("demand").NodeLabel("instance", "demand").Obj(),
 						"spot":    utiltesting.MakeResourceFlavor("spot").NodeLabel("instance", "spot").Obj(),
@@ -372,8 +374,9 @@ func TestSnapshot(t *testing.T) {
 					}).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{},
+					map[string]*ClusterQueueSnapshot{
 						"with-preemption": {
 							Name:                          "with-preemption",
 							NamespaceSelector:             labels.Everything(),
@@ -388,7 +391,7 @@ func TestSnapshot(t *testing.T) {
 							FairWeight: oneQuantity,
 						},
 					},
-				},
+				),
 			},
 		},
 		"clusterQueue with fair sharing weight": {
@@ -396,8 +399,9 @@ func TestSnapshot(t *testing.T) {
 				utiltesting.MakeClusterQueue("with-preemption").FairWeight(resource.MustParse("3")).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{},
+					map[string]*ClusterQueueSnapshot{
 						"with-preemption": {
 							Name:                          "with-preemption",
 							NamespaceSelector:             labels.Everything(),
@@ -409,7 +413,7 @@ func TestSnapshot(t *testing.T) {
 							FairWeight:                    resource.MustParse("3"),
 						},
 					},
-				},
+				),
 			},
 		},
 		"lendingLimit with 2 clusterQueues and 2 flavors(whenCanBorrow: Borrow)": {
@@ -471,11 +475,11 @@ func TestSnapshot(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lending": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"a": {
 								Name:                          "a",
 								AllocatableResourceGeneration: 2,
@@ -557,7 +561,7 @@ func TestSnapshot(t *testing.T) {
 								Status:            active,
 							},
 						},
-					},
+					),
 					ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 						"arm": utiltesting.MakeResourceFlavor("arm").NodeLabel("arch", "arm").Obj(),
 						"x86": utiltesting.MakeResourceFlavor("x86").NodeLabel("arch", "x86").Obj(),
@@ -626,11 +630,11 @@ func TestSnapshot(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lending": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"a": {
 								Name:                          "a",
 								AllocatableResourceGeneration: 2,
@@ -711,7 +715,7 @@ func TestSnapshot(t *testing.T) {
 								Status:            active,
 							},
 						},
-					},
+					),
 					ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 						"arm": utiltesting.MakeResourceFlavor("arm").NodeLabel("arch", "arm").Obj(),
 						"x86": utiltesting.MakeResourceFlavor("x86").NodeLabel("arch", "x86").Obj(),
@@ -745,8 +749,26 @@ func TestSnapshot(t *testing.T) {
 					).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{
+						"cohort": {
+							Name: "cohort",
+							ResourceNode: ResourceNode{
+								Quotas: map[resources.FlavorResource]ResourceQuota{
+									{Flavor: "arm", Resource: corev1.ResourceCPU}:  {Nominal: 10_000, BorrowingLimit: nil, LendingLimit: nil},
+									{Flavor: "x86", Resource: corev1.ResourceCPU}:  {Nominal: 20_000, BorrowingLimit: nil, LendingLimit: nil},
+									{Flavor: "mips", Resource: corev1.ResourceCPU}: {Nominal: 42_000, BorrowingLimit: nil, LendingLimit: nil},
+								},
+								SubtreeQuota: resources.FlavorResourceQuantities{
+									{Flavor: "arm", Resource: corev1.ResourceCPU}:  13_000,
+									{Flavor: "x86", Resource: corev1.ResourceCPU}:  25_000,
+									{Flavor: "mips", Resource: corev1.ResourceCPU}: 42_000,
+								},
+							},
+							FairWeight: oneQuantity,
+						},
+					},
+					map[string]*ClusterQueueSnapshot{
 						"cq": {
 							Name:                          "cq",
 							AllocatableResourceGeneration: 2,
@@ -773,25 +795,7 @@ func TestSnapshot(t *testing.T) {
 							Status:            active,
 						},
 					},
-					Cohorts: map[string]*CohortSnapshot{
-						"cohort": {
-							Name: "cohort",
-							ResourceNode: ResourceNode{
-								Quotas: map[resources.FlavorResource]ResourceQuota{
-									{Flavor: "arm", Resource: corev1.ResourceCPU}:  {Nominal: 10_000, BorrowingLimit: nil, LendingLimit: nil},
-									{Flavor: "x86", Resource: corev1.ResourceCPU}:  {Nominal: 20_000, BorrowingLimit: nil, LendingLimit: nil},
-									{Flavor: "mips", Resource: corev1.ResourceCPU}: {Nominal: 42_000, BorrowingLimit: nil, LendingLimit: nil},
-								},
-								SubtreeQuota: resources.FlavorResourceQuantities{
-									{Flavor: "arm", Resource: corev1.ResourceCPU}:  13_000,
-									{Flavor: "x86", Resource: corev1.ResourceCPU}:  25_000,
-									{Flavor: "mips", Resource: corev1.ResourceCPU}: 42_000,
-								},
-							},
-							FairWeight: oneQuantity,
-						},
-					},
-				},
+				),
 				ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 					"arm":  utiltesting.MakeResourceFlavor("arm").Obj(),
 					"x86":  utiltesting.MakeResourceFlavor("x86").Obj(),
@@ -832,8 +836,19 @@ func TestSnapshot(t *testing.T) {
 					).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					ClusterQueues: map[string]*ClusterQueueSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{
+						"nocycle": {
+							Name: "nocycle",
+							ResourceNode: ResourceNode{
+								SubtreeQuota: resources.FlavorResourceQuantities{
+									{Flavor: "arm", Resource: corev1.ResourceCPU}: 0,
+								},
+							},
+							FairWeight: oneQuantity,
+						},
+					},
+					map[string]*ClusterQueueSnapshot{
 						"cq-nocycle": {
 							Name:                          "cq-nocycle",
 							AllocatableResourceGeneration: 2,
@@ -858,18 +873,7 @@ func TestSnapshot(t *testing.T) {
 							Status:            active,
 						},
 					},
-					Cohorts: map[string]*CohortSnapshot{
-						"nocycle": {
-							Name: "nocycle",
-							ResourceNode: ResourceNode{
-								SubtreeQuota: resources.FlavorResourceQuantities{
-									{Flavor: "arm", Resource: corev1.ResourceCPU}: 0,
-								},
-							},
-							FairWeight: oneQuantity,
-						},
-					},
-				},
+				),
 				InactiveClusterQueueSets: sets.New("cq-autocycle", "cq-a", "cq-b"),
 				ResourceFlavors: map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{
 					"arm": utiltesting.MakeResourceFlavor("arm").Obj(),
@@ -881,14 +885,15 @@ func TestSnapshot(t *testing.T) {
 				utiltesting.MakeCohort("cohort").FairWeight(resource.MustParse("0.5")).Obj(),
 			},
 			wantSnapshot: Snapshot{
-				Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-					Cohorts: map[string]*CohortSnapshot{
+				Manager: hierarchy.NewManagerForTest(
+					map[string]*CohortSnapshot{
 						"cohort": {
 							Name:       "cohort",
 							FairWeight: resource.MustParse("0.5"),
 						},
 					},
-				},
+					map[string]*ClusterQueueSnapshot{},
+				),
 			},
 		},
 	}
@@ -923,7 +928,7 @@ func TestSnapshot(t *testing.T) {
 			if diff := cmp.Diff(tc.wantSnapshot, *snapshot, snapCmpOpts...); len(diff) != 0 {
 				t.Errorf("Unexpected Snapshot (-want,+got):\n%s", diff)
 			}
-			for _, cq := range snapshot.ClusterQueues {
+			for _, cq := range snapshot.ClusterQueues() {
 				for i := range cq.ResourceGroups {
 					rg := &cq.ResourceGroups[i]
 					for rName := range rg.CoveredResources {
@@ -997,7 +1002,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 		}
 	}
 	wlInfos := make(map[string]*workload.Info, len(workloads))
-	for _, cq := range cqCache.hm.ClusterQueues {
+	for _, cq := range cqCache.hm.ClusterQueues() {
 		for _, wl := range cq.Workloads {
 			wlInfos[workload.Key(wl.Obj)] = wl
 		}
@@ -1006,7 +1011,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	initialCohortResources := initialSnapshot.ClusterQueues["c1"].Parent().ResourceNode.SubtreeQuota
+	initialCohortResources := initialSnapshot.ClusterQueue("c1").Parent().ResourceNode.SubtreeQuota
 	cases := map[string]struct {
 		remove []string
 		add    []string
@@ -1032,15 +1037,15 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"cohort": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"c1": {
 								Name:              "c1",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["c1"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("c1").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1059,7 +1064,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 							"c2": {
 								Name:                          "c2",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["c2"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("c2").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1073,7 +1078,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1092,18 +1097,18 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"cohort": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"c1": {
 								Name: "c1",
 								Workloads: map[string]*workload.Info{
 									"/c1-memory-alpha": nil,
 									"/c1-memory-beta":  nil,
 								},
-								ResourceGroups:    cqCache.hm.ClusterQueues["c1"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("c1").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1125,7 +1130,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 									"/c2-cpu-1": nil,
 									"/c2-cpu-2": nil,
 								},
-								ResourceGroups:                cqCache.hm.ClusterQueues["c2"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("c2").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1139,7 +1144,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1158,18 +1163,18 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"cohort": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"c1": {
 								Name: "c1",
 								Workloads: map[string]*workload.Info{
 									"/c1-memory-alpha": nil,
 									"/c1-memory-beta":  nil,
 								},
-								ResourceGroups:    cqCache.hm.ClusterQueues["c1"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("c1").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1191,7 +1196,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 									"/c2-cpu-1": nil,
 									"/c2-cpu-2": nil,
 								},
-								ResourceGroups:    cqCache.hm.ClusterQueues["c2"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("c2").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1204,7 +1209,7 @@ func TestSnapshotAddRemoveWorkload(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1291,7 +1296,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 		}
 	}
 	wlInfos := make(map[string]*workload.Info, len(workloads))
-	for _, cq := range cqCache.hm.ClusterQueues {
+	for _, cq := range cqCache.hm.ClusterQueues() {
 		for _, wl := range cq.Workloads {
 			wlInfos[workload.Key(wl.Obj)] = wl
 		}
@@ -1300,7 +1305,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	initialCohortResources := initialSnapshot.ClusterQueues["lend-a"].Parent().ResourceNode.SubtreeQuota
+	initialCohortResources := initialSnapshot.ClusterQueue("lend-a").Parent().ResourceNode.SubtreeQuota
 	cases := map[string]struct {
 		remove []string
 		add    []string
@@ -1324,15 +1329,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1347,7 +1352,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:              "lend-b",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1360,7 +1365,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1377,15 +1382,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1400,7 +1405,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:                          "lend-b",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1414,7 +1419,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1431,15 +1436,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1454,7 +1459,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:                          "lend-b",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1468,7 +1473,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1485,15 +1490,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1508,7 +1513,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:                          "lend-b",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1522,7 +1527,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1540,15 +1545,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1563,7 +1568,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:                          "lend-b",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1577,7 +1582,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1595,15 +1600,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1618,7 +1623,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:              "lend-b",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1631,7 +1636,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
@@ -1649,15 +1654,15 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 					},
 				}
 				return Snapshot{
-					Manager: hierarchy.Manager[*ClusterQueueSnapshot, *CohortSnapshot]{
-						Cohorts: map[string]*CohortSnapshot{
+					Manager: hierarchy.NewManagerForTest(
+						map[string]*CohortSnapshot{
 							"lend": cohort,
 						},
-						ClusterQueues: map[string]*ClusterQueueSnapshot{
+						map[string]*ClusterQueueSnapshot{
 							"lend-a": {
 								Name:              "lend-a",
 								Workloads:         make(map[string]*workload.Info),
-								ResourceGroups:    cqCache.hm.ClusterQueues["lend-a"].ResourceGroups,
+								ResourceGroups:    cqCache.hm.ClusterQueue("lend-a").ResourceGroups,
 								FlavorFungibility: defaultFlavorFungibility,
 								FairWeight:        oneQuantity,
 								ResourceNode: ResourceNode{
@@ -1672,7 +1677,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 							"lend-b": {
 								Name:                          "lend-b",
 								Workloads:                     make(map[string]*workload.Info),
-								ResourceGroups:                cqCache.hm.ClusterQueues["lend-b"].ResourceGroups,
+								ResourceGroups:                cqCache.hm.ClusterQueue("lend-b").ResourceGroups,
 								FlavorFungibility:             defaultFlavorFungibility,
 								FairWeight:                    oneQuantity,
 								AllocatableResourceGeneration: 1,
@@ -1686,7 +1691,7 @@ func TestSnapshotAddRemoveWorkloadWithLendingLimit(t *testing.T) {
 								},
 							},
 						},
-					},
+					),
 				}
 			}(),
 		},
diff --git a/pkg/controller/admissionchecks/multikueue/multikueuecluster_test.go b/pkg/controller/admissionchecks/multikueue/multikueuecluster_test.go
index f93dddf30..af0810a09 100644
--- a/pkg/controller/admissionchecks/multikueue/multikueuecluster_test.go
+++ b/pkg/controller/admissionchecks/multikueue/multikueuecluster_test.go
@@ -379,7 +379,7 @@ func TestUpdateConfig(t *testing.T) {
 
 			adapters, _ := jobframework.GetMultiKueueAdapters(sets.New("batch/job"))
 			reconciler := newClustersReconciler(c, TestNamespace, 0, defaultOrigin, nil, adapters)
-			//nolint:fatcontext // false positive
+
 			reconciler.rootContext = ctx
 
 			if len(tc.remoteClients) > 0 {
diff --git a/pkg/controller/core/cohort_controller_test.go b/pkg/controller/core/cohort_controller_test.go
index f68ce06c9..0a3932b6c 100644
--- a/pkg/controller/core/cohort_controller_test.go
+++ b/pkg/controller/core/cohort_controller_test.go
@@ -47,7 +47,7 @@ func TestCohortReconcileCohortNotFoundDelete(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; !ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap == nil {
 		t.Fatal("expected Cohort in snapshot")
 	}
 
@@ -62,7 +62,7 @@ func TestCohortReconcileCohortNotFoundDelete(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap != nil {
 		t.Fatal("unexpected Cohort in snapshot")
 	}
 }
@@ -79,7 +79,7 @@ func TestCohortReconcileCohortNotFoundIdempotentDelete(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap != nil {
 		t.Fatal("unexpected Cohort in snapshot")
 	}
 
@@ -95,7 +95,7 @@ func TestCohortReconcileCohortNotFoundIdempotentDelete(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap != nil {
 		t.Fatal("unexpected Cohort in snapshot")
 	}
 }
@@ -162,7 +162,7 @@ func TestCohortReconcileErrorOtherThanNotFoundNotDeleted(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; !ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap == nil {
 		t.Fatal("expected Cohort in snapshot")
 	}
 
@@ -177,7 +177,7 @@ func TestCohortReconcileErrorOtherThanNotFoundNotDeleted(t *testing.T) {
 	if err != nil {
 		t.Fatalf("unexpected error while building snapshot: %v", err)
 	}
-	if _, ok := snapshot.Cohorts["cohort"]; !ok {
+	if cohortSnap := snapshot.Cohort("cohort"); cohortSnap == nil {
 		t.Fatal("expected Cohort in snapshot")
 	}
 }
@@ -205,8 +205,8 @@ func TestCohortReconcileLifecycle(t *testing.T) {
 		if err != nil {
 			t.Fatalf("unexpected error while building snapshot: %v", err)
 		}
-		cohortSnap, ok := snapshot.Cohorts["cohort"]
-		if !ok {
+		cohortSnap := snapshot.Cohort("cohort")
+		if cohortSnap == nil {
 			t.Fatal("expected Cohort in snapshot")
 		}
 
@@ -240,8 +240,8 @@ func TestCohortReconcileLifecycle(t *testing.T) {
 		if err != nil {
 			t.Fatalf("unexpected error while building snapshot: %v", err)
 		}
-		cohortSnap, ok := snapshot.Cohorts["cohort"]
-		if !ok {
+		cohortSnap := snapshot.Cohort("cohort")
+		if cohortSnap == nil {
 			t.Fatal("expected Cohort in snapshot")
 		}
 
@@ -269,7 +269,7 @@ func TestCohortReconcileLifecycle(t *testing.T) {
 		if err != nil {
 			t.Fatalf("unexpected error while building snapshot: %v", err)
 		}
-		if _, ok := snapshot.Cohorts["cohort"]; ok {
+		if cohortSnap := snapshot.Cohort("cohort"); cohortSnap != nil {
 			t.Fatal("unexpected Cohort in snapshot")
 		}
 	}
diff --git a/pkg/hierarchy/manager_test.go b/pkg/hierarchy/manager_test.go
index e77e0e4cb..b6062c3d8 100644
--- a/pkg/hierarchy/manager_test.go
+++ b/pkg/hierarchy/manager_test.go
@@ -327,7 +327,7 @@ func TestManager(t *testing.T) {
 			t.Run("verify clusterqueues", func(t *testing.T) {
 				gotCqs := sets.New[string]()
 				gotEdges := make([]edge, 0, len(tc.wantCqEdge))
-				for _, cq := range mgr.ClusterQueues {
+				for _, cq := range mgr.ClusterQueues() {
 					gotCqs.Insert(cq.GetName())
 					if cq.HasParent() {
 						gotEdges = append(gotEdges, edge{cq.GetName(), cq.Parent().GetName()})
@@ -345,7 +345,7 @@ func TestManager(t *testing.T) {
 				gotCqEdges := make([]edge, 0, len(tc.wantCqEdge))
 				gotCohortChildEdges := make([]edge, 0, len(tc.wantCohortEdge))
 				gotCohortParentEdges := make([]edge, 0, len(tc.wantCohortEdge))
-				for _, cohort := range mgr.Cohorts {
+				for _, cohort := range mgr.Cohorts() {
 					gotCohorts.Insert(cohort.GetName())
 					for _, cq := range cohort.ChildCQs() {
 						gotCqEdges = append(gotCqEdges, edge{cq.GetName(), cohort.GetName()})
@@ -408,7 +408,7 @@ func TestCycles(t *testing.T) {
 				m.AddCohort("root")
 				m.UpdateCohortEdge("root", "root")
 				// we call HasCycle to test invalidation
-				m.CycleChecker.HasCycle(m.Cohorts["root"])
+				m.CycleChecker.HasCycle(m.Cohort("root"))
 				m.UpdateCohortEdge("root", "")
 			},
 			wantCycles: map[string]bool{
@@ -435,7 +435,7 @@ func TestCycles(t *testing.T) {
 				m.UpdateCohortEdge("cohort-b", "cohort-a")
 
 				// we call HasCycle to test invalidation
-				m.CycleChecker.HasCycle(m.Cohorts["cohort-a"])
+				m.CycleChecker.HasCycle(m.Cohort("cohort-a"))
 
 				m.UpdateCohortEdge("cohort-a", "cohort-c")
 			},
@@ -451,7 +451,7 @@ func TestCycles(t *testing.T) {
 				m.AddCohort("cohort-b")
 				m.UpdateCohortEdge("cohort-a", "cohort-b")
 				m.UpdateCohortEdge("cohort-b", "cohort-a")
-				m.CycleChecker.HasCycle(m.Cohorts["cohort-a"])
+				m.CycleChecker.HasCycle(m.Cohort("cohort-a"))
 
 				m.UpdateCohortEdge("cohort-a", "")
 			},
@@ -466,7 +466,7 @@ func TestCycles(t *testing.T) {
 				m.AddCohort("cohort-b")
 				m.UpdateCohortEdge("cohort-a", "cohort-b")
 				m.UpdateCohortEdge("cohort-b", "cohort-a")
-				m.CycleChecker.HasCycle(m.Cohorts["cohort-a"])
+				m.CycleChecker.HasCycle(m.Cohort("cohort-a"))
 				m.DeleteCohort("cohort-b")
 			},
 			wantCycles: map[string]bool{
@@ -480,7 +480,7 @@ func TestCycles(t *testing.T) {
 		t.Run(name, func(t *testing.T) {
 			mgr := NewManager(newCohort)
 			tc.operations(mgr)
-			for _, cohort := range mgr.Cohorts {
+			for _, cohort := range mgr.Cohorts() {
 				got := mgr.CycleChecker.HasCycle(cohort)
 				if got != tc.wantCycles[cohort.GetName()] {
 					t.Errorf("-want +got: %v %v", tc.wantCycles[cohort.GetName()], got)
diff --git a/pkg/queue/manager_test.go b/pkg/queue/manager_test.go
index 730decea8..309fca891 100644
--- a/pkg/queue/manager_test.go
+++ b/pkg/queue/manager_test.go
@@ -118,7 +118,7 @@ func TestAddClusterQueueOrphans(t *testing.T) {
 	if err := manager.AddClusterQueue(ctx, cq); err != nil {
 		t.Fatalf("Could not re-add ClusterQueue: %v", err)
 	}
-	workloads := popNamesFromCQ(manager.hm.ClusterQueues["cq"])
+	workloads := popNamesFromCQ(manager.hm.ClusterQueue("cq"))
 	wantWorkloads := []string{"/b", "/a"}
 	if diff := cmp.Diff(wantWorkloads, workloads); diff != "" {
 		t.Errorf("Workloads popped in the wrong order from clusterQueue:\n%s", diff)
@@ -191,7 +191,7 @@ func TestUpdateClusterQueue(t *testing.T) {
 		"alpha": sets.New("cq1", "cq2"),
 	}
 	gotCohorts := make(map[string]sets.Set[string])
-	for name, cohort := range manager.hm.Cohorts {
+	for name, cohort := range manager.hm.Cohorts() {
 		gotCohorts[name] = sets.New[string]()
 		for _, cq := range cohort.ChildCQs() {
 			gotCohorts[name].Insert(cq.GetName())
@@ -249,7 +249,7 @@ func TestRequeueWorkloadsCohortCycle(t *testing.T) {
 
 	// This method is where we do a cycle check. We call it to ensure
 	// it behaves properly when a cycle exists
-	if manager.requeueWorkloadsCohort(ctx, manager.hm.Cohorts["cohort-a"]) {
+	if manager.requeueWorkloadsCohort(ctx, manager.hm.Cohort("cohort-a")) {
 		t.Fatal("Expected moveWorkloadsCohort to return false")
 	}
 }
@@ -359,7 +359,7 @@ func TestUpdateLocalQueue(t *testing.T) {
 
 	// Verification.
 	workloadOrders := make(map[string][]string)
-	for name, cq := range manager.hm.ClusterQueues {
+	for name, cq := range manager.hm.ClusterQueues() {
 		workloadOrders[name] = popNamesFromCQ(cq)
 	}
 	wantWorkloadOrders := map[string][]string{
@@ -827,7 +827,7 @@ func TestUpdateWorkload(t *testing.T) {
 				} else if diff := cmp.Diff(wl, item.Obj); diff != "" {
 					t.Errorf("Object stored in queue differs (-want,+got):\n%s", diff)
 				}
-				cq := manager.hm.ClusterQueues[q.ClusterQueue]
+				cq := manager.hm.ClusterQueue(q.ClusterQueue)
 				if cq != nil {
 					item := cq.Info(key)
 					if item == nil {
@@ -838,7 +838,7 @@ func TestUpdateWorkload(t *testing.T) {
 				}
 			}
 			queueOrder := make(map[string][]string)
-			for name, cq := range manager.hm.ClusterQueues {
+			for name, cq := range manager.hm.ClusterQueues() {
 				queueOrder[name] = popNamesFromCQ(cq)
 			}
 			if diff := cmp.Diff(tc.wantQueueOrder, queueOrder); diff != "" {
diff --git a/pkg/scheduler/flavorassigner/flavorassigner_test.go b/pkg/scheduler/flavorassigner/flavorassigner_test.go
index 4ebf32cef..b9595e0eb 100644
--- a/pkg/scheduler/flavorassigner/flavorassigner_test.go
+++ b/pkg/scheduler/flavorassigner/flavorassigner_test.go
@@ -1961,7 +1961,7 @@ func TestAssignFlavors(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			clusterQueue := snapshot.ClusterQueues[tc.clusterQueue.Name]
+			clusterQueue := snapshot.ClusterQueue(tc.clusterQueue.Name)
 
 			if clusterQueue == nil {
 				t.Fatalf("Failed to create CQ snapshot")
@@ -1971,7 +1971,7 @@ func TestAssignFlavors(t *testing.T) {
 			}
 
 			if tc.secondaryClusterQueue != nil {
-				secondaryClusterQueue := snapshot.ClusterQueues[tc.secondaryClusterQueue.Name]
+				secondaryClusterQueue := snapshot.ClusterQueue(tc.secondaryClusterQueue.Name)
 				if secondaryClusterQueue == nil {
 					t.Fatalf("Failed to create secondary CQ snapshot")
 				}
@@ -2124,10 +2124,10 @@ func TestReclaimBeforePriorityPreemption(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			otherClusterQueue := snapshot.ClusterQueues["other-clusterqueue"]
+			otherClusterQueue := snapshot.ClusterQueue("other-clusterqueue")
 			otherClusterQueue.AddUsage(workload.Usage{Quota: tc.otherClusterQueueUsage})
 
-			testClusterQueue := snapshot.ClusterQueues["test-clusterqueue"]
+			testClusterQueue := snapshot.ClusterQueue("test-clusterqueue")
 			testClusterQueue.AddUsage(workload.Usage{Quota: tc.testClusterQueueUsage})
 
 			flvAssigner := New(wlInfo, testClusterQueue, resourceFlavors, false, &testOracle{})
@@ -2252,7 +2252,7 @@ func TestDeletedFlavors(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			clusterQueue := snapshot.ClusterQueues[tc.clusterQueue.Name]
+			clusterQueue := snapshot.ClusterQueue(tc.clusterQueue.Name)
 			if clusterQueue == nil {
 				t.Fatalf("Failed to create CQ snapshot")
 			}
diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go
index e5f928794..e42b8ce27 100644
--- a/pkg/scheduler/scheduler_test.go
+++ b/pkg/scheduler/scheduler_test.go
@@ -2659,7 +2659,7 @@ func TestSchedule(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			for cqName, c := range snapshot.ClusterQueues {
+			for cqName, c := range snapshot.ClusterQueues() {
 				for name, w := range c.Workloads {
 					gotWorkloads = append(gotWorkloads, *w.Obj)
 					switch {
@@ -3466,7 +3466,7 @@ func TestLastSchedulingContext(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			for cqName, c := range snapshot.ClusterQueues {
+			for cqName, c := range snapshot.ClusterQueues() {
 				for name, w := range c.Workloads {
 					switch {
 					case !workload.IsAdmitted(w.Obj):
@@ -3815,7 +3815,7 @@ func TestResourcesToReserve(t *testing.T) {
 			if err != nil {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
-			cqSnapshot := snapshot.ClusterQueues["cq"]
+			cqSnapshot := snapshot.ClusterQueue("cq")
 
 			got := resourcesToReserve(e, cqSnapshot)
 			if !reflect.DeepEqual(tc.wantReserved, got.Quota) {
@@ -5073,7 +5073,7 @@ func TestScheduleForTAS(t *testing.T) {
 				t.Fatalf("unexpected error while building snapshot: %v", err)
 			}
 			gotAssignments := make(map[string]kueue.Admission)
-			for cqName, c := range snapshot.ClusterQueues {
+			for cqName, c := range snapshot.ClusterQueues() {
 				for name, w := range c.Workloads {
 					if initiallyAdmittedWorkloads.Has(workload.Key(w.Obj)) {
 						continue
@@ -5645,7 +5645,7 @@ func TestScheduleForTASPreemption(t *testing.T) {
 				t.Errorf("Unexpected preemptions (-want,+got):\n%s", diff)
 			}
 			gotAssignments := make(map[string]kueue.Admission)
-			for cqName, c := range snapshot.ClusterQueues {
+			for cqName, c := range snapshot.ClusterQueues() {
 				for name, w := range c.Workloads {
 					if initiallyAdmittedWorkloads.Has(workload.Key(w.Obj)) {
 						continue