Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a clusterquota reconciliation controller #9658

Merged
merged 2 commits into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Godeps/_workspace/src/k8s.io/kubernetes/pkg/quota/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/client/clusteresourcequota.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ClusterResourceQuotaInterface interface {
List(opts kapi.ListOptions) (*quotaapi.ClusterResourceQuotaList, error)
Get(name string) (*quotaapi.ClusterResourceQuota, error)
Create(resourceQuota *quotaapi.ClusterResourceQuota) (*quotaapi.ClusterResourceQuota, error)
Update(resourceQuota *quotaapi.ClusterResourceQuota) (*quotaapi.ClusterResourceQuota, error)
Delete(name string) error
Watch(opts kapi.ListOptions) (watch.Interface, error)
}
Expand Down Expand Up @@ -48,6 +49,12 @@ func (c *clusterResourceQuotas) Create(resourceQuota *quotaapi.ClusterResourceQu
return
}

func (c *clusterResourceQuotas) Update(resourceQuota *quotaapi.ClusterResourceQuota) (result *quotaapi.ClusterResourceQuota, err error) {
result = &quotaapi.ClusterResourceQuota{}
err = c.r.Put().Resource("clusterresourcequotas").Name(resourceQuota.Name).Body(resourceQuota).Do().Into(result)
return
}

func (c *clusterResourceQuotas) Delete(name string) (err error) {
err = c.r.Delete().Resource("clusterresourcequotas").Name(name).Do().Error()
return
Expand Down
8 changes: 8 additions & 0 deletions pkg/client/testclient/fake_clusterresourcequota.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func (c *FakeClusterResourceQuotas) Create(inObj *quotaapi.ClusterResourceQuota)
return obj.(*quotaapi.ClusterResourceQuota), err
}

func (c *FakeClusterResourceQuotas) Update(inObj *quotaapi.ClusterResourceQuota) (*quotaapi.ClusterResourceQuota, error) {
obj, err := c.Fake.Invokes(ktestclient.NewRootUpdateAction("clusterresourcequotas", inObj), inObj)
if obj == nil {
return nil, err
}

return obj.(*quotaapi.ClusterResourceQuota), err
}
func (c *FakeClusterResourceQuotas) Delete(name string) error {
_, err := c.Fake.Invokes(ktestclient.NewRootDeleteAction("clusterresourcequotas", name), &quotaapi.ClusterResourceQuota{})
return err
Expand Down
30 changes: 30 additions & 0 deletions pkg/cmd/server/origin/run_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
kresourcequota "k8s.io/kubernetes/pkg/controller/resourcequota"
sacontroller "k8s.io/kubernetes/pkg/controller/serviceaccount"
quotainstall "k8s.io/kubernetes/pkg/quota/install"
"k8s.io/kubernetes/pkg/registry/service/allocator"
etcdallocator "k8s.io/kubernetes/pkg/registry/service/allocator/etcd"
"k8s.io/kubernetes/pkg/serviceaccount"
Expand Down Expand Up @@ -52,6 +53,7 @@ import (
imageapi "github.com/openshift/origin/pkg/image/api"
quota "github.com/openshift/origin/pkg/quota"
quotacontroller "github.com/openshift/origin/pkg/quota/controller"
"github.com/openshift/origin/pkg/quota/controller/clusterquotareconciliation"
sdnplugin "github.com/openshift/origin/pkg/sdn/plugin"
serviceaccountcontrollers "github.com/openshift/origin/pkg/serviceaccounts/controllers"
)
Expand Down Expand Up @@ -508,3 +510,31 @@ func (c *MasterConfig) RunClusterQuotaMappingController() {
go c.ClusterQuotaMappingController.Run(5, utilwait.NeverStop)
})
}

func (c *MasterConfig) RunClusterQuotaReconciliationController() {
osClient, kClient := c.ResourceQuotaManagerClients()
resourceQuotaRegistry := quotainstall.NewRegistry(kClient)
groupKindsToReplenish := []unversioned.GroupKind{
kapi.Kind("Pod"),
kapi.Kind("Service"),
kapi.Kind("ReplicationController"),
kapi.Kind("PersistentVolumeClaim"),
kapi.Kind("Secret"),
kapi.Kind("ConfigMap"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all we can replenish? Image strems? Deployment configs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all we can replenish? Image strems? Deployment configs?

for now, there's an item on the card: https://trello.com/c/qJUVjQnj/713-13-multi-project-quota

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a utility method upstream to pull this list so we can pull from a common set?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened tracking issue: kubernetes/kubernetes#28601

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a utility method upstream to pull this list so we can pull from a common set?

It's more structurally flawed. The choice should be based on GroupResource and that needs to built based on an intersection with enabled resources. It doesn't actually have to be limited to this server's hosting, since it could observe changes in federated servers.

In addition, we need to extend our InformerFactory to transparently handle generic listener requests to properly feed this beast.

We should probably restructure the replenishment controller to work as a listener/notifier and upstream the bucketter I built here to be able to handle partial updates.

I haven't prioritized the list of TODOs, but its a significant endeavor.

}

options := clusterquotareconciliation.ClusterQuotaReconcilationControllerOptions{
ClusterQuotaInformer: c.Informers.ClusterResourceQuotas(),
ClusterQuotaMapper: c.ClusterQuotaMappingController.GetClusterQuotaMapper(),
ClusterQuotaClient: osClient,

Registry: resourceQuotaRegistry,
ResyncPeriod: defaultResourceQuotaSyncPeriod,
ControllerFactory: kresourcequota.NewReplenishmentControllerFactory(c.Informers.Pods().Informer(), kClient),
ReplenishmentResyncPeriod: controller.StaticResyncPeriodFunc(defaultReplenishmentSyncPeriod),
GroupKindsToReplenish: groupKindsToReplenish,
}
controller := clusterquotareconciliation.NewClusterQuotaReconcilationController(options)
c.ClusterQuotaMappingController.GetClusterQuotaMapper().AddListener(controller)
go controller.Run(5, utilwait.NeverStop)
}
1 change: 1 addition & 0 deletions pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ func startControllers(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) erro
oc.RunImageImportController()
oc.RunOriginNamespaceController()
oc.RunSDNController()
oc.RunClusterQuotaReconciliationController()
oc.RunClusterQuotaMappingController()

_, _, serviceServingCertClient, err := oc.GetServiceAccountClients(bootstrappolicy.ServiceServingCertServiceAccountName)
Expand Down
Loading