Skip to content

Remove client.ListOptions.Raw hack #727

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

Merged
merged 1 commit into from
Feb 6, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/crds/cluster_v1alpha1_machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ spec:
to indicate what labels, annotations, name prefix, etc., should be
used when creating the Node.
type: object
providerID:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these changes get clobbered if we change the apis and re-run make?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's correct. Ideally we should check this in CI like we do for the clientset.

description: ProviderID is the identification ID of the machine provided
by the provider. This field must match the provider ID as seen on
the node object corresponding to this machine. This field is required
by higher level consumers of cluster-api. Example use case is cluster
autoscaler with cluster-api as provider. Clean-up login in the autoscaler
compares machines v/s nodes to find out machines at provider which
could not get registered as Kubernetes nodes. With cluster-api as
a generic out-of-tree provider for autoscaler, this field is required
by autoscaler to be able to have a provider view of the list of machines.
Another list of nodes is queries from the k8s apiserver and then comparison
is done to find out unregistered machines and are marked for delete.
This field will be set by the actuators and consumed by higher level
entities like autoscaler who will be interfacing with cluster-api
as generic provider.
type: string
providerSpec:
description: ProviderSpec details Provider-specific configuration to
use during node creation.
Expand Down
18 changes: 18 additions & 0 deletions config/crds/cluster_v1alpha1_machinedeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ spec:
Use this to indicate what labels, annotations, name prefix,
etc., should be used when creating the Node.
type: object
providerID:
description: ProviderID is the identification ID of the machine
provided by the provider. This field must match the provider
ID as seen on the node object corresponding to this machine.
This field is required by higher level consumers of cluster-api.
Example use case is cluster autoscaler with cluster-api as
provider. Clean-up login in the autoscaler compares machines
v/s nodes to find out machines at provider which could not
get registered as Kubernetes nodes. With cluster-api as a
generic out-of-tree provider for autoscaler, this field is
required by autoscaler to be able to have a provider view
of the list of machines. Another list of nodes is queries
from the k8s apiserver and then comparison is done to find
out unregistered machines and are marked for delete. This
field will be set by the actuators and consumed by higher
level entities like autoscaler who will be interfacing with
cluster-api as generic provider.
type: string
providerSpec:
description: ProviderSpec details Provider-specific configuration
to use during node creation.
Expand Down
18 changes: 18 additions & 0 deletions config/crds/cluster_v1alpha1_machineset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ spec:
Use this to indicate what labels, annotations, name prefix,
etc., should be used when creating the Node.
type: object
providerID:
description: ProviderID is the identification ID of the machine
provided by the provider. This field must match the provider
ID as seen on the node object corresponding to this machine.
This field is required by higher level consumers of cluster-api.
Example use case is cluster autoscaler with cluster-api as
provider. Clean-up login in the autoscaler compares machines
v/s nodes to find out machines at provider which could not
get registered as Kubernetes nodes. With cluster-api as a
generic out-of-tree provider for autoscaler, this field is
required by autoscaler to be able to have a provider view
of the list of machines. Another list of nodes is queries
from the k8s apiserver and then comparison is done to find
out unregistered machines and are marked for delete. This
field will be set by the actuators and consumed by higher
level entities like autoscaler who will be interfacing with
cluster-api as generic provider.
type: string
providerSpec:
description: ProviderSpec details Provider-specific configuration
to use during node creation.
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/machine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/util:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library",
Expand Down
10 changes: 1 addition & 9 deletions pkg/controller/machine/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/klog"
clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
Expand Down Expand Up @@ -197,15 +196,8 @@ func (r *ReconcileMachine) getCluster(ctx context.Context, machine *clusterv1.Ma
clusterList := clusterv1.ClusterList{}
listOptions := &client.ListOptions{
Namespace: machine.Namespace,
// This is set so the fake client can be used for unit test. See:
// https://github.com/kubernetes-sigs/controller-runtime/issues/168
Raw: &metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
APIVersion: clusterv1.SchemeGroupVersion.String(),
Kind: "Cluster",
},
},
}

if err := r.Client.List(ctx, listOptions, &clusterList); err != nil {
return nil, err
}
Expand Down
24 changes: 0 additions & 24 deletions pkg/controller/machinedeployment/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@ func (r *ReconcileMachineDeployment) getMachineSetsForDeployment(d *v1alpha1.Mac
machineSets := &v1alpha1.MachineSetList{}
listOptions := &client.ListOptions{
Namespace: d.Namespace,
// This is set so the fake client can be used for unit test. See:
// https://github.com/kubernetes-sigs/controller-runtime/issues/168
Raw: &metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
APIVersion: v1alpha1.SchemeGroupVersion.String(),
Kind: "MachineSet",
},
},
}
if err := r.Client.List(context.Background(), listOptions, machineSets); err != nil {
return nil, err
Expand Down Expand Up @@ -206,14 +198,6 @@ func (r *ReconcileMachineDeployment) getMachineDeploymentsForMachineSet(ms *v1al
dList := &v1alpha1.MachineDeploymentList{}
listOptions := &client.ListOptions{
Namespace: ms.Namespace,
// This is set so the fake client can be used for unit test. See:
// https://github.com/kubernetes-sigs/controller-runtime/issues/168
Raw: &metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
APIVersion: v1alpha1.SchemeGroupVersion.String(),
Kind: "MachineDeployment",
},
},
}
if err := r.Client.List(context.Background(), listOptions, dList); err != nil {
klog.Warningf("failed to list machine deployments, %v", err)
Expand Down Expand Up @@ -252,14 +236,6 @@ func (r *ReconcileMachineDeployment) getMachineMapForDeployment(d *v1alpha1.Mach
machines := &v1alpha1.MachineList{}
listOptions := &client.ListOptions{
Namespace: d.Namespace,
// This is set so the fake client can be used for unit test. See:
// https://github.com/kubernetes-sigs/controller-runtime/issues/168
Raw: &metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
APIVersion: v1alpha1.SchemeGroupVersion.String(),
Kind: "Machine",
},
},
}
if err = r.Client.List(context.Background(), listOptions.MatchingLabels(selector), machines); err != nil {
return nil, err
Expand Down
8 changes: 0 additions & 8 deletions pkg/controller/machineset/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ func (c *ReconcileMachineSet) getMachineSetsForMachine(m *v1alpha1.Machine) []*v
msList := &v1alpha1.MachineSetList{}
listOptions := &client.ListOptions{
Namespace: m.Namespace,
// This is set so the fake client can be used for unit test. See:
// https://github.com/kubernetes-sigs/controller-runtime/issues/168
Raw: &metav1.ListOptions{
TypeMeta: metav1.TypeMeta{
APIVersion: v1alpha1.SchemeGroupVersion.String(),
Kind: "MachineSet",
},
},
}

err := c.Client.List(context.Background(), listOptions, msList)
Expand Down