Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: tried to get listing of all componentstatuses using a labelSelector query selector. I am hitting the apiServer directly. GET /api/v1/componentstatuses What you expected to happen: GET /api/v1/componentstatuses with labelSelector should limit responses to only componentstatuses with the specified label How to reproduce it (as minimally and precisely as possible): run GET /api/v1/componentstatuses with and without a labelSelector against the apiServer. Anything else we need to know?: specifically my label selector is in the form . and i can confirm everything works as expected when i hit GET /api/v1/pods Environment: Kubernetes version (use ): Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.6+IKS", GitCommit:"", GitTreeState:"clean", BuildDate:"2019-05-09T13:26:51Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"} Cloud provider or hardware configuration: IBM OS (e.g: ): Mac Kernel (e.g. ): Darwin Kernel Version 18.5.0 Install tools: Using javascript npm request to talk to api server Network plugin and version (if this is a network-related bug): Others:
/sig api-machinery
i assume its because you cant add a label to componentstatus, but they still shouldnt return if i specify a labelSelector
that's indeed a bug i presume. but what use-case makes you label-querying componentstatus?
we have a bot to periodically run a query that finds all known endpoints on the ApiServer. Then for each of the found endpoints, find all resources with our label defined. sort of an inventory tracking system.
in a similar vein, the endpoint doesnt seem to respect
/priority backlog /help
This request has been marked as needing help from a contributor. Please ensure the request meets the requirements listed . If this request no longer meets these requirements, the label can be removed by commenting with the command. <detailsIn response to : /priority backlog /help Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
I will take a look at this unless no objections
thank you, yours!
a PR for the ComponentStatus API, could you pls kindly take a look? I will look into the metrics API probably over the weekend. Thanks
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale

Discussion:
"//pkg/probe/http:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/internalversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", <ins> "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", </ins> "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library", <ins> "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", </ins> "//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library", <ins> "//staging/src/k8s.io/apiserver/pkg/storage:go_default_library", </ins> ], )

deps = [ "//pkg/apis/core:go_default_library", "//pkg/probe:go_default_library", <ins> "//staging/src/k8s.io/apimachinery/pkg/apis/meta/internalversion:go_default_library", </ins> "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", <ins> "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", </ins> "//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library", "//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library", ],

"fmt" "sync" <ins> "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage" </ins> metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime"

wait.Wait() close(statuses) <ins> pred := componentStatusPredicate(options) </ins> reply := []api.ComponentStatus{} for status := range statuses { <del> reply = append(reply, status) </del> <ins> // ComponentStatus resources currently (v1.14) do not support labeling, however the filtering is executed // nonetheless in case the request contains Label or Field selectors (which will effectively filter out // all of the results and return an empty response). if matched := matchesPredicate(status, &pred); matched { reply = append(reply, status) } </ins> } return &api.ComponentStatusList{Items: reply}, nil } <ins> func componentStatusPredicate(options *metainternalversion.ListOptions) storage.SelectionPredicate { pred := storage.SelectionPredicate{ Label:       labels.Everything(), Field:       fields.Everything(), GetAttrs:    nil, IndexFields: []string{}, } if options != nil { if options.LabelSelector != nil { pred.Label = options.LabelSelector } if options.FieldSelector != nil { pred.Field = options.FieldSelector } } return pred } func matchesPredicate(status api.ComponentStatus, pred *storage.SelectionPredicate) bool { // currently no fields except the generic meta fields are supported for predicate matching fieldsSet := generic.AddObjectMetaFieldsSet(make(fields.Set, 2), &status.ObjectMeta, true) return pred.MatchesObjectAttributes( status.ObjectMeta.Labels, fieldsSet, ) } </ins> func (rs *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { servers := rs.GetServersToValidate()

"strings" "testing" <ins> metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" </ins> "net/http" "net/url" "time"

} } <ins> func TestList_WithLabelSelectors(t *testing.T) { r := NewTestREST(testResponse{result: probe.Success, data: "ok"}) opts := metainternalversion.ListOptions{ LabelSelector: labels.SelectorFromSet(map[string]string{ "testLabel": "testValue", }), } got, err := r.List(genericapirequest.NewContext(), &opts) if err != nil { t.Fatalf("Unexpected error: %v", err) } expect := &api.ComponentStatusList{ Items: []api.ComponentStatus{}, } if e, a := expect, got; !reflect.DeepEqual(e, a) { t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } func TestList_WithFieldSelectors(t *testing.T) { r := NewTestREST(testResponse{result: probe.Success, data: "ok"}) opts := metainternalversion.ListOptions{ FieldSelector: fields.SelectorFromSet(map[string]string{ "testField": "testValue", }), } got, err := r.List(genericapirequest.NewContext(), &opts) if err != nil { t.Fatalf("Unexpected error: %v", err) } expect := &api.ComponentStatusList{ Items: []api.ComponentStatus{}, } if e, a := expect, got; !reflect.DeepEqual(e, a) { t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) } } </ins> func TestList_FailedCheck(t *testing.T) { r := NewTestREST(testResponse{result: probe.Failure, data: ""}) got, err := r.List(genericapirequest.NewContext(), nil)