Skip to content

Commit

Permalink
Merge pull request #119 from ardaguclu/add-logs-to-track-quota
Browse files Browse the repository at this point in the history
Add logs for quota namespace syncing with verbosity level 2
  • Loading branch information
openshift-merge-robot committed Jul 11, 2023
2 parents cc787e1 + 0c14ec2 commit 3b6a995
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -164,6 +164,7 @@ func (c *ClusterQuotaReconcilationController) Sync(discoveryFunc resourcequota.N
// Get the current resource list from discovery.
newResources, err := resourcequota.GetQuotableResources(discoveryFunc)
if err != nil {
klog.V(2).Infof("error occurred GetQuotableResources err=%v", err)
utilruntime.HandleError(err)

if discovery.IsGroupDiscoveryFailedError(err) && len(newResources) > 0 {
Expand Down Expand Up @@ -231,13 +232,15 @@ func (c *ClusterQuotaReconcilationController) resyncMonitors(ctx context.Context

func (c *ClusterQuotaReconcilationController) calculate(quotaName string, namespaceNames ...string) {
if len(namespaceNames) == 0 {
klog.V(2).Infof("no namespace is passed for quota %s", quotaName)
return
}
items := make([]interface{}, 0, len(namespaceNames))
for _, name := range namespaceNames {
items = append(items, workItem{namespaceName: name, forceRecalculation: false})
}

klog.V(2).Infof("calculating items for quota %s with namespaces %v", quotaName, items)
c.queue.AddWithData(quotaName, items...)
}

Expand All @@ -250,6 +253,7 @@ func (c *ClusterQuotaReconcilationController) forceCalculation(quotaName string,
items = append(items, workItem{namespaceName: name, forceRecalculation: true})
}

klog.V(2).Infof("force calculating items for quota %s with namespaces %v", quotaName, items)
c.queue.AddWithData(quotaName, items...)
}

Expand All @@ -264,6 +268,7 @@ func (c *ClusterQuotaReconcilationController) calculateAll() {
// If we have namespaces we map to, force calculating those namespaces
namespaces, _ := c.clusterQuotaMapper.GetNamespacesFor(quota.Name)
if len(namespaces) > 0 {
klog.V(2).Infof("syncing quota %s with namespaces %v", quota.Name, namespaces)
c.forceCalculation(quota.Name, namespaces...)
continue
}
Expand Down Expand Up @@ -339,6 +344,7 @@ func (c *ClusterQuotaReconcilationController) syncQuotaForNamespaces(originalQuo
return fmt.Errorf("mapping not up to date, have=%v need=%v", quotaSelector, quota.Spec.Selector), workItems
}
matchingNamespaceNames := sets.NewString(matchingNamespaceNamesList...)
klog.V(2).Infof("syncing for quota %s with set of namespaces %v", quota.Name, matchingNamespaceNames)

reconcilationErrors := []error{}
retryItems := []workItem{}
Expand Down Expand Up @@ -422,6 +428,9 @@ func (c *ClusterQuotaReconcilationController) replenishQuota(ctx context.Context
}

quotaNames, _ := c.clusterQuotaMapper.GetClusterQuotasFor(namespace)
if len(quotaNames) > 0 {
klog.V(2).Infof("replenish quotas %v for namespace %s", quotaNames, namespace)
}

// only queue those quotas that are tracking a resource associated with this kind.
for _, quotaName := range quotaNames {
Expand Down

0 comments on commit 3b6a995

Please sign in to comment.