mirror of https://github.com/k3s-io/k3s
Avoid dropping resourcequota metadata in controller
parent
34196ac946
commit
fdd87a8872
|
@ -347,24 +347,17 @@ func (rq *ResourceQuotaController) syncResourceQuota(resourceQuota *v1.ResourceQ
|
||||||
|
|
||||||
// Create a usage object that is based on the quota resource version that will handle updates
|
// Create a usage object that is based on the quota resource version that will handle updates
|
||||||
// by default, we preserve the past usage observation, and set hard to the current spec
|
// by default, we preserve the past usage observation, and set hard to the current spec
|
||||||
usage := v1.ResourceQuota{
|
usage := resourceQuota.DeepCopy()
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
usage.Status = v1.ResourceQuotaStatus{
|
||||||
Name: resourceQuota.Name,
|
Hard: hardLimits,
|
||||||
Namespace: resourceQuota.Namespace,
|
Used: used,
|
||||||
ResourceVersion: resourceQuota.ResourceVersion,
|
|
||||||
Labels: resourceQuota.Labels,
|
|
||||||
Annotations: resourceQuota.Annotations},
|
|
||||||
Status: v1.ResourceQuotaStatus{
|
|
||||||
Hard: hardLimits,
|
|
||||||
Used: used,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dirty = dirty || !quota.Equals(usage.Status.Used, resourceQuota.Status.Used)
|
dirty = dirty || !quota.Equals(usage.Status.Used, resourceQuota.Status.Used)
|
||||||
|
|
||||||
// there was a change observed by this controller that requires we update quota
|
// there was a change observed by this controller that requires we update quota
|
||||||
if dirty {
|
if dirty {
|
||||||
_, err = rq.rqClient.ResourceQuotas(usage.Namespace).UpdateStatus(&usage)
|
_, err = rq.rqClient.ResourceQuotas(usage.Namespace).UpdateStatus(usage)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue