Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to versioned ListOptions in client. #18645

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func makeTempDirOrDie(prefix string, baseDir string) string {
func podsOnNodes(c *client.Client, podNamespace string, labelSelector labels.Selector) wait.ConditionFunc {
// Wait until all pods are running on the node.
return func() (bool, error) {
options := unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{labelSelector}}
options := api.ListOptions{LabelSelector: labelSelector}
pods, err := c.Pods(podNamespace).List(options)
if err != nil {
glog.Infof("Unable to get pods to list: %v", err)
Expand Down Expand Up @@ -401,7 +401,7 @@ containers:
namespace := kubetypes.NamespaceDefault
if err := wait.Poll(time.Second, longTestTimeout,
podRunning(c, namespace, podName)); err != nil {
if pods, err := c.Pods(namespace).List(unversioned.ListOptions{}); err == nil {
if pods, err := c.Pods(namespace).List(api.ListOptions{}); err == nil {
for _, pod := range pods.Items {
glog.Infof("pod found: %s/%s", namespace, pod.Name)
}
Expand Down Expand Up @@ -509,7 +509,7 @@ func runSelfLinkTestOnNamespace(c *client.Client, namespace string) {
glog.Fatalf("Failed listing service with supplied self link '%v': %v", svc.SelfLink, err)
}

svcList, err := services.List(unversioned.ListOptions{})
svcList, err := services.List(api.ListOptions{})
if err != nil {
glog.Fatalf("Failed listing services: %v", err)
}
Expand Down Expand Up @@ -730,7 +730,7 @@ func runPatchTest(c *client.Client) {

func runMasterServiceTest(client *client.Client) {
time.Sleep(12 * time.Second)
svcList, err := client.Services(api.NamespaceDefault).List(unversioned.ListOptions{})
svcList, err := client.Services(api.NamespaceDefault).List(api.ListOptions{})
if err != nil {
glog.Fatalf("Unexpected error listing services: %v", err)
}
Expand Down Expand Up @@ -857,7 +857,7 @@ func runServiceTest(client *client.Client) {
glog.Fatalf("FAILED: service in other namespace should have no endpoints: %v", err)
}

svcList, err := client.Services(api.NamespaceAll).List(unversioned.ListOptions{})
svcList, err := client.Services(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
glog.Fatalf("Failed to list services across namespaces: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions contrib/mesos/pkg/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ func NewMockPodsListWatch(initialPodList api.PodList) *MockPodsListWatch {
list: initialPodList,
}
lw.ListWatch = cache.ListWatch{
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return lw.fakeWatcher, nil
},
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return &lw.list, nil
},
}
Expand Down
5 changes: 2 additions & 3 deletions contrib/mesos/pkg/scheduler/components/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"k8s.io/kubernetes/contrib/mesos/pkg/scheduler/podtask"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubelet/container"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
Expand Down Expand Up @@ -650,7 +649,7 @@ func (k *framework) makeTaskRegistryReconciler() taskreconciler.Action {
// tasks identified by annotations in the Kubernetes pod registry.
func (k *framework) makePodRegistryReconciler() taskreconciler.Action {
return taskreconciler.Action(func(drv bindings.SchedulerDriver, cancel <-chan struct{}) <-chan error {
podList, err := k.client.Pods(api.NamespaceAll).List(unversioned.ListOptions{})
podList, err := k.client.Pods(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
return proc.ErrorChanf("failed to reconcile pod registry: %v", err)
}
Expand Down Expand Up @@ -726,7 +725,7 @@ func (k *framework) explicitlyReconcileTasks(driver bindings.SchedulerDriver, ta
}

func (ks *framework) recoverTasks() error {
podList, err := ks.client.Pods(api.NamespaceAll).List(unversioned.ListOptions{})
podList, err := ks.client.Pods(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
log.V(1).Infof("failed to recover pod registry, madness may ensue: %v", err)
return err
Expand Down
4 changes: 2 additions & 2 deletions contrib/mesos/pkg/scheduler/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ func NewMockPodsListWatch(initialPodList api.PodList) *MockPodsListWatch {
list: initialPodList,
}
lw.ListWatch = cache.ListWatch{
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return lw.fakeWatcher, nil
},
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
lw.lock.Lock()
defer lw.lock.Unlock()

Expand Down
11 changes: 5 additions & 6 deletions contrib/mesos/pkg/service/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/endpoints"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
kservice "k8s.io/kubernetes/pkg/controller/endpoint"
Expand Down Expand Up @@ -58,10 +57,10 @@ func NewEndpointController(client *client.Client) *endpointController {
}
e.serviceStore.Store, e.serviceController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Services(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Services(api.NamespaceAll).Watch(options)
},
},
Expand All @@ -78,10 +77,10 @@ func NewEndpointController(client *client.Client) *endpointController {

e.podStore.Store, e.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Pods(api.NamespaceAll).Watch(options)
},
},
Expand Down Expand Up @@ -385,7 +384,7 @@ func (e *endpointController) syncService(key string) {
// some stragglers could have been left behind if the endpoint controller
// reboots).
func (e *endpointController) checkLeftoverEndpoints() {
list, err := e.client.Endpoints(api.NamespaceAll).List(unversioned.ListOptions{})
list, err := e.client.Endpoints(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
glog.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)
return
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ var Codec = runtime.CodecFor(Scheme, "")

func init() {
Scheme.AddDefaultingFuncs(
func(obj *ListOptions) {
if obj.LabelSelector == nil {
obj.LabelSelector = labels.Everything()
}
if obj.FieldSelector == nil {
obj.FieldSelector = fields.Everything()
}
},
func(obj *unversioned.ListOptions) {
if obj.LabelSelector.Selector == nil {
obj.LabelSelector = unversioned.LabelSelector{labels.Everything()}
Expand Down
32 changes: 32 additions & 0 deletions pkg/api/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
resource "k8s.io/kubernetes/pkg/api/resource"
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
conversion "k8s.io/kubernetes/pkg/conversion"
fields "k8s.io/kubernetes/pkg/fields"
labels "k8s.io/kubernetes/pkg/labels"
runtime "k8s.io/kubernetes/pkg/runtime"
intstr "k8s.io/kubernetes/pkg/util/intstr"
inf "speter.net/go/exp/math/dec/inf"
Expand Down Expand Up @@ -807,6 +809,35 @@ func deepCopy_api_List(in List, out *List, c *conversion.Cloner) error {
return nil
}

func deepCopy_api_ListOptions(in ListOptions, out *ListOptions, c *conversion.Cloner) error {
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if newVal, err := c.DeepCopy(in.LabelSelector); err != nil {
return err
} else if newVal == nil {
out.LabelSelector = nil
} else {
out.LabelSelector = newVal.(labels.Selector)
}
if newVal, err := c.DeepCopy(in.FieldSelector); err != nil {
return err
} else if newVal == nil {
out.FieldSelector = nil
} else {
out.FieldSelector = newVal.(fields.Selector)
}
out.Watch = in.Watch
out.ResourceVersion = in.ResourceVersion
if in.TimeoutSeconds != nil {
out.TimeoutSeconds = new(int64)
*out.TimeoutSeconds = *in.TimeoutSeconds
} else {
out.TimeoutSeconds = nil
}
return nil
}

func deepCopy_api_LoadBalancerIngress(in LoadBalancerIngress, out *LoadBalancerIngress, c *conversion.Cloner) error {
out.IP = in.IP
out.Hostname = in.Hostname
Expand Down Expand Up @@ -2374,6 +2405,7 @@ func init() {
deepCopy_api_LimitRangeList,
deepCopy_api_LimitRangeSpec,
deepCopy_api_List,
deepCopy_api_ListOptions,
deepCopy_api_LoadBalancerIngress,
deepCopy_api_LoadBalancerStatus,
deepCopy_api_LocalObjectReference,
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func init() {
&PersistentVolumeClaim{},
&PersistentVolumeClaimList{},
&DeleteOptions{},
&ListOptions{},
&PodAttachOptions{},
&PodLogOptions{},
&PodExecOptions{},
Expand All @@ -83,7 +84,6 @@ func init() {

// Register Unversioned types
// TODO this should not be done here
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ListOptions{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.Status{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIVersions{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIGroupList{})
Expand Down Expand Up @@ -123,6 +123,7 @@ func (*PersistentVolumeList) IsAnAPIObject() {}
func (*PersistentVolumeClaim) IsAnAPIObject() {}
func (*PersistentVolumeClaimList) IsAnAPIObject() {}
func (*DeleteOptions) IsAnAPIObject() {}
func (*ListOptions) IsAnAPIObject() {}
func (*PodAttachOptions) IsAnAPIObject() {}
func (*PodLogOptions) IsAnAPIObject() {}
func (*PodExecOptions) IsAnAPIObject() {}
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
j.SelfLink = c.RandString()
},
func(j *api.ListOptions, c fuzz.Continue) {
label, _ := labels.Parse("a=b")
j.LabelSelector = label
field, _ := fields.ParseSelector("a=b")
j.FieldSelector = field
},
func(j *unversioned.ListOptions, c fuzz.Continue) {
// TODO: add some parsing
label, _ := labels.Parse("a=b")
Expand Down