Skip to content

Commit 478cfe2

Browse files
authored
Merge pull request #14923 from aveshagarwal/master-rhbz-1449891
UPSTREAM: kubernetes-incubator/cluster-capacity: 81: Fix cluster-capacity to avoid pending pods not created by it.
2 parents 3ff2db7 + 75c4fb6 commit 478cfe2

File tree

1 file changed

+15
-1
lines changed
  • cmd/cluster-capacity/go/src/github.com/kubernetes-incubator/cluster-capacity/pkg/framework

1 file changed

+15
-1
lines changed

cmd/cluster-capacity/go/src/github.com/kubernetes-incubator/cluster-capacity/pkg/framework/simulator.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ import (
5151
"github.com/kubernetes-incubator/cluster-capacity/pkg/framework/strategy"
5252
)
5353

54+
const (
55+
podProvisioner = "cc.kubernetes.io/provisioned-by"
56+
)
57+
5458
type ClusterCapacity struct {
5559
// caches modified by emulation strategy
5660
resourceStore store.ResourceStore
@@ -210,7 +214,9 @@ func (c *ClusterCapacity) Close() {
210214

211215
func (c *ClusterCapacity) Update(pod *v1.Pod, podCondition *v1.PodCondition, schedulerName string) error {
212216
stop := podCondition.Type == v1.PodScheduled && podCondition.Status == v1.ConditionFalse && podCondition.Reason == "Unschedulable"
213-
if stop {
217+
218+
// Only for pending pods provisioned by cluster-capacity
219+
if stop && metav1.HasAnnotation(pod.ObjectMeta, podProvisioner) {
214220
c.status.StopReason = fmt.Sprintf("%v: %v", podCondition.Reason, podCondition.Message)
215221
c.Close()
216222
// The Update function can be run more than once before any corresponding
@@ -235,6 +241,14 @@ func (c *ClusterCapacity) nextPod() error {
235241
// use simulated pod name with an index to construct the name
236242
pod.ObjectMeta.Name = fmt.Sprintf("%v-%v", c.simulatedPod.Name, c.simulated)
237243

244+
// Add pod provisioner annotation
245+
if pod.ObjectMeta.Annotations == nil {
246+
pod.ObjectMeta.Annotations = map[string]string{}
247+
}
248+
249+
// Stores the scheduler name
250+
pod.ObjectMeta.Annotations[podProvisioner] = c.defaultScheduler
251+
238252
c.simulated++
239253
c.lastSimulatedPod = &pod
240254

0 commit comments

Comments
 (0)