Enforce unique constraint at namespace boundary in etcd, make client and server namespace aware

This commit is contained in:
derekwaynecarr
2014-10-03 11:44:06 -04:00
parent b63974bd21
commit 085ca40291
15 changed files with 642 additions and 186 deletions

View File

@@ -184,7 +184,8 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
backoff.wait(podID)
// Get the pod again; it may have changed/been scheduled already.
pod = &api.Pod{}
err := factory.Client.Get().Path("pods").Path(podID).Do().Into(pod)
ctx := api.WithNamespace(api.NewContext(), pod.Namespace)
err := factory.Client.Get().Namespace(api.Namespace(ctx)).Path("pods").Path(podID).Do().Into(pod)
if err != nil {
glog.Errorf("Error getting pod %v for retry: %v; abandoning", podID, err)
return
@@ -256,7 +257,8 @@ type binder struct {
// Bind just does a POST binding RPC.
func (b *binder) Bind(binding *api.Binding) error {
glog.V(2).Infof("Attempting to bind %v to %v", binding.PodID, binding.Host)
return b.Post().Path("bindings").Body(binding).Do().Error()
ctx := api.WithNamespace(api.NewContext(), binding.Namespace)
return b.Post().Namespace(api.Namespace(ctx)).Path("bindings").Body(binding).Do().Error()
}
type clock interface {

View File

@@ -73,8 +73,9 @@ func (s *Scheduler) scheduleOne() {
return
}
b := &api.Binding{
PodID: pod.ID,
Host: dest,
TypeMeta: api.TypeMeta{Namespace: pod.Namespace},
PodID: pod.ID,
Host: dest,
}
if err := s.config.Binder.Bind(b); err != nil {
record.Eventf(pod, "", string(api.PodWaiting), "failedScheduling", "Binding rejected: %v", err)