mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +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
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -32,7 +31,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
|
||||
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)
|
||||
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{
|
||||
"pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{
|
||||
CloudProvider: cloud,
|
||||
MinionLister: m.minionRegistry,
|
||||
PodCache: podCache,
|
||||
PodInfoGetter: podInfoGetter,
|
||||
Registry: m.podRegistry,
|
||||
Scheduler: s,
|
||||
}),
|
||||
"replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry),
|
||||
"services": service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
|
||||
@ -39,33 +38,27 @@ import (
|
||||
type RegistryStorage struct {
|
||||
cloudProvider cloudprovider.Interface
|
||||
mu sync.Mutex
|
||||
minionLister scheduler.MinionLister
|
||||
podCache client.PodInfoGetter
|
||||
podInfoGetter client.PodInfoGetter
|
||||
podPollPeriod time.Duration
|
||||
registry Registry
|
||||
scheduler scheduler.Scheduler
|
||||
}
|
||||
|
||||
type RegistryStorageConfig struct {
|
||||
CloudProvider cloudprovider.Interface
|
||||
MinionLister scheduler.MinionLister
|
||||
PodCache client.PodInfoGetter
|
||||
PodInfoGetter client.PodInfoGetter
|
||||
Registry Registry
|
||||
Scheduler scheduler.Scheduler
|
||||
}
|
||||
|
||||
// NewRegistryStorage returns a new RegistryStorage.
|
||||
func NewRegistryStorage(config *RegistryStorageConfig) apiserver.RESTStorage {
|
||||
return &RegistryStorage{
|
||||
cloudProvider: config.CloudProvider,
|
||||
minionLister: config.MinionLister,
|
||||
podCache: config.PodCache,
|
||||
podInfoGetter: config.PodInfoGetter,
|
||||
podPollPeriod: time.Second * 10,
|
||||
registry: config.Registry,
|
||||
scheduler: config.Scheduler,
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +75,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
||||
pod.CreationTimestamp = util.Now()
|
||||
|
||||
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 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) {
|
||||
for {
|
||||
podObj, err := rs.Get(pod.ID)
|
||||
|
@ -25,9 +25,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
||||
"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/scheduler"
|
||||
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
)
|
||||
@ -58,8 +56,7 @@ func TestCreatePodRegistryError(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := RegistryStorage{
|
||||
scheduler: ®istrytest.Scheduler{},
|
||||
registry: podRegistry,
|
||||
registry: podRegistry,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
@ -78,8 +75,7 @@ func TestCreatePodSetsIds(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := RegistryStorage{
|
||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
||||
registry: podRegistry,
|
||||
registry: podRegistry,
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
@ -327,8 +323,7 @@ func TestPodStorageValidatesCreate(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := RegistryStorage{
|
||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
||||
registry: podRegistry,
|
||||
registry: podRegistry,
|
||||
}
|
||||
pod := &api.Pod{}
|
||||
c, err := storage.Create(pod)
|
||||
@ -344,8 +339,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Err = fmt.Errorf("test error")
|
||||
storage := RegistryStorage{
|
||||
scheduler: ®istrytest.Scheduler{Machine: "test"},
|
||||
registry: podRegistry,
|
||||
registry: podRegistry,
|
||||
}
|
||||
pod := &api.Pod{}
|
||||
c, err := storage.Update(pod)
|
||||
@ -368,8 +362,6 @@ func TestCreatePod(t *testing.T) {
|
||||
storage := RegistryStorage{
|
||||
registry: podRegistry,
|
||||
podPollPeriod: time.Millisecond * 100,
|
||||
scheduler: scheduler.NewRoundRobinScheduler(),
|
||||
minionLister: minion.NewRegistry([]string{"machine"}),
|
||||
}
|
||||
desiredState := api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
|
Loading…
Reference in New Issue
Block a user