diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 61669ac6f00..125d488375a 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -40,7 +40,8 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/record" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/endpoint" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/node" replicationControllerPkg "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/replication" explatest "github.com/GoogleCloudPlatform/kubernetes/pkg/expapi/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" @@ -51,7 +52,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/master" "github.com/GoogleCloudPlatform/kubernetes/pkg/probe" - "github.com/GoogleCloudPlatform/kubernetes/pkg/service" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait" @@ -187,7 +187,7 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st eventBroadcaster.StartRecordingToSink(cl.Events("")) scheduler.New(schedulerConfig).Run() - endpoints := service.NewEndpointController(cl) + endpoints := endpointcontroller.NewEndpointController(cl) // ensure the service endpoints are sync'd several times within the window that the integration tests wait go endpoints.Run(3, util.NeverStop) diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index 9f2d06b2acd..58508a683a3 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -35,16 +35,16 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd" clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/routecontroller" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/servicecontroller" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/endpoint" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/namespace" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/node" replicationControllerPkg "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/replication" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/resourcequota" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/route" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/service" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz" "github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports" - "github.com/GoogleCloudPlatform/kubernetes/pkg/namespace" - "github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota" - "github.com/GoogleCloudPlatform/kubernetes/pkg/service" - "github.com/GoogleCloudPlatform/kubernetes/pkg/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/volumeclaimbinder" @@ -183,7 +183,7 @@ func (s *CMServer) Run(_ []string) error { glog.Fatal(server.ListenAndServe()) }() - endpoints := service.NewEndpointController(kubeClient) + endpoints := endpointcontroller.NewEndpointController(kubeClient) go endpoints.Run(s.ConcurrentEndpointSyncs, util.NeverStop) controllerManager := replicationControllerPkg.NewReplicationManager(kubeClient, replicationControllerPkg.BurstReplicas) @@ -215,11 +215,11 @@ func (s *CMServer) Run(_ []string) error { } } - resourceQuotaManager := resourcequota.NewResourceQuotaManager(kubeClient) - resourceQuotaManager.Run(s.ResourceQuotaSyncPeriod) + resourceQuotaController := resourcequotacontroller.NewResourceQuotaController(kubeClient) + resourceQuotaController.Run(s.ResourceQuotaSyncPeriod) - namespaceManager := namespace.NewNamespaceManager(kubeClient, s.NamespaceSyncPeriod) - namespaceManager.Run() + namespaceController := namespacecontroller.NewNamespaceController(kubeClient, s.NamespaceSyncPeriod) + namespaceController.Run() pvclaimBinder := volumeclaimbinder.NewPersistentVolumeClaimBinder(kubeClient, s.PVClaimBinderSyncPeriod) pvclaimBinder.Run() diff --git a/cmd/kubernetes/kubernetes.go b/cmd/kubernetes/kubernetes.go index 7ddb3013e7e..c0d7b2ba1eb 100644 --- a/cmd/kubernetes/kubernetes.go +++ b/cmd/kubernetes/kubernetes.go @@ -34,15 +34,15 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/servicecontroller" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/endpoint" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/node" "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/replication" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/service" explatest "github.com/GoogleCloudPlatform/kubernetes/pkg/expapi/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor" kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools" "github.com/GoogleCloudPlatform/kubernetes/pkg/master" - "github.com/GoogleCloudPlatform/kubernetes/pkg/service" etcdstorage "github.com/GoogleCloudPlatform/kubernetes/pkg/storage/etcd" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -140,10 +140,10 @@ func runControllerManager(cl *client.Client) { glog.Warningf("Running without a service controller: %v", err) } - endpoints := service.NewEndpointController(cl) + endpoints := endpointcontroller.NewEndpointController(cl) go endpoints.Run(5, util.NeverStop) - controllerManager := replication.NewReplicationManager(cl, replication.BurstReplicas) + controllerManager := replicationcontroller.NewReplicationManager(cl, replicationcontroller.BurstReplicas) go controllerManager.Run(5, util.NeverStop) } diff --git a/contrib/mesos/pkg/controllermanager/controllermanager.go b/contrib/mesos/pkg/controllermanager/controllermanager.go index ac12fe98ef4..a0d016333b1 100644 --- a/contrib/mesos/pkg/controllermanager/controllermanager.go +++ b/contrib/mesos/pkg/controllermanager/controllermanager.go @@ -29,15 +29,15 @@ import ( clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/mesos" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/nodecontroller" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/routecontroller" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/servicecontroller" + kendpoint "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/endpoint" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/namespace" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/node" "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/replication" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/resourcequota" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/route" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/service" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz" - "github.com/GoogleCloudPlatform/kubernetes/pkg/namespace" - "github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota" - kendpoint "github.com/GoogleCloudPlatform/kubernetes/pkg/service" - "github.com/GoogleCloudPlatform/kubernetes/pkg/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/volumeclaimbinder" @@ -110,7 +110,7 @@ func (s *CMServer) Run(_ []string) error { endpoints := s.createEndpointController(kubeClient) go endpoints.Run(s.ConcurrentEndpointSyncs, util.NeverStop) - controllerManager := replication.NewReplicationManager(kubeClient, replication.BurstReplicas) + controllerManager := replicationcontroller.NewReplicationManager(kubeClient, replicationcontroller.BurstReplicas) go controllerManager.Run(s.ConcurrentRCSyncs, util.NeverStop) //TODO(jdef) should eventually support more cloud providers here @@ -141,11 +141,11 @@ func (s *CMServer) Run(_ []string) error { routeController.Run(s.NodeSyncPeriod) } - resourceQuotaManager := resourcequota.NewResourceQuotaManager(kubeClient) - resourceQuotaManager.Run(s.ResourceQuotaSyncPeriod) + resourceQuotaController := resourcequotacontroller.NewResourceQuotaController(kubeClient) + resourceQuotaController.Run(s.ResourceQuotaSyncPeriod) - namespaceManager := namespace.NewNamespaceManager(kubeClient, s.NamespaceSyncPeriod) - namespaceManager.Run() + namespaceController := namespacecontroller.NewNamespaceController(kubeClient, s.NamespaceSyncPeriod) + namespaceController.Run() pvclaimBinder := volumeclaimbinder.NewPersistentVolumeClaimBinder(kubeClient, s.PVClaimBinderSyncPeriod) pvclaimBinder.Run() diff --git a/contrib/mesos/pkg/scheduler/resource/resource.go b/contrib/mesos/pkg/scheduler/resource/resource.go index 2104c3dfcb5..44ca401a270 100644 --- a/contrib/mesos/pkg/scheduler/resource/resource.go +++ b/contrib/mesos/pkg/scheduler/resource/resource.go @@ -19,7 +19,7 @@ package resource import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" - "github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/resourcequota" ) const ( @@ -30,14 +30,14 @@ const ( // CPUFromPodSpec computes the cpu shares that the pod is admitted to use. Containers // without CPU limit are NOT taken into account. func PodCPULimit(pod *api.Pod) CPUShares { - cpuQuantity := resourcequota.PodCPU(pod) + cpuQuantity := resourcequotacontroller.PodCPU(pod) return CPUShares(float64(cpuQuantity.MilliValue()) / 1000.0) } // MemFromPodSpec computes the amount of memory that the pod is admitted to use. Containers // without memory limit are NOT taken into account. func PodMemLimit(pod *api.Pod) MegaBytes { - memQuantity := resourcequota.PodMemory(pod) + memQuantity := resourcequotacontroller.PodMemory(pod) return MegaBytes(float64(memQuantity.Value()) / 1024.0 / 1024.0) } diff --git a/contrib/mesos/pkg/service/endpoints_controller.go b/contrib/mesos/pkg/service/endpoints_controller.go index f0eb055023e..4327ea240c8 100644 --- a/contrib/mesos/pkg/service/endpoints_controller.go +++ b/contrib/mesos/pkg/service/endpoints_controller.go @@ -28,11 +28,11 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" + kservice "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/endpoint" "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/framework" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" - kservice "github.com/GoogleCloudPlatform/kubernetes/pkg/service" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/workqueue" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" diff --git a/pkg/apiserver/authn.go b/pkg/apiserver/authn.go index d40aa3eb0e8..cc3000d484e 100644 --- a/pkg/apiserver/authn.go +++ b/pkg/apiserver/authn.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authenticator" "github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authenticator/bearertoken" - "github.com/GoogleCloudPlatform/kubernetes/pkg/serviceaccount" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/storage" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/auth/authenticator/password/passwordfile" diff --git a/pkg/service/doc.go b/pkg/controller/endpoint/doc.go similarity index 96% rename from pkg/service/doc.go rename to pkg/controller/endpoint/doc.go index b76e051debf..058b1643a6b 100644 --- a/pkg/service/doc.go +++ b/pkg/controller/endpoint/doc.go @@ -16,4 +16,4 @@ limitations under the License. // Package service provides EndpointController implementation // to manage and sync service endpoints. -package service +package endpointcontroller diff --git a/pkg/service/endpoints_controller.go b/pkg/controller/endpoint/endpoints_controller.go similarity index 99% rename from pkg/service/endpoints_controller.go rename to pkg/controller/endpoint/endpoints_controller.go index 461e41c8134..f61066abbb7 100644 --- a/pkg/service/endpoints_controller.go +++ b/pkg/controller/endpoint/endpoints_controller.go @@ -16,7 +16,7 @@ limitations under the License. // CAUTION: If you update code in this file, you may need to also update code // in contrib/mesos/pkg/service/endpoints_controller.go -package service +package endpointcontroller import ( "fmt" diff --git a/pkg/service/endpoints_controller_test.go b/pkg/controller/endpoint/endpoints_controller_test.go similarity index 99% rename from pkg/service/endpoints_controller_test.go rename to pkg/controller/endpoint/endpoints_controller_test.go index c34a79abba5..74001557568 100644 --- a/pkg/service/endpoints_controller_test.go +++ b/pkg/controller/endpoint/endpoints_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package service +package endpointcontroller import ( "fmt" diff --git a/pkg/namespace/doc.go b/pkg/controller/namespace/doc.go similarity index 95% rename from pkg/namespace/doc.go rename to pkg/controller/namespace/doc.go index fea657af5e7..57c79007339 100644 --- a/pkg/namespace/doc.go +++ b/pkg/controller/namespace/doc.go @@ -15,4 +15,4 @@ limitations under the License. */ // namespace contains a controller that handles namespace lifecycle -package namespace +package namespacecontroller diff --git a/pkg/namespace/namespace_controller.go b/pkg/controller/namespace/namespace_controller.go similarity index 95% rename from pkg/namespace/namespace_controller.go rename to pkg/controller/namespace/namespace_controller.go index 191c0c2bd7b..9fe0f466c28 100644 --- a/pkg/namespace/namespace_controller.go +++ b/pkg/controller/namespace/namespace_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package namespace +package namespacecontroller import ( "time" @@ -33,14 +33,14 @@ import ( "github.com/golang/glog" ) -// NamespaceManager is responsible for performing actions dependent upon a namespace phase -type NamespaceManager struct { +// NamespaceController is responsible for performing actions dependent upon a namespace phase +type NamespaceController struct { controller *framework.Controller StopEverything chan struct{} } -// NewNamespaceManager creates a new NamespaceManager -func NewNamespaceManager(kubeClient client.Interface, resyncPeriod time.Duration) *NamespaceManager { +// NewNamespaceController creates a new NamespaceController +func NewNamespaceController(kubeClient client.Interface, resyncPeriod time.Duration) *NamespaceController { _, controller := framework.NewInformer( &cache.ListWatch{ ListFunc: func() (runtime.Object, error) { @@ -70,13 +70,13 @@ func NewNamespaceManager(kubeClient client.Interface, resyncPeriod time.Duration }, ) - return &NamespaceManager{ + return &NamespaceController{ controller: controller, } } // Run begins observing the system. It starts a goroutine and returns immediately. -func (nm *NamespaceManager) Run() { +func (nm *NamespaceController) Run() { if nm.StopEverything == nil { nm.StopEverything = make(chan struct{}) go nm.controller.Run(nm.StopEverything) @@ -84,7 +84,7 @@ func (nm *NamespaceManager) Run() { } // Stop gracefully shutsdown this controller -func (nm *NamespaceManager) Stop() { +func (nm *NamespaceController) Stop() { if nm.StopEverything != nil { close(nm.StopEverything) nm.StopEverything = nil diff --git a/pkg/namespace/namespace_controller_test.go b/pkg/controller/namespace/namespace_controller_test.go similarity index 92% rename from pkg/namespace/namespace_controller_test.go rename to pkg/controller/namespace/namespace_controller_test.go index 0be0cbf4e17..0c98ace9054 100644 --- a/pkg/namespace/namespace_controller_test.go +++ b/pkg/controller/namespace/namespace_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package namespace +package namespacecontroller import ( "testing" @@ -138,21 +138,21 @@ func TestSyncNamespaceThatIsActive(t *testing.T) { func TestRunStop(t *testing.T) { o := testclient.NewObjects(api.Scheme, api.Scheme) client := &testclient.Fake{ReactFn: testclient.ObjectReaction(o, api.RESTMapper)} - nsMgr := NewNamespaceManager(client, 1*time.Second) + nsController := NewNamespaceController(client, 1*time.Second) - if nsMgr.StopEverything != nil { - t.Errorf("Non-running manager should not have a stop channel. Got %v", nsMgr.StopEverything) + if nsController.StopEverything != nil { + t.Errorf("Non-running manager should not have a stop channel. Got %v", nsController.StopEverything) } - nsMgr.Run() + nsController.Run() - if nsMgr.StopEverything == nil { + if nsController.StopEverything == nil { t.Errorf("Running manager should have a stop channel. Got nil") } - nsMgr.Stop() + nsController.Stop() - if nsMgr.StopEverything != nil { - t.Errorf("Non-running manager should not have a stop channel. Got %v", nsMgr.StopEverything) + if nsController.StopEverything != nil { + t.Errorf("Non-running manager should not have a stop channel. Got %v", nsController.StopEverything) } } diff --git a/pkg/cloudprovider/nodecontroller/doc.go b/pkg/controller/node/doc.go similarity index 100% rename from pkg/cloudprovider/nodecontroller/doc.go rename to pkg/controller/node/doc.go diff --git a/pkg/cloudprovider/nodecontroller/nodecontroller.go b/pkg/controller/node/nodecontroller.go similarity index 100% rename from pkg/cloudprovider/nodecontroller/nodecontroller.go rename to pkg/controller/node/nodecontroller.go diff --git a/pkg/cloudprovider/nodecontroller/nodecontroller_test.go b/pkg/controller/node/nodecontroller_test.go similarity index 100% rename from pkg/cloudprovider/nodecontroller/nodecontroller_test.go rename to pkg/controller/node/nodecontroller_test.go diff --git a/pkg/cloudprovider/nodecontroller/podevictor.go b/pkg/controller/node/podevictor.go similarity index 100% rename from pkg/cloudprovider/nodecontroller/podevictor.go rename to pkg/controller/node/podevictor.go diff --git a/pkg/cloudprovider/nodecontroller/podevictor_test.go b/pkg/controller/node/podevictor_test.go similarity index 100% rename from pkg/cloudprovider/nodecontroller/podevictor_test.go rename to pkg/controller/node/podevictor_test.go diff --git a/pkg/controller/replication/doc.go b/pkg/controller/replication/doc.go index b60e1d99c4e..eb6027db312 100644 --- a/pkg/controller/replication/doc.go +++ b/pkg/controller/replication/doc.go @@ -16,4 +16,4 @@ limitations under the License. // Package replication contains logic for watching and synchronizing // replication controllers. -package replication +package replicationcontroller diff --git a/pkg/controller/replication/replication_controller.go b/pkg/controller/replication/replication_controller.go index 6725dc71d07..a0d3d54e3ac 100644 --- a/pkg/controller/replication/replication_controller.go +++ b/pkg/controller/replication/replication_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package replication +package replicationcontroller import ( "reflect" @@ -63,6 +63,8 @@ const ( // ReplicationManager is responsible for synchronizing ReplicationController objects stored // in the system with actual running pods. +// TODO: this really should be called ReplicationController. The only reason why it's a Manager +// is to distinguish this type from API object "ReplicationController". We should fix this. type ReplicationManager struct { kubeClient client.Interface podControl controller.PodControlInterface diff --git a/pkg/controller/replication/replication_controller_test.go b/pkg/controller/replication/replication_controller_test.go index b619fc4e75a..ac2931841ee 100644 --- a/pkg/controller/replication/replication_controller_test.go +++ b/pkg/controller/replication/replication_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package replication +package replicationcontroller import ( "fmt" diff --git a/pkg/controller/replication/replication_controller_utils.go b/pkg/controller/replication/replication_controller_utils.go index 63f4fecf58b..7639e174ead 100644 --- a/pkg/controller/replication/replication_controller_utils.go +++ b/pkg/controller/replication/replication_controller_utils.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package replication +package replicationcontroller import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" diff --git a/pkg/resourcequota/doc.go b/pkg/controller/resourcequota/doc.go similarity index 95% rename from pkg/resourcequota/doc.go rename to pkg/controller/resourcequota/doc.go index a83ad10dd66..73fa39f90e7 100644 --- a/pkg/resourcequota/doc.go +++ b/pkg/controller/resourcequota/doc.go @@ -15,4 +15,4 @@ limitations under the License. */ // resourcequota contains a controller that makes resource quota usage observations -package resourcequota +package resourcequotacontroller diff --git a/pkg/resourcequota/resource_quota_controller.go b/pkg/controller/resourcequota/resource_quota_controller.go similarity index 93% rename from pkg/resourcequota/resource_quota_controller.go rename to pkg/controller/resourcequota/resource_quota_controller.go index b8defbdd540..9a2311aed79 100644 --- a/pkg/resourcequota/resource_quota_controller.go +++ b/pkg/controller/resourcequota/resource_quota_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package resourcequota +package resourcequotacontroller import ( "time" @@ -28,8 +28,8 @@ import ( "github.com/golang/glog" ) -// ResourceQuotaManager is responsible for tracking quota usage status in the system -type ResourceQuotaManager struct { +// ResourceQuotaController is responsible for tracking quota usage status in the system +type ResourceQuotaController struct { kubeClient client.Interface syncTime <-chan time.Time @@ -37,10 +37,10 @@ type ResourceQuotaManager struct { syncHandler func(quota api.ResourceQuota) error } -// NewResourceQuotaManager creates a new ResourceQuotaManager -func NewResourceQuotaManager(kubeClient client.Interface) *ResourceQuotaManager { +// NewResourceQuotaController creates a new ResourceQuotaController +func NewResourceQuotaController(kubeClient client.Interface) *ResourceQuotaController { - rm := &ResourceQuotaManager{ + rm := &ResourceQuotaController{ kubeClient: kubeClient, } @@ -50,12 +50,12 @@ func NewResourceQuotaManager(kubeClient client.Interface) *ResourceQuotaManager } // Run begins watching and syncing. -func (rm *ResourceQuotaManager) Run(period time.Duration) { +func (rm *ResourceQuotaController) Run(period time.Duration) { rm.syncTime = time.Tick(period) go util.Forever(func() { rm.synchronize() }, period) } -func (rm *ResourceQuotaManager) synchronize() { +func (rm *ResourceQuotaController) synchronize() { var resourceQuotas []api.ResourceQuota list, err := rm.kubeClient.ResourceQuotas(api.NamespaceAll).List(labels.Everything()) if err != nil { @@ -101,7 +101,7 @@ func FilterQuotaPods(pods []api.Pod) []*api.Pod { } // syncResourceQuota runs a complete sync of current status -func (rm *ResourceQuotaManager) syncResourceQuota(quota api.ResourceQuota) (err error) { +func (rm *ResourceQuotaController) syncResourceQuota(quota api.ResourceQuota) (err error) { // quota is dirty if any part of spec hard limits differs from the status hard limits dirty := !api.Semantic.DeepEqual(quota.Spec.Hard, quota.Status.Hard) diff --git a/pkg/resourcequota/resource_quota_controller_test.go b/pkg/controller/resourcequota/resource_quota_controller_test.go similarity index 95% rename from pkg/resourcequota/resource_quota_controller_test.go rename to pkg/controller/resourcequota/resource_quota_controller_test.go index 14b0ff5d5c0..0aef467ec2b 100644 --- a/pkg/resourcequota/resource_quota_controller_test.go +++ b/pkg/controller/resourcequota/resource_quota_controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package resourcequota +package resourcequotacontroller import ( "testing" @@ -152,8 +152,8 @@ func TestSyncResourceQuota(t *testing.T) { kubeClient := testclient.NewSimpleFake(&podList, "a) - resourceQuotaManager := NewResourceQuotaManager(kubeClient) - err := resourceQuotaManager.syncResourceQuota(quota) + ResourceQuotaController := NewResourceQuotaController(kubeClient) + err := ResourceQuotaController.syncResourceQuota(quota) if err != nil { t.Fatalf("Unexpected error %v", err) } @@ -210,8 +210,8 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) { kubeClient := testclient.NewSimpleFake("a) - resourceQuotaManager := NewResourceQuotaManager(kubeClient) - err := resourceQuotaManager.syncResourceQuota(quota) + ResourceQuotaController := NewResourceQuotaController(kubeClient) + err := ResourceQuotaController.syncResourceQuota(quota) if err != nil { t.Fatalf("Unexpected error %v", err) } @@ -257,8 +257,8 @@ func TestSyncResourceQuotaNoChange(t *testing.T) { kubeClient := testclient.NewSimpleFake(&api.PodList{}, "a) - resourceQuotaManager := NewResourceQuotaManager(kubeClient) - err := resourceQuotaManager.syncResourceQuota(quota) + ResourceQuotaController := NewResourceQuotaController(kubeClient) + err := ResourceQuotaController.syncResourceQuota(quota) if err != nil { t.Fatalf("Unexpected error %v", err) } diff --git a/pkg/cloudprovider/routecontroller/doc.go b/pkg/controller/route/doc.go similarity index 100% rename from pkg/cloudprovider/routecontroller/doc.go rename to pkg/controller/route/doc.go diff --git a/pkg/cloudprovider/routecontroller/routecontroller.go b/pkg/controller/route/routecontroller.go similarity index 100% rename from pkg/cloudprovider/routecontroller/routecontroller.go rename to pkg/controller/route/routecontroller.go diff --git a/pkg/cloudprovider/routecontroller/routecontroller_test.go b/pkg/controller/route/routecontroller_test.go similarity index 100% rename from pkg/cloudprovider/routecontroller/routecontroller_test.go rename to pkg/controller/route/routecontroller_test.go diff --git a/pkg/cloudprovider/servicecontroller/doc.go b/pkg/controller/service/doc.go similarity index 100% rename from pkg/cloudprovider/servicecontroller/doc.go rename to pkg/controller/service/doc.go diff --git a/pkg/cloudprovider/servicecontroller/servicecontroller.go b/pkg/controller/service/servicecontroller.go similarity index 100% rename from pkg/cloudprovider/servicecontroller/servicecontroller.go rename to pkg/controller/service/servicecontroller.go diff --git a/pkg/cloudprovider/servicecontroller/servicecontroller_test.go b/pkg/controller/service/servicecontroller_test.go similarity index 100% rename from pkg/cloudprovider/servicecontroller/servicecontroller_test.go rename to pkg/controller/service/servicecontroller_test.go diff --git a/pkg/serviceaccount/doc.go b/pkg/controller/serviceaccount/doc.go similarity index 100% rename from pkg/serviceaccount/doc.go rename to pkg/controller/serviceaccount/doc.go diff --git a/pkg/serviceaccount/jwt.go b/pkg/controller/serviceaccount/jwt.go similarity index 100% rename from pkg/serviceaccount/jwt.go rename to pkg/controller/serviceaccount/jwt.go diff --git a/pkg/serviceaccount/jwt_test.go b/pkg/controller/serviceaccount/jwt_test.go similarity index 100% rename from pkg/serviceaccount/jwt_test.go rename to pkg/controller/serviceaccount/jwt_test.go diff --git a/pkg/serviceaccount/serviceaccounts_controller.go b/pkg/controller/serviceaccount/serviceaccounts_controller.go similarity index 100% rename from pkg/serviceaccount/serviceaccounts_controller.go rename to pkg/controller/serviceaccount/serviceaccounts_controller.go diff --git a/pkg/serviceaccount/serviceaccounts_controller_test.go b/pkg/controller/serviceaccount/serviceaccounts_controller_test.go similarity index 100% rename from pkg/serviceaccount/serviceaccounts_controller_test.go rename to pkg/controller/serviceaccount/serviceaccounts_controller_test.go diff --git a/pkg/serviceaccount/tokengetter.go b/pkg/controller/serviceaccount/tokengetter.go similarity index 100% rename from pkg/serviceaccount/tokengetter.go rename to pkg/controller/serviceaccount/tokengetter.go diff --git a/pkg/serviceaccount/tokens_controller.go b/pkg/controller/serviceaccount/tokens_controller.go similarity index 100% rename from pkg/serviceaccount/tokens_controller.go rename to pkg/controller/serviceaccount/tokens_controller.go diff --git a/pkg/serviceaccount/tokens_controller_test.go b/pkg/controller/serviceaccount/tokens_controller_test.go similarity index 100% rename from pkg/serviceaccount/tokens_controller_test.go rename to pkg/controller/serviceaccount/tokens_controller_test.go diff --git a/plugin/pkg/admission/resourcequota/admission.go b/plugin/pkg/admission/resourcequota/admission.go index f92f7c56675..da8f893b4f1 100644 --- a/plugin/pkg/admission/resourcequota/admission.go +++ b/plugin/pkg/admission/resourcequota/admission.go @@ -27,9 +27,9 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/resourcequota" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" - "github.com/GoogleCloudPlatform/kubernetes/pkg/resourcequota" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" ) @@ -193,23 +193,23 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli // handle memory/cpu constraints, and any diff of usage based on memory/cpu on updates if a.GetResource() == "pods" && (set[api.ResourceMemory] || set[api.ResourceCPU]) { pod := obj.(*api.Pod) - deltaCPU := resourcequota.PodCPU(pod) - deltaMemory := resourcequota.PodMemory(pod) + deltaCPU := resourcequotacontroller.PodCPU(pod) + deltaMemory := resourcequotacontroller.PodMemory(pod) // if this is an update, we need to find the delta cpu/memory usage from previous state if a.GetOperation() == admission.Update { oldPod, err := client.Pods(a.GetNamespace()).Get(pod.Name) if err != nil { return false, err } - oldCPU := resourcequota.PodCPU(oldPod) - oldMemory := resourcequota.PodMemory(oldPod) + oldCPU := resourcequotacontroller.PodCPU(oldPod) + oldMemory := resourcequotacontroller.PodMemory(oldPod) deltaCPU = resource.NewMilliQuantity(deltaCPU.MilliValue()-oldCPU.MilliValue(), resource.DecimalSI) deltaMemory = resource.NewQuantity(deltaMemory.Value()-oldMemory.Value(), resource.DecimalSI) } hardMem, hardMemFound := status.Hard[api.ResourceMemory] if hardMemFound { - if set[api.ResourceMemory] && resourcequota.IsPodMemoryUnbounded(pod) { + if set[api.ResourceMemory] && resourcequotacontroller.IsPodMemoryUnbounded(pod) { return false, fmt.Errorf("Limited to %s memory, but pod has no specified memory limit", hardMem.String()) } used, usedFound := status.Used[api.ResourceMemory] @@ -225,7 +225,7 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli } hardCPU, hardCPUFound := status.Hard[api.ResourceCPU] if hardCPUFound { - if set[api.ResourceCPU] && resourcequota.IsPodCPUUnbounded(pod) { + if set[api.ResourceCPU] && resourcequotacontroller.IsPodCPUUnbounded(pod) { return false, fmt.Errorf("Limited to %s CPU, but pod has no specified cpu limit", hardCPU.String()) } used, usedFound := status.Used[api.ResourceCPU] diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index eb08d72e4ea..3b9e35a0368 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -68,7 +68,7 @@ type MasterComponents struct { // Restclient used to talk to the kubernetes master RestClient *client.Client // Replication controller manager - ControllerManager *replication.ReplicationManager + ControllerManager *replicationcontroller.ReplicationManager // Channel for stop signals to rc manager rcStopCh chan struct{} // Used to stop master components individually, and via MasterComponents.Stop @@ -101,7 +101,7 @@ func NewMasterComponents(c *Config) *MasterComponents { } restClient := client.NewOrDie(&client.Config{Host: s.URL, Version: testapi.Version(), QPS: c.QPS, Burst: c.Burst}) rcStopCh := make(chan struct{}) - controllerManager := replication.NewReplicationManager(restClient, c.Burst) + controllerManager := replicationcontroller.NewReplicationManager(restClient, c.Burst) // TODO: Support events once we can cleanly shutdown an event recorder. controllerManager.SetEventRecorder(&record.FakeRecorder{}) diff --git a/test/integration/service_account_test.go b/test/integration/service_account_test.go index a45fd760f2f..e6c42bb19c3 100644 --- a/test/integration/service_account_test.go +++ b/test/integration/service_account_test.go @@ -40,10 +40,10 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/auth/authorizer" "github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" + "github.com/GoogleCloudPlatform/kubernetes/pkg/controller/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/master" - "github.com/GoogleCloudPlatform/kubernetes/pkg/serviceaccount" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"