@@ -65,6 +65,8 @@ func (r *HierarchicalResourceQuotaReconciler) Reconcile(ctx context.Context, req
65
65
return ctrl.Result {}, err
66
66
}
67
67
68
+ log .Info ("Reconciling HRQ" , "name" , req .NamespacedName .Name , "namespace" , req .NamespacedName .Namespace , "Hard" , inst .Spec .Hard , "scopeSelector" , inst .Spec .ScopeSelector )
69
+
68
70
// If an object is deleted, assign the name and namespace of the request to
69
71
// the object so that they can be used to sync with the forest.
70
72
if isDeleted (inst ) {
@@ -74,7 +76,7 @@ func (r *HierarchicalResourceQuotaReconciler) Reconcile(ctx context.Context, req
74
76
oldUsages := inst .Status .Used
75
77
76
78
// Sync with forest to update the HRQ or the in-memory forest.
77
- updatedInst , updatedForest , err := r .syncWithForest (inst )
79
+ updatedInst , updatedForest , err := r .syncWithForest (log , inst )
78
80
if err != nil {
79
81
return ctrl.Result {}, err
80
82
}
@@ -109,7 +111,7 @@ func (r *HierarchicalResourceQuotaReconciler) Reconcile(ctx context.Context, req
109
111
// syncWithForest syncs resource limits and resource usages with the in-memory
110
112
// forest. The first return value is true if the HRQ object is updated; the
111
113
// second return value is true if the forest is updated.
112
- func (r * HierarchicalResourceQuotaReconciler ) syncWithForest (inst * api.HierarchicalResourceQuota ) (bool , bool , error ) {
114
+ func (r * HierarchicalResourceQuotaReconciler ) syncWithForest (log logr. Logger , inst * api.HierarchicalResourceQuota ) (bool , bool , error ) {
113
115
r .Forest .Lock ()
114
116
defer r .Forest .Unlock ()
115
117
@@ -118,10 +120,14 @@ func (r *HierarchicalResourceQuotaReconciler) syncWithForest(inst *api.Hierarchi
118
120
rqName := api .ResourceQuotaSingletonName
119
121
nn := types.NamespacedName {Name : inst .GetName (), Namespace : inst .GetNamespace ()}
120
122
if isScopedHRQ {
123
+ log .Info ("Marking HRQ as scoped" , "name" , inst .GetName (), "namespace" , inst .GetNamespace ())
121
124
r .Forest .MarkScopedRQ (nn )
122
125
rqName = utils .ScopedRQName (inst .GetName ())
123
126
} else if r .Forest .IsMarkedAsScopedHRQ (nn ) {
127
+ log .Info ("Detect the Scoped HRQ because of the mark" )
124
128
rqName = utils .ScopedRQName (inst .GetName ())
129
+ } else {
130
+ log .Info ("HRQ is a singleton" )
125
131
}
126
132
127
133
updatedInst := false
@@ -139,7 +145,11 @@ func (r *HierarchicalResourceQuotaReconciler) syncWithForest(inst *api.Hierarchi
139
145
}
140
146
141
147
// Update HRQ usages if they are changed.
142
- r .syncUsages (inst , rqName )
148
+ err = r .syncUsages (inst , rqName )
149
+ if err != nil {
150
+ return false , false , err
151
+ }
152
+
143
153
updatedInst = updatedInst || ! utils .Equals (oldUsages , inst .Status .Used )
144
154
145
155
return updatedInst , updatedForest , nil
0 commit comments