mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
Merge pull request #3810 from ironcladlou/cache-namespacing
Support namespacing in cache.Store
This commit is contained in:
@@ -35,9 +35,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
PodLister = &cache.StoreToPodLister{cache.NewStore()}
|
||||
MinionLister = &cache.StoreToNodeLister{cache.NewStore()}
|
||||
ServiceLister = &cache.StoreToServiceLister{cache.NewStore()}
|
||||
PodLister = &cache.StoreToPodLister{cache.NewStore(cache.MetaNamespaceKeyFunc)}
|
||||
MinionLister = &cache.StoreToNodeLister{cache.NewStore(cache.MetaNamespaceKeyFunc)}
|
||||
ServiceLister = &cache.StoreToServiceLister{cache.NewStore(cache.MetaNamespaceKeyFunc)}
|
||||
)
|
||||
|
||||
// ConfigFactory knows how to fill out a scheduler config with its support functions.
|
||||
@@ -57,7 +57,7 @@ type ConfigFactory struct {
|
||||
func NewConfigFactory(client *client.Client) *ConfigFactory {
|
||||
return &ConfigFactory{
|
||||
Client: client,
|
||||
PodQueue: cache.NewFIFO(),
|
||||
PodQueue: cache.NewFIFO(cache.MetaNamespaceKeyFunc),
|
||||
PodLister: PodLister,
|
||||
MinionLister: MinionLister,
|
||||
ServiceLister: ServiceLister,
|
||||
@@ -241,7 +241,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
||||
return
|
||||
}
|
||||
if pod.Status.Host == "" {
|
||||
podQueue.Add(pod.Name, pod)
|
||||
podQueue.Add(pod)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -261,8 +261,8 @@ func (ne *nodeEnumerator) Len() int {
|
||||
}
|
||||
|
||||
// Get returns the item (and ID) with the particular index.
|
||||
func (ne *nodeEnumerator) Get(index int) (string, interface{}) {
|
||||
return ne.Items[index].Name, &ne.Items[index]
|
||||
func (ne *nodeEnumerator) Get(index int) interface{} {
|
||||
return &ne.Items[index]
|
||||
}
|
||||
|
||||
type binder struct {
|
||||
|
@@ -208,7 +208,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||
server := httptest.NewServer(mux)
|
||||
defer server.Close()
|
||||
factory := NewConfigFactory(client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()}))
|
||||
queue := cache.NewFIFO()
|
||||
queue := cache.NewFIFO(cache.MetaNamespaceKeyFunc)
|
||||
podBackoff := podBackoff{
|
||||
perPodBackoff: map[string]*backoffEntry{},
|
||||
clock: &fakeClock{},
|
||||
@@ -223,7 +223,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||
// whole error handling system in the future. The test will time
|
||||
// out if something doesn't work.
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
got, exists := queue.Get("foo")
|
||||
got, exists, _ := queue.Get(testPod)
|
||||
if !exists {
|
||||
continue
|
||||
}
|
||||
@@ -249,8 +249,8 @@ func TestMinionEnumerator(t *testing.T) {
|
||||
t.Fatalf("expected %v, got %v", e, a)
|
||||
}
|
||||
for i := range testList.Items {
|
||||
gotID, gotObj := me.Get(i)
|
||||
if e, a := testList.Items[i].Name, gotID; e != a {
|
||||
gotObj := me.Get(i)
|
||||
if e, a := testList.Items[i].Name, gotObj.(*api.Node).Name; e != a {
|
||||
t.Errorf("Expected %v, got %v", e, a)
|
||||
}
|
||||
if e, a := &testList.Items[i], gotObj; !reflect.DeepEqual(e, a) {
|
||||
|
Reference in New Issue
Block a user