@@ -49,6 +49,10 @@ func (h *statusHandler) OnUpdate(c client.Client, decoder admission.Decoder, rec
49
49
}
50
50
51
51
func (h * statusHandler ) calculate (ctx context.Context , c client.Client , decoder admission.Decoder , recorder record.EventRecorder , req admission.Request ) * admission.Response {
52
+ h .log .V (3 ).Info ("loggign request" , "REQUEST" , req )
53
+
54
+ return utils .ErroredResponse (fmt .Errorf ("meowie" ))
55
+
52
56
// Decode the incoming object
53
57
quota := & corev1.ResourceQuota {}
54
58
if err := decoder .Decode (req , quota ); err != nil {
@@ -61,7 +65,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
61
65
return utils .ErroredResponse (fmt .Errorf ("failed to decode old ResourceQuota object: %w" , err ))
62
66
}
63
67
64
- h .log .V (5 ).Info ("loggign request" , "REQUEST" , req )
68
+ h .log .V (3 ).Info ("loggign request" , "REQUEST" , req )
65
69
66
70
// Get Item within Resource Quota
67
71
indexLabel := capsuleutils .GetGlobalResourceQuotaTypeLabel ()
@@ -83,7 +87,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
83
87
84
88
// Skip if quota not active
85
89
if ! globalQuota .Spec .Active {
86
- h .log .V (5 ).Info ("GlobalQuota is not active" , "quota" , globalQuota .Name )
90
+ h .log .V (3 ).Info ("GlobalQuota is not active" , "quota" , globalQuota .Name )
87
91
88
92
return nil
89
93
}
@@ -117,12 +121,20 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
117
121
tenantUsed = corev1.ResourceList {}
118
122
}
119
123
120
- h .log .V (5 ).Info ("Available space calculated" , "space" , availableSpace )
124
+ h .log .V (3 ).Info ("Available space calculated" , "space" , availableSpace )
121
125
122
126
// Process each resource and enforce allocation limits
123
127
for resourceName , avail := range availableSpace {
124
128
rlog := h .log .WithValues ("resource" , resourceName )
125
129
130
+ rlog .V (3 ).Info ("AVAILABLE" , "avail" , avail , "USED" , tenantUsed [resourceName ], "HARD" , tenantQuota .Hard [resourceName ])
131
+
132
+ if avail .Cmp (zero ) == 0 {
133
+ rlog .V (3 ).Info ("NO SPACE AVAILABLE" )
134
+ quota .Status .Hard [resourceName ] = oldQuota .Status .Hard [resourceName ]
135
+ continue
136
+ }
137
+
126
138
// Get From the status whet's currently Used
127
139
var globalUsage resource.Quantity
128
140
if currentUsed , exists := tenantUsed [resourceName ]; exists {
@@ -148,7 +160,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
148
160
diff := newRequested .DeepCopy ()
149
161
diff .Sub (oldAllocated )
150
162
151
- rlog .V (5 ).Info ("calculate ingestion" , "diff" , diff , "old" , oldAllocated , "new" , newRequested )
163
+ rlog .V (3 ).Info ("calculate ingestion" , "diff" , diff , "old" , oldAllocated , "new" , newRequested )
152
164
153
165
// Compare how the newly ingested resources compare against empty resources
154
166
// This is the quickest way to find out, how the status must be updated
@@ -160,7 +172,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
160
172
continue
161
173
// Resource Consumtion Increased
162
174
case stat > 0 :
163
- rlog .V (5 ).Info ("increase" )
175
+ rlog .V (3 ).Info ("increase" )
164
176
// Validate Space
165
177
// Overprovisioned, allocate what's left
166
178
if avail .Cmp (diff ) < 0 {
@@ -173,7 +185,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
173
185
174
186
//oldAllocated.Add(avail)
175
187
rlog .V (5 ).Info ("PREVENT OVERPROVISING" , "allocation" , oldAllocated )
176
- quota .Status .Hard [resourceName ] = oldAllocated
188
+ quota .Status .Hard [resourceName ] = oldQuota . Status . Hard [ resourceName ]
177
189
178
190
} else {
179
191
// Adding, since requested resources have space
@@ -185,7 +197,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
185
197
}
186
198
// Resource Consumption decreased
187
199
default :
188
- rlog .V (5 ).Info ("negate" )
200
+ rlog .V (3 ).Info ("negate" )
189
201
// SUbstract Difference from available
190
202
// Negative values also combine correctly with the Add() operation
191
203
globalUsage .Add (diff )
@@ -197,9 +209,7 @@ func (h *statusHandler) calculate(ctx context.Context, c client.Client, decoder
197
209
}
198
210
}
199
211
200
- rlog .V (5 ).Info ("calculate ingestion" , "diff" , diff , "usage" , avail , "usage" , globalUsage )
201
-
202
- rlog .V (5 ).Info ("caclulated total usage" , "global" , globalUsage , "requested" , quota .Status .Used [resourceName ])
212
+ rlog .V (3 ).Info ("caclulated total usage" , "global" , globalUsage , "diff" , diff , "usage" , avail , "hard" , quota .Status .Hard [resourceName ], "usage" , quota .Status .Used [resourceName ])
203
213
tenantUsed [resourceName ] = globalUsage
204
214
}
205
215
0 commit comments