Repository: kubernetes-sigs/kueue

Issue:
Unexport access to Cohorts and ClusterQueues maps in hierarchy.Manager
**What would you like to be cleaned**:
https://github.com/kubernetes-sigs/kueue/blob/be27bb83d087783d7a227e2068bb874110ac9580/pkg/hierarchy/manager.go#L22-L23

**Why is this needed**:
Current requires callers to avoid modifying this map, outside of using the Manager's add/delete methods. See https://github.com/kubernetes-sigs/kueue/pull/2971#discussion_r1745385475

Hints from issue comments:
@gabesaba: /assign@k8s-triage-robot: The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle stale`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle stale

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/@k8s-triage-robot: The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity, `lifecycle/stale` is applied
- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied
- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed

You can:
- Mark this issue as fresh with `/remove-lifecycle rotten`
- Close this issue with `/close`
- Offer to help out with [Issue Triage][1]

Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community).

/lifecycle rotten

[1]: https://www.kubernetes.dev/docs/guide/issue-triage/@tenzen-y: /remove-lifecycle rotten@gabesaba: /unassign@nasedil: /assign

Solution patch:
diff --git a/hack/internal/tools/go.mod b/hack/internal/tools/go.mod
index bdc6f4e47..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
@@ -15,7 +15,7 @@ require (
 	k8s.io/code-generator v0.32.2
 	sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240813183042-b901db121e1f
 	sigs.k8s.io/controller-tools v0.17.1
-	sigs.k8s.io/kind v0.26.0
+	sigs.k8s.io/kind v0.27.0
 	sigs.k8s.io/kustomize/kustomize/v5 v5.6.0
 	sigs.k8s.io/mdtoc v1.4.0
 )
@@ -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 d228c634a..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=
@@ -427,8 +428,8 @@ sigs.k8s.io/controller-tools v0.17.1 h1:bQ+dKCS7jY9AgpefenBDtm6geJZCHVKbegpLynxg
 sigs.k8s.io/controller-tools v0.17.1/go.mod h1:3QXAdrmdxYuQ4MifvbCAFD9wLXn7jylnfBPYS4yVDdc=
 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
 sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
-sigs.k8s.io/kind v0.26.0 h1:8fS6I0Q5WGlmLprSpH0DarlOSdcsv0txnwc93J2BP7M=
-sigs.k8s.io/kind v0.26.0/go.mod h1:t7ueEpzPYJvHA8aeLtI52rtFftNgUYUaCwvxjk7phfw=
+sigs.k8s.io/kind v0.27.0 h1:PQ3f0iAWNIj66LYkZ1ivhEg/+Zb6UPMbO+qVei/INZA=
+sigs.k8s.io/kind v0.27.0/go.mod h1:RZVFmy6qcwlSWwp6xeIUv7kXCPF3i8MXsEXxW/J+gJY=
 sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ=
 sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o=
 sigs.k8s.io/kustomize/kustomize/v5 v5.6.0 h1:MWtRRDWCwQEeW2rnJTqJMuV6Agy56P53SkbVoJpN7wA=
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/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