Issue 1:
The docker_manager_test needs some refactoring. A few of the problems:

Rampant code duplication (the test is over 2500 lines long)

Fragile tests depending on lots of internal functionality

Cleanup up the test properly may require exposing a few more interfaces from the DockerManager, or just providing better fakes.

Issue 2:
What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.):

service

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

BUG REPORT

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.4", GitCommit:"dd6b458ef8dbf24aff55795baa68f83383c9b3a9", GitTreeState:"clean", BuildDate:"2016-08-01T16:45:16Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.5", GitCommit:"b0deb2eb8f4037421077f77cb163dbb4c0a2a9f5", GitTreeState:"clean", BuildDate:"2016-08-11T20:21:58Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}

Environment:

Cloud provider or hardware configuration: GCE container cluster

What happened:

Tried to create a service, but the service disappeared after a minute or two. Watch doesn't tell any info about the removal. Tried both ClusterIP and NodePort, the same result. Appreciate if someone can explain the cause.

Create the service:

$ kubectl create -f grafana-service.yaml
You have exposed your service on an external port on all nodes in your
cluster. If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:30603) to serve traffic.

See http://releases.k8s.io/release-1.3/docs/user-guide/services-firewalls.md for more details.
service "monitoring-grafana" created

The service was created:

$ kubectl get services --namespace kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default-http-backend 10.3.247.212 <nodes> 80/TCP 2d
heapster 10.3.247.1 <none> 80/TCP 1d
kube-dns 10.3.240.10 <none> 53/UDP,53/TCP 2d
kubernetes-dashboard 10.3.246.164 <none> 80/TCP 2d
monitoring-grafana 10.3.243.215 <nodes> 80/TCP 40s
monitoring-influxdb 10.3.250.25 <none> 8083/TCP,8086/TCP 19m

But it disappeared later on:

$ kubectl get services --namespace kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default-http-backend 10.3.247.212 <nodes> 80/TCP 2d
heapster 10.3.247.1 <none> 80/TCP 1d
kube-dns 10.3.240.10 <none> 53/UDP,53/TCP 2d
kubernetes-dashboard 10.3.246.164 <none> 80/TCP 2d
monitoring-influxdb 10.3.250.25 <none> 8083/TCP,8086/TCP 20m

Below is what I got from watch:

apiVersion: v1
kind: Service
metadata:
creationTimestamp: 2016-08-24T23:09:51Z
labels:
kubernetes.io/cluster-service: "true"
kubernetes.io/name: monitoring-grafana
name: monitoring-grafana
namespace: kube-system
resourceVersion: "57700"
selfLink: /api/v1/namespaces/kube-system/services/monitoring-grafana
uid: dc8a45c5-6a4f-11e6-a055-42010a8a0fc8
spec:
clusterIP: 10.3.243.215
ports:
- nodePort: 30603
port: 80
protocol: TCP
targetPort: 3000
selector:
name: influxGrafana
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}

apiVersion: v1
kind: Service
metadata:
creationTimestamp: 2016-08-24T23:09:51Z
labels:
kubernetes.io/cluster-service: "true"
kubernetes.io/name: monitoring-grafana
name: monitoring-grafana
namespace: kube-system
resourceVersion: "57709"
selfLink: /api/v1/namespaces/kube-system/services/monitoring-grafana
uid: dc8a45c5-6a4f-11e6-a055-42010a8a0fc8
spec:
clusterIP: 10.3.243.215
ports:
- nodePort: 30603
port: 80
protocol: TCP
targetPort: 3000
selector:
name: influxGrafana
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}