kubernetes-sigs / scheduler-plugins

Repository for out-of-tree scheduler plugins based on scheduler framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trimaran common function minor bug fix

knarayan opened this issue · comments

Area

  • Scheduler
  • Controller
  • Helm Chart
  • Documents

Other components

No response

What happened?

This issue fixes below minor bugs found during code walk through:

  1. Bug-1: Trimaran handler.go function OnDelete() needs to delete a node from ScheduledPodsCache if the pod being deleted is the last one associated with that node.

  1. Bug-2: Trimaran handler.go function cleanupCache() deletes older entries. The variable idx represents the index of the first element whose timestamp is within the current interval (assuming the entries are in ascending order of timestamps). When idx == len(cache), all the entries are to be deleted as it indicates that all the elements are older. However, the code currently doesn't delete any element if all the entries are older.

if idx == len(cache) {

What did you expect to happen?

The issues above are functionality bugs.

  1. If we don't fix the cleaning the cache entry map as part of the Bug-1 reported above, then it results into not optimally managing the cache map.

Function TestHandlerCacheAddUpdateDelete with test cases is added to scheduler-plugins/pkg/trimaran/handler_test.go to exercise this. The test cases in this function will fail without this source code change.

  1. If we don't change the if condition idx == len(cache) to address the Bug-2 reported above, then entries outside of the current interval continue to be part of the cache.

cleanupCache_deletes_old_pods_and_node_entry_with_empty_cache added to the function TestHandlerCacheCleanup() of scheduler-plugins/pkg/trimaran/handler_test.go to exercise this scenario will fail without this source code change.

How can we reproduce it (as minimally and precisely as possible)?

Test cases were added to reproduce these issues. Without the changes to the file scheduler-plugins/pkg/trimaran/handler.go, the test cases that are added as specified above will fail.

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here

Scheduler Plugins version

/assign @atantawi @wangchen615

could you please help take a look at the issue and PR?

@Huang-Wei: GitHub didn't allow me to assign the following users: atantawi.

Note that only kubernetes-sigs members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @atantawi @wangchen615

could you please help take a look at the issue and PR?

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.