Merge pull request #44482 from k82cn/use_new_bind_api

Automatic merge from submit-queue (batch tested with PRs 44607, 44472, 44482)

Used Pods interface for binding.

Used Pods interface for binding in scheduler.
This commit is contained in:
Kubernetes Submit Queue 2017-04-25 14:47:41 -07:00 committed by GitHub
commit 1c315c64ba
4 changed files with 15 additions and 7 deletions

View File

@ -432,6 +432,17 @@ func (g TestGroup) ResourcePath(resource, namespace, name string) string {
return g.ResourcePathWithPrefix("", resource, namespace, name)
}
// SubResourcePath returns the appropriate path for the given resource, namespace,
// name and subresource.
func (g TestGroup) SubResourcePath(resource, namespace, name, sub string) string {
path := g.ResourcePathWithPrefix("", resource, namespace, name)
if sub != "" {
path = path + "/" + sub
}
return path
}
func (g TestGroup) RESTMapper() meta.RESTMapper {
return api.Registry.RESTMapper()
}

View File

@ -41,7 +41,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
],
)

View File

@ -29,7 +29,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api/v1"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
@ -584,10 +583,7 @@ type binder struct {
// Bind just does a POST binding RPC.
func (b *binder) Bind(binding *v1.Binding) error {
glog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name)
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), binding.Namespace)
return b.Client.Core().RESTClient().Post().Namespace(genericapirequest.NamespaceValue(ctx)).Resource("bindings").Body(binding).Do().Error()
// TODO: use Pods interface for binding once clusters are upgraded
// return b.Pods(binding.Namespace).Bind(binding)
return b.Client.CoreV1().Pods(binding.Namespace).Bind(binding)
}
type podConditionUpdater struct {

View File

@ -278,7 +278,9 @@ func TestBind(t *testing.T) {
continue
}
expectedBody := runtime.EncodeOrDie(testapi.Default.Codec(), item.binding)
handler.ValidateRequest(t, testapi.Default.ResourcePath("bindings", metav1.NamespaceDefault, ""), "POST", &expectedBody)
handler.ValidateRequest(t,
testapi.Default.SubResourcePath("pods", metav1.NamespaceDefault, "foo", "binding"),
"POST", &expectedBody)
}
}