mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Remove references to scheduler from pod storage.
This commit is contained in:
parent
ddba004ad0
commit
98ef76c164
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package master
|
package master
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -32,7 +31,6 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
|
||||||
goetcd "github.com/coreos/go-etcd/etcd"
|
goetcd "github.com/coreos/go-etcd/etcd"
|
||||||
@ -111,16 +109,12 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
|
|||||||
endpoints := endpoint.NewEndpointController(m.serviceRegistry, m.client)
|
endpoints := endpoint.NewEndpointController(m.serviceRegistry, m.client)
|
||||||
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
||||||
|
|
||||||
random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
|
|
||||||
s := scheduler.NewRandomFitScheduler(m.podRegistry, random)
|
|
||||||
m.storage = map[string]apiserver.RESTStorage{
|
m.storage = map[string]apiserver.RESTStorage{
|
||||||
"pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{
|
"pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{
|
||||||
CloudProvider: cloud,
|
CloudProvider: cloud,
|
||||||
MinionLister: m.minionRegistry,
|
|
||||||
PodCache: podCache,
|
PodCache: podCache,
|
||||||
PodInfoGetter: podInfoGetter,
|
PodInfoGetter: podInfoGetter,
|
||||||
Registry: m.podRegistry,
|
Registry: m.podRegistry,
|
||||||
Scheduler: s,
|
|
||||||
}),
|
}),
|
||||||
"replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry),
|
"replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry),
|
||||||
"services": service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
|
"services": service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
|
|
||||||
@ -39,33 +38,27 @@ import (
|
|||||||
type RegistryStorage struct {
|
type RegistryStorage struct {
|
||||||
cloudProvider cloudprovider.Interface
|
cloudProvider cloudprovider.Interface
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
minionLister scheduler.MinionLister
|
|
||||||
podCache client.PodInfoGetter
|
podCache client.PodInfoGetter
|
||||||
podInfoGetter client.PodInfoGetter
|
podInfoGetter client.PodInfoGetter
|
||||||
podPollPeriod time.Duration
|
podPollPeriod time.Duration
|
||||||
registry Registry
|
registry Registry
|
||||||
scheduler scheduler.Scheduler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegistryStorageConfig struct {
|
type RegistryStorageConfig struct {
|
||||||
CloudProvider cloudprovider.Interface
|
CloudProvider cloudprovider.Interface
|
||||||
MinionLister scheduler.MinionLister
|
|
||||||
PodCache client.PodInfoGetter
|
PodCache client.PodInfoGetter
|
||||||
PodInfoGetter client.PodInfoGetter
|
PodInfoGetter client.PodInfoGetter
|
||||||
Registry Registry
|
Registry Registry
|
||||||
Scheduler scheduler.Scheduler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRegistryStorage returns a new RegistryStorage.
|
// NewRegistryStorage returns a new RegistryStorage.
|
||||||
func NewRegistryStorage(config *RegistryStorageConfig) apiserver.RESTStorage {
|
func NewRegistryStorage(config *RegistryStorageConfig) apiserver.RESTStorage {
|
||||||
return &RegistryStorage{
|
return &RegistryStorage{
|
||||||
cloudProvider: config.CloudProvider,
|
cloudProvider: config.CloudProvider,
|
||||||
minionLister: config.MinionLister,
|
|
||||||
podCache: config.PodCache,
|
podCache: config.PodCache,
|
||||||
podInfoGetter: config.PodInfoGetter,
|
podInfoGetter: config.PodInfoGetter,
|
||||||
podPollPeriod: time.Second * 10,
|
podPollPeriod: time.Second * 10,
|
||||||
registry: config.Registry,
|
registry: config.Registry,
|
||||||
scheduler: config.Scheduler,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +75,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
|||||||
pod.CreationTimestamp = util.Now()
|
pod.CreationTimestamp = util.Now()
|
||||||
|
|
||||||
return apiserver.MakeAsync(func() (interface{}, error) {
|
return apiserver.MakeAsync(func() (interface{}, error) {
|
||||||
if err := rs.scheduleAndCreatePod(*pod); err != nil {
|
if err := rs.registry.CreatePod(*pod); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rs.registry.GetPod(pod.ID)
|
return rs.registry.GetPod(pod.ID)
|
||||||
@ -245,12 +238,6 @@ func getPodStatus(pod *api.Pod) api.PodStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RegistryStorage) scheduleAndCreatePod(pod api.Pod) error {
|
|
||||||
rs.mu.Lock()
|
|
||||||
defer rs.mu.Unlock()
|
|
||||||
return rs.registry.CreatePod(pod)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RegistryStorage) waitForPodRunning(pod api.Pod) (interface{}, error) {
|
func (rs *RegistryStorage) waitForPodRunning(pod api.Pod) (interface{}, error) {
|
||||||
for {
|
for {
|
||||||
podObj, err := rs.Get(pod.ID)
|
podObj, err := rs.Get(pod.ID)
|
||||||
|
@ -25,9 +25,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
|
|
||||||
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
@ -58,7 +56,6 @@ func TestCreatePodRegistryError(t *testing.T) {
|
|||||||
podRegistry := registrytest.NewPodRegistry(nil)
|
podRegistry := registrytest.NewPodRegistry(nil)
|
||||||
podRegistry.Err = fmt.Errorf("test error")
|
podRegistry.Err = fmt.Errorf("test error")
|
||||||
storage := RegistryStorage{
|
storage := RegistryStorage{
|
||||||
scheduler: ®istrytest.Scheduler{},
|
|
||||||
registry: podRegistry,
|
registry: podRegistry,
|
||||||
}
|
}
|
||||||
desiredState := api.PodState{
|
desiredState := api.PodState{
|
||||||
@ -78,7 +75,6 @@ func TestCreatePodSetsIds(t *testing.T) {
|
|||||||
podRegistry := registrytest.NewPodRegistry(nil)
|
podRegistry := registrytest.NewPodRegistry(nil)
|
||||||
podRegistry.Err = fmt.Errorf("test error")
|
podRegistry.Err = fmt.Errorf("test error")
|
||||||
storage := RegistryStorage{
|
storage := RegistryStorage{
|
||||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
|
||||||
registry: podRegistry,
|
registry: podRegistry,
|
||||||
}
|
}
|
||||||
desiredState := api.PodState{
|
desiredState := api.PodState{
|
||||||
@ -327,7 +323,6 @@ func TestPodStorageValidatesCreate(t *testing.T) {
|
|||||||
podRegistry := registrytest.NewPodRegistry(nil)
|
podRegistry := registrytest.NewPodRegistry(nil)
|
||||||
podRegistry.Err = fmt.Errorf("test error")
|
podRegistry.Err = fmt.Errorf("test error")
|
||||||
storage := RegistryStorage{
|
storage := RegistryStorage{
|
||||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
|
||||||
registry: podRegistry,
|
registry: podRegistry,
|
||||||
}
|
}
|
||||||
pod := &api.Pod{}
|
pod := &api.Pod{}
|
||||||
@ -344,7 +339,6 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
|
|||||||
podRegistry := registrytest.NewPodRegistry(nil)
|
podRegistry := registrytest.NewPodRegistry(nil)
|
||||||
podRegistry.Err = fmt.Errorf("test error")
|
podRegistry.Err = fmt.Errorf("test error")
|
||||||
storage := RegistryStorage{
|
storage := RegistryStorage{
|
||||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
|
||||||
registry: podRegistry,
|
registry: podRegistry,
|
||||||
}
|
}
|
||||||
pod := &api.Pod{}
|
pod := &api.Pod{}
|
||||||
@ -368,8 +362,6 @@ func TestCreatePod(t *testing.T) {
|
|||||||
storage := RegistryStorage{
|
storage := RegistryStorage{
|
||||||
registry: podRegistry,
|
registry: podRegistry,
|
||||||
podPollPeriod: time.Millisecond * 100,
|
podPollPeriod: time.Millisecond * 100,
|
||||||
scheduler: scheduler.NewRoundRobinScheduler(),
|
|
||||||
minionLister: minion.NewRegistry([]string{"machine"}),
|
|
||||||
}
|
}
|
||||||
desiredState := api.PodState{
|
desiredState := api.PodState{
|
||||||
Manifest: api.ContainerManifest{
|
Manifest: api.ContainerManifest{
|
||||||
|
Loading…
Reference in New Issue
Block a user