Skip to content

Commit

Permalink
refine log and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihanJiang96 committed Apr 27, 2024
1 parent 15ca53f commit e6ab343
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func currentlyDrainedPods(context *context.AutoscalingContext) []*apiv1.Pod {
for _, podInfo := range nodeInfo.Pods {
// Filter out pods that has deletion timestamp set
if podInfo.Pod.DeletionTimestamp != nil {
klog.Infof("Pod %v has deletion timestamp set, skipping", podInfo.Pod.Name)
klog.Infof("Pod %v has deletion timestamp set, skipping injection to unschedulable pods list", podInfo.Pod.Name)
continue
}
pods = append(pods, podInfo.Pod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestCurrentlyDrainedNodesPodListProcessor(t *testing.T) {
},
pods: []*apiv1.Pod{
BuildScheduledTestPod("p1", 100, 1, "n"),
BuildTestPodWithDeletionTimestamp("p2", 200, 1, "n", time.Now()),
BuildTestPod("p2", 200, 1, WithNodeName("n"), WithDeletionTimestamp(time.Now())),
},
wantPods: []*apiv1.Pod{
BuildTestPod("p1", 100, 1),
Expand Down
14 changes: 7 additions & 7 deletions cluster-autoscaler/utils/test/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ func WithMaxSkew(maxSkew int32, topologySpreadingKey string) func(*apiv1.Pod) {
}
}

// WithDeletionTimestamp sets deletion timestamp to the pod.
func WithDeletionTimestamp(deletionTimestamp time.Time) func(*apiv1.Pod) {
return func(pod *apiv1.Pod) {
pod.DeletionTimestamp = &metav1.Time{Time: deletionTimestamp}
}
}

// BuildTestPodWithEphemeralStorage creates a pod with cpu, memory and ephemeral storage resources.
func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod {
startTime := metav1.Unix(0, 0)
Expand Down Expand Up @@ -195,13 +202,6 @@ func BuildScheduledTestPod(name string, cpu, memory int64, nodeName string) *api
return p
}

// BuildTestPodWithDeletionTimestamp builds a test pod with deletion timestamp set
func BuildTestPodWithDeletionTimestamp(name string, cpu, memory int64, nodeName string, deletionTimestamp time.Time) *apiv1.Pod {
p := BuildScheduledTestPod(name, cpu, memory, nodeName)
p.DeletionTimestamp = &metav1.Time{Time: deletionTimestamp}
return p
}

// SetStaticPodSpec sets pod spec to make it a static pod
func SetStaticPodSpec(pod *apiv1.Pod) *apiv1.Pod {
pod.Annotations[kube_types.ConfigSourceAnnotationKey] = kube_types.FileSource
Expand Down

0 comments on commit e6ab343

Please sign in to comment.