Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2313] Add 2 second delay to UpdateNode() #22

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
run: make pseudo
- name: Run ShellCheck
run: make check_scripts
- name: Unit tests
run: make test
# - name: Unit tests
# run: make test
- name: Code coverage
uses: codecov/codecov-action@v3
with:
Expand Down Expand Up @@ -74,3 +74,8 @@ jobs:
with:
name: ${{ github.job }} stdout (${{ matrix.k8s }}${{ matrix.plugin == '--plugin' && format(', {0}', matrix.plugin) || matrix.plugin }})
path: build/e2e
- name: Upload artifacts-Success
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }} stdout (${{ matrix.k8s }}${{ matrix.plugin == '--plugin' && format(', {0}', matrix.plugin) || matrix.plugin }})
path: build/e2e
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ require (
)

replace (
// remove go routine. delay 2 sec
github.com/apache/yunikorn-core => github.com/chenyulin0719/yunikorn-core v0.0.0-20240115142538-d3b581119dc2
golang.org/x/crypto => golang.org/x/crypto v0.14.0
golang.org/x/lint => golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
golang.org/x/net => golang.org/x/net v0.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves=
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
github.com/apache/yunikorn-core v0.0.0-20240105094327-77e19f6aca27 h1:o38fyYaBl7YurkVf8Lm8IFpPSxAVjRGBh0tlAN5YohY=
github.com/apache/yunikorn-core v0.0.0-20240105094327-77e19f6aca27/go.mod h1:lSAZNt47HGygsVG6mJTl0rW7acBl3tbN/Fg2wGJXYs8=
github.com/apache/yunikorn-scheduler-interface v0.0.0-20240102192148-d4b43d6910c9 h1:9Nj1XB52J7CjUysHwwu1Jf1HNC7fil5F/LkslwZEkN0=
github.com/apache/yunikorn-scheduler-interface v0.0.0-20240102192148-d4b43d6910c9/go.mod h1:zDWV5y9Zh9DM1C65RCVXT1nhNNO8kykVW7bzPFamNYw=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
Expand All @@ -70,6 +68,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chenyulin0719/yunikorn-core v0.0.0-20240115142538-d3b581119dc2 h1:cqhrm+vPwxmaao0b+yyfZoxvnwBEYJeke0RbNZitWq8=
github.com/chenyulin0719/yunikorn-core v0.0.0-20240115142538-d3b581119dc2/go.mod h1:lSAZNt47HGygsVG6mJTl0rW7acBl3tbN/Fg2wGJXYs8=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
10 changes: 10 additions & 0 deletions pkg/cache/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ func (ctx *Context) updateNodeInternal(node *v1.Node, register bool) {
if !common.Equals(prevCapacity, newCapacity) {
// update capacity
if capacity, occupied, ok := ctx.schedulerCache.UpdateCapacity(node.Name, newCapacity); ok {

log.Log(log.ShimContext).Info(fmt.Sprintf("### updateNodeResources when prevCapacity!=newCapacity, node.Name: %v,capacity: %v,occupied: %v, newReady: %v", node.Name, capacity, occupied, newReady))

if err := ctx.updateNodeResources(node, capacity, occupied, newReady); err != nil {
log.Log(log.ShimContext).Warn("Failed to update node capacity", zap.Error(err))
}
Expand All @@ -201,6 +204,9 @@ func (ctx *Context) updateNodeInternal(node *v1.Node, register bool) {
} else if newReady != prevReady {
// update readiness
if capacity, occupied, ok := ctx.schedulerCache.SnapshotResources(node.Name); ok {

log.Log(log.ShimContext).Info(fmt.Sprintf("### updateNodeResources when newReady != prevReady, node.Name: %v,capacity: %v,occupied: %v, newReady: %v", node.Name, capacity, occupied, newReady))

if err := ctx.updateNodeResources(node, capacity, occupied, newReady); err != nil {
log.Log(log.ShimContext).Warn("Failed to update node readiness", zap.Error(err))
}
Expand Down Expand Up @@ -462,6 +468,7 @@ func (ctx *Context) deleteForeignPod(pod *v1.Pod) {
zap.String("podStatusCurrent", string(pod.Status.Phase)))
// this means pod is terminated
// we need sub the occupied resource and re-sync with the scheduler-core

ctx.updateNodeOccupiedResources(pod.Spec.NodeName, pod.Namespace, pod.Name, common.GetPodResource(pod), schedulercache.SubOccupiedResource)
} else {
// pod is orphaned (references an unknown node)
Expand All @@ -479,6 +486,8 @@ func (ctx *Context) updateNodeOccupiedResources(nodeName string, namespace strin
return
}
if node, capacity, occupied, ok := ctx.schedulerCache.UpdateOccupiedResource(nodeName, namespace, podName, resource, opt); ok {
log.Log(log.ShimContext).Info(fmt.Sprintf("### updateNodeResources in updateNodeOccupiedResources, node.Name: %v,capacity: %v,occupied: %v, newReady: %v", node.Name, capacity, occupied, hasReadyCondition(node)))

if err := ctx.updateNodeResources(node, capacity, occupied, hasReadyCondition(node)); err != nil {
log.Log(log.ShimContext).Warn("scheduler rejected update to node occupied resources", zap.Error(err))
}
Expand Down Expand Up @@ -1590,6 +1599,7 @@ func (ctx *Context) decommissionNode(node *v1.Node) error {

func (ctx *Context) updateNodeResources(node *v1.Node, capacity *si.Resource, occupied *si.Resource, ready bool) error {
request := common.CreateUpdateRequestForUpdatedNode(node.Name, capacity, occupied, ready)
log.Log(log.ShimContext).Info(fmt.Sprintf("### Shim trigger SchedulerAPI() request, node.Name: %v,capacity: %v,occupied: %v, ready: %v", node.Name, capacity, occupied, ready))
return ctx.apiProvider.GetAPIs().SchedulerAPI.UpdateNode(request)
}

Expand Down
238 changes: 0 additions & 238 deletions test/e2e/admission_controller/admission_controller_suite_test.go

This file was deleted.

Loading
Loading