mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
move daemonset to generalized label selector
This commit is contained in:
6
pkg/client/cache/listers.go
vendored
6
pkg/client/cache/listers.go
vendored
@@ -247,7 +247,11 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex
|
||||
if daemonSet.Namespace != pod.Namespace {
|
||||
continue
|
||||
}
|
||||
selector = labels.Set(daemonSet.Spec.Selector).AsSelector()
|
||||
selector, err = extensions.PodSelectorAsSelector(daemonSet.Spec.Selector)
|
||||
if err != nil {
|
||||
// this should not happen if the DaemonSet passed validation
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything.
|
||||
if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) {
|
||||
|
||||
6
pkg/client/cache/listers_test.go
vendored
6
pkg/client/cache/listers_test.go
vendored
@@ -272,7 +272,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{"foo": "baz"},
|
||||
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "baz"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -311,13 +311,13 @@ func TestStoreToDaemonSetLister(t *testing.T) {
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
},
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Selector: &extensions.PodSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user