Skip to content

Commit fd538aa

Browse files
committed
Adjust to lazy restmapper promotion to default
Signed-off-by: Stefan Büringer [email protected]
1 parent 9b363c7 commit fd538aa

File tree

15 files changed

+11
-70
lines changed

15 files changed

+11
-70
lines changed

bootstrap/kubeadm/config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
args:
2222
- "--leader-elect"
2323
- "--metrics-bind-addr=localhost:8080"
24-
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false},LazyRestmapper=${EXP_LAZY_RESTMAPPER:=false}"
24+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}"
2525
- "--bootstrap-token-ttl=${KUBEADM_BOOTSTRAP_TOKEN_TTL:=15m}"
2626
image: controller:latest
2727
name: manager

bootstrap/kubeadm/main.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ import (
2121
"context"
2222
"flag"
2323
"fmt"
24-
"net/http"
2524
_ "net/http/pprof"
2625
"os"
2726
"time"
2827

2928
// +kubebuilder:scaffold:imports
3029
"github.com/spf13/pflag"
3130
corev1 "k8s.io/api/core/v1"
32-
"k8s.io/apimachinery/pkg/api/meta"
3331
"k8s.io/apimachinery/pkg/runtime"
3432
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
35-
"k8s.io/client-go/rest"
3633
"k8s.io/client-go/tools/leaderelection/resourcelock"
3734
cliflag "k8s.io/component-base/cli/flag"
3835
"k8s.io/component-base/logs"
@@ -42,7 +39,6 @@ import (
4239
ctrl "sigs.k8s.io/controller-runtime"
4340
"sigs.k8s.io/controller-runtime/pkg/cache"
4441
"sigs.k8s.io/controller-runtime/pkg/client"
45-
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4642
"sigs.k8s.io/controller-runtime/pkg/controller"
4743
"sigs.k8s.io/controller-runtime/pkg/webhook"
4844

@@ -213,12 +209,6 @@ func main() {
213209
},
214210
}
215211

216-
if feature.Gates.Enabled(feature.LazyRestmapper) {
217-
ctrlOptions.MapperProvider = func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
218-
return apiutil.NewDynamicRESTMapper(c, httpClient, apiutil.WithExperimentalLazyMapper)
219-
}
220-
}
221-
222212
mgr, err := ctrl.NewManager(restConfig, ctrlOptions)
223213
if err != nil {
224214
setupLog.Error(err, "unable to start manager")

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
args:
2323
- "--leader-elect"
2424
- "--metrics-bind-addr=localhost:8080"
25-
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false},LazyRestmapper=${EXP_LAZY_RESTMAPPER:=false}"
25+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false}"
2626
image: controller:latest
2727
name: manager
2828
env:

controllers/remote/cluster_cache_tracker.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/pkg/errors"
3030
corev1 "k8s.io/api/core/v1"
3131
apierrors "k8s.io/apimachinery/pkg/api/errors"
32-
"k8s.io/apimachinery/pkg/api/meta"
3332
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3433
"k8s.io/apimachinery/pkg/runtime"
3534
"k8s.io/apimachinery/pkg/runtime/serializer"
@@ -49,7 +48,6 @@ import (
4948
"sigs.k8s.io/controller-runtime/pkg/source"
5049

5150
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
52-
"sigs.k8s.io/cluster-api/feature"
5351
"sigs.k8s.io/cluster-api/util/certs"
5452
"sigs.k8s.io/cluster-api/util/conditions"
5553
)
@@ -350,13 +348,8 @@ func (t *ClusterCacheTracker) createClient(ctx context.Context, config *rest.Con
350348
return nil, nil, errors.Wrapf(err, "error creating http client for remote cluster %q", cluster.String())
351349
}
352350

353-
var mapper meta.RESTMapper
354351
// Create a mapper for it
355-
if !feature.Gates.Enabled(feature.LazyRestmapper) {
356-
mapper, err = apiutil.NewDynamicRESTMapper(config, httpClient)
357-
} else {
358-
mapper, err = apiutil.NewDynamicRESTMapper(config, httpClient, apiutil.WithExperimentalLazyMapper)
359-
}
352+
mapper, err := apiutil.NewDynamicRESTMapper(config, httpClient)
360353
if err != nil {
361354
return nil, nil, errors.Wrapf(err, "error creating dynamic rest mapper for remote cluster %q", cluster.String())
362355
}

controllers/remote/cluster_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ func TestNewClusterClient(t *testing.T) {
8989
gs := NewWithT(t)
9090

9191
client := fake.NewClientBuilder().WithObjects(validSecret).Build()
92-
_, err := NewClusterClient(ctx, "test-source", client, clusterWithValidKubeConfig)
92+
c, err := NewClusterClient(ctx, "test-source", client, clusterWithValidKubeConfig)
93+
gs.Expect(err).ToNot(HaveOccurred())
94+
9395
// Since we do not have a remote server to connect to, we should expect to get
9496
// an error to that effect for the purpose of this test.
97+
// Note: The error occurs here and not in `NewClusterClient` as with the lazy
98+
// restmapper only the List call actually communicates with the server.
99+
err = c.List(ctx, &corev1.NodeList{})
95100
gs.Expect(err).To(MatchError(ContainSubstring("no such host")))
96101

97102
restConfig, err := RESTConfig(ctx, "test-source", client, clusterWithValidKubeConfig)

controlplane/kubeadm/config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
args:
2222
- "--leader-elect"
2323
- "--metrics-bind-addr=localhost:8080"
24-
- "--feature-gates=ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false},LazyRestmapper=${EXP_LAZY_RESTMAPPER:=false}"
24+
- "--feature-gates=ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}"
2525
image: controller:latest
2626
name: manager
2727
env:

controlplane/kubeadm/main.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"context"
2222
"flag"
2323
"fmt"
24-
"net/http"
2524
_ "net/http/pprof"
2625
"os"
2726
"time"
@@ -31,10 +30,8 @@ import (
3130
appsv1 "k8s.io/api/apps/v1"
3231
corev1 "k8s.io/api/core/v1"
3332
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
34-
"k8s.io/apimachinery/pkg/api/meta"
3533
"k8s.io/apimachinery/pkg/runtime"
3634
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
37-
"k8s.io/client-go/rest"
3835
"k8s.io/client-go/tools/leaderelection/resourcelock"
3936
cliflag "k8s.io/component-base/cli/flag"
4037
"k8s.io/component-base/logs"
@@ -44,7 +41,6 @@ import (
4441
ctrl "sigs.k8s.io/controller-runtime"
4542
"sigs.k8s.io/controller-runtime/pkg/cache"
4643
"sigs.k8s.io/controller-runtime/pkg/client"
47-
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4844
"sigs.k8s.io/controller-runtime/pkg/controller"
4945
"sigs.k8s.io/controller-runtime/pkg/webhook"
5046

@@ -221,12 +217,6 @@ func main() {
221217
},
222218
}
223219

224-
if feature.Gates.Enabled(feature.LazyRestmapper) {
225-
ctrlOptions.MapperProvider = func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
226-
return apiutil.NewDynamicRESTMapper(c, httpClient, apiutil.WithExperimentalLazyMapper)
227-
}
228-
}
229-
230220
mgr, err := ctrl.NewManager(restConfig, ctrlOptions)
231221
if err != nil {
232222
setupLog.Error(err, "unable to start manager")

docs/book/src/developer/testing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ kustomize_substitutions:
267267
EXP_CLUSTER_RESOURCE_SET: "true"
268268
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
269269
EXP_RUNTIME_SDK: "true"
270-
EXP_LAZY_RESTMAPPER: "true"
271270
```
272271
273272
</aside>

docs/book/src/developer/tilt.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ kustomize_substitutions:
110110
EXP_CLUSTER_RESOURCE_SET: "true"
111111
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
112112
EXP_RUNTIME_SDK: "true"
113-
EXP_LAZY_RESTMAPPER: "true"
114113
```
115114

116115
{{#tabs name:"tab-tilt-kustomize-substitution" tabs:"AWS,Azure,DigitalOcean,GCP,vSphere"}}

docs/book/src/tasks/experimental-features/experimental-features.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ variables:
3434
EXP_MACHINE_POOL: "true"
3535
CLUSTER_TOPOLOGY: "true"
3636
EXP_RUNTIME_SDK: "true"
37-
EXP_LAZY_RESTMAPPER: "true"
3837
```
3938

4039
Another way is to set them as environmental variables before running e2e tests.
@@ -49,7 +48,6 @@ kustomize_substitutions:
4948
EXP_MACHINE_POOL: 'true'
5049
CLUSTER_TOPOLOGY: 'true'
5150
EXP_RUNTIME_SDK: 'true'
52-
EXP_LAZY_RESTMAPPER: 'true'
5351
```
5452

5553
For more details on setting up a development environment with `tilt`, see [Developing Cluster API with Tilt](../../developer/tilt.md)
@@ -65,7 +63,7 @@ kubectl edit -n capi-system deployment.apps/capi-controller-manager
6563
// Enable/disable available features by modifying Args below.
6664
Args:
6765
--leader-elect
68-
--feature-gates=MachinePool=true,ClusterResourceSet=true,LazyRestmapper=true
66+
--feature-gates=MachinePool=true,ClusterResourceSet=true
6967
```
7068
7169
Similarly, to **validate** if a particular feature is enabled, see cluster-api-provider deployment arguments by:

0 commit comments

Comments
 (0)