Skip to content

Commit e2ba73d

Browse files
committed
refactor(hrq): Simplify legacy scoped RQ check by removing annotation logic
1 parent 268e3f0 commit e2ba73d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

internal/hrq/utils/scopedhrq.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import (
1313
)
1414

1515
const (
16-
hrqNameLabel = "hnc.x-k8s.io/hrq-name"
17-
hrqNamespaceLabel = "hnc.x-k8s.io/hrq-namespace"
18-
newScopedRQAnnotation = "hnc.x-k8s.io/new-scoped-rq"
16+
hrqNameLabel = "hnc.x-k8s.io/hrq-name"
17+
hrqNamespaceLabel = "hnc.x-k8s.io/hrq-namespace"
1918
)
2019

2120
const (
@@ -48,10 +47,9 @@ func IsLegacyScopedRQ(rq *v1.ResourceQuota) bool {
4847
if !IsHNCManagedRQ(rq) {
4948
return false
5049
}
51-
if v, ok := metadata.GetAnnotation(rq, newScopedRQAnnotation); ok && v == "true" {
52-
return false
53-
}
54-
return true
50+
_, nsLabelFound := metadata.GetLabel(rq, hrqNamespaceLabel)
51+
_, nameLabelFound := metadata.GetLabel(rq, hrqNameLabel)
52+
return !nsLabelFound || !nameLabelFound
5553
}
5654

5755
// LegacyScopedRQName generates the legacy RQ name for backward compatibility
@@ -94,7 +92,6 @@ func ScopedHRQNameFromRQ(rq *v1.ResourceQuota) (types.NamespacedName, error) {
9492
func SetLabelsAnnotationsForScopedRQ(rq *v1.ResourceQuota, hrqNamespace string, hrqName string) {
9593
metadata.SetLabel(rq, hrqNamespaceLabel, hrqNamespace)
9694
metadata.SetLabel(rq, hrqNameLabel, hrqName)
97-
metadata.SetAnnotation(rq, newScopedRQAnnotation, "true")
9895
}
9996

10097
func truncate(s string, n int) string {

0 commit comments

Comments
 (0)