mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-17 13:58:21 +00:00
nfd-master: fix filtering of extended resources
Fix a bug in checking the allowed ".feature.node.kubernetes.io" ns suffix for extended resources. Also update e2e-tests to cover this case.
This commit is contained in:
parent
570722462d
commit
ad13f5f68f
3 changed files with 6 additions and 6 deletions
|
@ -804,7 +804,7 @@ func filterExtendedResources(features *nfdv1alpha1.Features, extendedResources E
|
||||||
func filterExtendedResource(name, value string, features *nfdv1alpha1.Features) (string, error) {
|
func filterExtendedResource(name, value string, features *nfdv1alpha1.Features) (string, error) {
|
||||||
// Check if given NS is allowed
|
// Check if given NS is allowed
|
||||||
ns, _ := splitNs(name)
|
ns, _ := splitNs(name)
|
||||||
if ns != nfdv1alpha1.ExtendedResourceNs && !strings.HasPrefix(ns, nfdv1alpha1.ExtendedResourceSubNsSuffix) {
|
if ns != nfdv1alpha1.ExtendedResourceNs && !strings.HasSuffix(ns, nfdv1alpha1.ExtendedResourceSubNsSuffix) {
|
||||||
if ns == "kubernetes.io" || strings.HasSuffix(ns, ".kubernetes.io") {
|
if ns == "kubernetes.io" || strings.HasSuffix(ns, ".kubernetes.io") {
|
||||||
return "", fmt.Errorf("namespace %q is not allowed", ns)
|
return "", fmt.Errorf("namespace %q is not allowed", ns)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ spec:
|
||||||
|
|
||||||
- name: "e2e static rule"
|
- name: "e2e static rule"
|
||||||
extendedResources:
|
extendedResources:
|
||||||
vendor.io/static: "123"
|
vendor.feature.node.kubernetes.io/static: "123"
|
||||||
matchFeatures:
|
matchFeatures:
|
||||||
|
|
||||||
- name: "e2e not allowed rule"
|
- name: "e2e not allowed rule"
|
||||||
|
|
|
@ -771,13 +771,13 @@ core:
|
||||||
expectedTaints["*"] = []corev1.Taint{}
|
expectedTaints["*"] = []corev1.Taint{}
|
||||||
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchTaints(expectedTaints, nodes, false))
|
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchTaints(expectedTaints, nodes, false))
|
||||||
|
|
||||||
expectedAnnotations["*"] = k8sAnnotations{"nfd.node.kubernetes.io/extended-resources": "nons,vendor.io/dynamic,vendor.io/static"}
|
expectedAnnotations["*"] = k8sAnnotations{"nfd.node.kubernetes.io/extended-resources": "nons,vendor.feature.node.kubernetes.io/static,vendor.io/dynamic"}
|
||||||
|
|
||||||
expectedCapacity := map[string]corev1.ResourceList{
|
expectedCapacity := map[string]corev1.ResourceList{
|
||||||
"*": {
|
"*": {
|
||||||
"feature.node.kubernetes.io/nons": resourcev1.MustParse("123"),
|
"feature.node.kubernetes.io/nons": resourcev1.MustParse("123"),
|
||||||
"vendor.io/dynamic": resourcev1.MustParse("10"),
|
"vendor.io/dynamic": resourcev1.MustParse("10"),
|
||||||
"vendor.io/static": resourcev1.MustParse("123"),
|
"vendor.feature.node.kubernetes.io/static": resourcev1.MustParse("123"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue