Skip to content

Commit ee309ae

Browse files
committed
Make NRT plugin implement PostBind Extension
Signed-off-by: pprokop <[email protected]>
1 parent 7da686c commit ee309ae

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

pkg/noderesourcetopology/cache/cache.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,10 @@ type Interface interface {
5656

5757
// UnreserveNodeResources decrement from the node assumed resources the resources required by the given pod.
5858
UnreserveNodeResources(nodeName string, pod *corev1.Pod)
59+
60+
// PostBind is called after a pod is successfully bound. These plugins are
61+
// informational. A common application of this extension point is for cleaning
62+
// up. If a plugin needs to clean-up its state after a pod is scheduled and
63+
// bound, PostBind is the extension point that it should register.
64+
PostBind(nodeName string, pod *corev1.Pod)
5965
}

pkg/noderesourcetopology/cache/overreserve.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,5 @@ func (ov *OverReserve) Store() *nrtStore {
261261
func logIDFromTime() string {
262262
return fmt.Sprintf("resync%v", time.Now().UnixMilli())
263263
}
264+
265+
func (ov *OverReserve) PostBind(nodeName string, pod *corev1.Pod) {}

pkg/noderesourcetopology/cache/passthrough.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ func (pt Passthrough) NodeMaybeOverReserved(nodeName string, pod *corev1.Pod) {
4848
func (pt Passthrough) NodeHasForeignPods(nodeName string, pod *corev1.Pod) {}
4949
func (pt Passthrough) ReserveNodeResources(nodeName string, pod *corev1.Pod) {}
5050
func (pt Passthrough) UnreserveNodeResources(nodeName string, pod *corev1.Pod) {}
51+
func (pt Passthrough) PostBind(nodeName string, pod *corev1.Pod) {}

pkg/noderesourcetopology/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var _ framework.FilterPlugin = &TopologyMatch{}
9393
var _ framework.ReservePlugin = &TopologyMatch{}
9494
var _ framework.ScorePlugin = &TopologyMatch{}
9595
var _ framework.EnqueueExtensions = &TopologyMatch{}
96+
var _ framework.PostBindPlugin = &TopologyMatch{}
9697

9798
// Name returns name of the plugin. It is used in logs, etc.
9899
func (tm *TopologyMatch) Name() string {

pkg/noderesourcetopology/postbind.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package noderesourcetopology
18+
19+
import (
20+
"context"
21+
22+
corev1 "k8s.io/api/core/v1"
23+
"k8s.io/kubernetes/pkg/scheduler/framework"
24+
)
25+
26+
func (tm *TopologyMatch) PostBind(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) {
27+
tm.nrtCache.PostBind(nodeName, pod)
28+
}

0 commit comments

Comments
 (0)