Skip to content

Commit c7347b5

Browse files
committed
nrt: deps: use noderesourcetopology API alpha1v2 helpers
The noderesourcetyoopology API v1alpha2 features a helper package to factor in the most common operations performed on the API, starting with attribute manipulation. We bring the extra little dep in so we can remove our own implementation. Signed-off-by: Francesco Romani <[email protected]>
1 parent 7609fea commit c7347b5

File tree

5 files changed

+100
-15
lines changed

5 files changed

+100
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/dustin/go-humanize v1.0.0
99
github.com/go-logr/logr v1.2.3
1010
github.com/google/go-cmp v0.5.9
11-
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.0
11+
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.1
1212
github.com/k8stopologyawareschedwg/podfingerprint v0.2.0
1313
github.com/patrickmn/go-cache v2.1.0+incompatible
1414
github.com/paypal/load-watcher v0.2.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
295295
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
296296
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
297297
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
298-
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.0 h1:2uCRJbv+A+fmaUaO0wLZ8oYd6cLE1dRzBQcFNxggH3s=
299-
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.0/go.mod h1:AkACMQGiTgCt0lQw3m7TTU8PLH9lYKNK5e9DqFf5VuM=
298+
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.1 h1:BI3L7hNqRvXtB42FO4NI/0ZjDDVRPOMBDFLShhFtf28=
299+
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.1/go.mod h1:AkACMQGiTgCt0lQw3m7TTU8PLH9lYKNK5e9DqFf5VuM=
300300
github.com/k8stopologyawareschedwg/podfingerprint v0.2.0 h1:3Wc58WPBqG0yry0noEARZIAljBOU7TQZDg1L7dQTyw0=
301301
github.com/k8stopologyawareschedwg/podfingerprint v0.2.0/go.mod h1:C23pM15t06dXg/OihGlqBvnYzLr+MXDXJ7zMfbNAyXI=
302302
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

pkg/noderesourcetopology/cache/store.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/klog/v2"
2525

2626
topologyv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
27+
topologyv1alpha2attr "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2/helper/attribute"
2728

2829
"sigs.k8s.io/scheduler-plugins/pkg/noderesourcetopology/stringify"
2930
"sigs.k8s.io/scheduler-plugins/pkg/util"
@@ -195,8 +196,8 @@ func (cnt counter) Len() int {
195196
// podFingerprintForNodeTopology extracts without recomputing the pods fingerprint from
196197
// the provided Node Resource Topology object.
197198
func podFingerprintForNodeTopology(nrt *topologyv1alpha2.NodeResourceTopology) string {
198-
if attrValue, ok := findAttribute(nrt.Attributes, podfingerprint.Attribute); ok {
199-
return attrValue
199+
if attr, ok := topologyv1alpha2attr.Get(nrt.Attributes, podfingerprint.Attribute); ok {
200+
return attr.Value
200201
}
201202
if nrt.Annotations != nil {
202203
return nrt.Annotations[podfingerprint.Annotation]
@@ -225,12 +226,3 @@ func checkPodFingerprintForNode(logID string, indexer NodeIndexer, nodeName, pfp
225226

226227
return pfp.Check(pfpExpected)
227228
}
228-
229-
func findAttribute(attrs topologyv1alpha2.AttributeList, name string) (string, bool) {
230-
for _, attr := range attrs {
231-
if attr.Name == name {
232-
return attr.Value, true
233-
}
234-
}
235-
return "", false
236-
}

vendor/github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2/helper/attribute/attribute.go

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,12 @@ github.com/jpillora/backoff
185185
# github.com/json-iterator/go v1.1.12
186186
## explicit; go 1.12
187187
github.com/json-iterator/go
188-
# github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.0
188+
# github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.1
189189
## explicit; go 1.16
190190
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology
191191
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha1
192192
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2
193+
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2/helper/attribute
193194
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned
194195
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned/fake
195196
github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned/scheme

0 commit comments

Comments
 (0)