Skip to content

Commit

Permalink
Remove HostPort conflict checking.
Browse files Browse the repository at this point in the history
We decided to get rid of boundPods.   Removing this check is
a prerequisite for that.  This check had some value before we had
IP-per-Pod.  However, AIUI, use of HostPort is strongly discouraged
in Kubernetes.  It still exists as part of a Pod spec because
of ContainerVM, where it is used.  But, this change does not affect
ContainerVM, where there is no master.

If someone did create pods with HostPort using kubernetes, the following
would happen:
  - The scheduler would try not to put two conflicting pods on the same
    machine (pkg/scheduler/predicates.go : PodFitsPorts() )
  - I'm not sure if it is currently possible for a race to occur where
    the PodFitsPorts check were bypassed.   Maybe it could happen.
  - If the kubelet was sent conflicting pods, it would detect them in
    ( pkg/kubelet/kubelet.go :  filterHostPortConflicts() ).  It would
    arbitrarily pick one pod to run and another to ignore.
  - If all of the above happened and the user filed and issue on github,
    we might figure out that the user used HostPort and tell the user to stop.

TODO:
 - e2e test
 - Several of the demos in examples/ use hostPort.  Change them to
   not specify hostPort and have a service instead.
  • Loading branch information
erictune committed Mar 11, 2015
1 parent 6d465c4 commit 5e8d70f
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 203 deletions.
33 changes: 0 additions & 33 deletions pkg/constraint/constraint.go

This file was deleted.

99 changes: 0 additions & 99 deletions pkg/constraint/constraint_test.go

This file was deleted.

23 changes: 0 additions & 23 deletions pkg/constraint/doc.go

This file was deleted.

43 changes: 0 additions & 43 deletions pkg/constraint/ports.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/registry/pod/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
etcderr "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/generic"
Expand Down Expand Up @@ -193,14 +192,10 @@ func (r *BindingREST) assignPod(ctx api.Context, podID string, machine string) e
if err != nil {
return err
}
// Doing the constraint check this way provides atomicity guarantees.
contKey := makeBoundPodsKey(machine)
err = r.store.Helper.AtomicUpdate(contKey, &api.BoundPods{}, true, func(in runtime.Object) (runtime.Object, error) {
boundPodList := in.(*api.BoundPods)
boundPodList.Items = append(boundPodList.Items, *boundPod)
if errors := constraint.Allowed(boundPodList.Items); len(errors) > 0 {
return nil, fmt.Errorf("the assignment would cause the following constraints violation: %v", errors)
}
return boundPodList, nil
})
if err != nil {
Expand Down

0 comments on commit 5e8d70f

Please sign in to comment.