Merge pull request #2113 from calvin0327/cleanup-federated-resourcequota
cleanup federated resource quota
This commit is contained in:
commit
d0cb708e7e
|
@ -6,7 +6,6 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/client-go/tools/record"
|
||||
|
@ -120,12 +119,9 @@ func (c *SyncController) SetupWithManager(mgr controllerruntime.Manager) error {
|
|||
func (c *SyncController) cleanUpWorks(namespace, name string) error {
|
||||
var errs []error
|
||||
workList := &workv1alpha1.WorkList{}
|
||||
if err := c.List(context.TODO(), workList, &client.ListOptions{
|
||||
LabelSelector: labels.SelectorFromSet(
|
||||
labels.Set{
|
||||
util.FederatedResourceQuotaNamespaceLabel: namespace,
|
||||
util.FederatedResourceQuotaNameLabel: name,
|
||||
}),
|
||||
if err := c.List(context.TODO(), workList, client.MatchingLabels{
|
||||
util.FederatedResourceQuotaNamespaceLabel: namespace,
|
||||
util.FederatedResourceQuotaNameLabel: name,
|
||||
}); err != nil {
|
||||
klog.Errorf("Failed to list works, err: %v", err)
|
||||
return err
|
||||
|
@ -139,10 +135,7 @@ func (c *SyncController) cleanUpWorks(namespace, name string) error {
|
|||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func (c *SyncController) buildWorks(quota *policyv1alpha1.FederatedResourceQuota, clusters []clusterv1alpha1.Cluster) error {
|
||||
|
@ -190,10 +183,7 @@ func (c *SyncController) buildWorks(quota *policyv1alpha1.FederatedResourceQuota
|
|||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func extractClusterHardResourceList(spec policyv1alpha1.FederatedResourceQuotaSpec, cluster string) corev1.ResourceList {
|
||||
|
|
|
@ -173,8 +173,5 @@ func (c *HorizontalPodAutoscalerController) deleteWorks(workName string) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
return nil
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
|
|
@ -354,12 +354,7 @@ func (c *ServiceExportController) reportEndpointSliceWithServiceExportCreate(ser
|
|||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
// reportEndpointSliceWithEndpointSliceCreateOrUpdate reports the EndpointSlice when referencing service has been exported.
|
||||
|
@ -436,11 +431,7 @@ func cleanupWorkWithServiceExportDelete(c client.Client, serviceExportKey keys.F
|
|||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func cleanupWorkWithEndpointSliceDelete(c client.Client, endpointSliceKey keys.FederatedKey) error {
|
||||
|
|
|
@ -546,11 +546,7 @@ func (d *DependenciesDistributor) removeScheduleResultFromAttachedBindings(bindi
|
|||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func buildAttachedBinding(binding *workv1alpha2.ResourceBinding, object *unstructured.Unstructured) *workv1alpha2.ResourceBinding {
|
||||
|
|
|
@ -973,12 +973,7 @@ func (d *ResourceDetector) HandleClusterPropagationPolicyDeletion(policyName str
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
// HandlePropagationPolicyCreation handles PropagationPolicy add event.
|
||||
|
|
|
@ -132,10 +132,7 @@ func RemoveOrphanWorks(c client.Client, works []workv1alpha1.Work) error {
|
|||
}
|
||||
klog.Infof("Delete orphan work %s/%s successfully.", work.GetNamespace(), work.GetName())
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
// FetchWorkload fetches the kubernetes resource to be propagated.
|
||||
|
@ -223,12 +220,7 @@ func DeleteWorks(c client.Client, namespace, name string) error {
|
|||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
// GenerateNodeClaimByPodSpec will return a NodeClaim from PodSpec.
|
||||
|
|
|
@ -73,9 +73,5 @@ func DeleteEndpointSlice(c client.Client, selector labels.Set) error {
|
|||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
return nil
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue