From 22eac85190e81e160c5232b202862a6d13db27c5 Mon Sep 17 00:00:00 2001 From: mqliang Date: Tue, 6 Oct 2015 09:01:05 +0800 Subject: [PATCH] write log when two replication controller overlap --- pkg/controller/replication/replication_controller.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/controller/replication/replication_controller.go b/pkg/controller/replication/replication_controller.go index c912588b2c..c7d9ea8a70 100644 --- a/pkg/controller/replication/replication_controller.go +++ b/pkg/controller/replication/replication_controller.go @@ -211,7 +211,13 @@ func (rm *ReplicationManager) getPodController(pod *api.Pod) *api.ReplicationCon // rc1 (older rc): [(k1=v1)], replicas=1 rc2: [(k2=v2)], replicas=2 // pod: [(k1:v1), (k2:v2)] will wake both rc1 and rc2, and we will sync rc1. // pod: [(k2:v2)] will wake rc2 which creates a new replica. - sort.Sort(overlappingControllers(controllers)) + if len(controllers) > 1 { + // More than two items in this list indicates user error. If two replication-controller + // overlap, sort by creation timestamp, subsort by name, then pick + // the first. + glog.Errorf("user error! more than one replication controller is selecting pods with labels: %+v", pod.Labels) + sort.Sort(overlappingControllers(controllers)) + } return &controllers[0] }