Skip to content

Commit 4680a9c

Browse files
committed
Unwind feature gates from template controller
1 parent b4d5776 commit 4680a9c

File tree

12 files changed

+26
-89
lines changed

12 files changed

+26
-89
lines changed

cmd/machine-config-controller/start.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
148148
ctx.OpenShiftConfigKubeNamespacedInformerFactory.Core().V1().Secrets(),
149149
ctx.ClientBuilder.KubeClientOrDie("template-controller"),
150150
ctx.ClientBuilder.MachineConfigClientOrDie("template-controller"),
151-
ctx.FeatureGateAccess,
152151
),
153152
// Add all "sub-renderers here"
154153
kubeletconfig.New(

pkg/controller/bootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (b *Bootstrap) Run(destDir string) error {
160160
return fmt.Errorf("error creating feature gate access: %w", err)
161161
}
162162

163-
iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw, fgAccess)
163+
iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw)
164164
if err != nil {
165165
return err
166166
}

pkg/controller/container-runtime-config/container_runtime_config_bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func RunContainerRuntimeBootstrap(templateDir string, crconfigs []*mcfgv1.Contai
3333
}
3434
role := pool.Name
3535
// Generate the original ContainerRuntimeConfig
36-
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role, featureGateAccess)
36+
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role)
3737
if err != nil {
3838
return nil, fmt.Errorf("could not generate origin ContainerRuntime Configs: %w", err)
3939
}

pkg/controller/container-runtime-config/container_runtime_config_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,10 @@ func (ctrl *Controller) handleImgErr(err error, key interface{}) {
426426
}
427427

428428
// generateOriginalContainerRuntimeConfigs returns rendered default storage, registries and policy config files
429-
func generateOriginalContainerRuntimeConfigs(templateDir string, cc *mcfgv1.ControllerConfig, role string, featureGateAccess featuregates.FeatureGateAccess) (*ign3types.File, *ign3types.File, *ign3types.File, error) {
429+
func generateOriginalContainerRuntimeConfigs(templateDir string, cc *mcfgv1.ControllerConfig, role string) (*ign3types.File, *ign3types.File, *ign3types.File, error) {
430430
// Render the default templates
431431
rc := &mtmpl.RenderConfig{
432432
ControllerConfigSpec: &cc.Spec,
433-
FeatureGateAccess: featureGateAccess,
434433
}
435434
generatedConfigs, err := mtmpl.GenerateMachineConfigsForRole(rc, role, templateDir)
436435
if err != nil {
@@ -603,7 +602,7 @@ func (ctrl *Controller) syncContainerRuntimeConfig(key string) error {
603602
}
604603
}
605604
// Generate the original ContainerRuntimeConfig
606-
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(ctrl.templatesDir, controllerConfig, role, ctrl.featureGateAccess)
605+
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(ctrl.templatesDir, controllerConfig, role)
607606
if err != nil {
608607
return ctrl.syncStatusOnly(cfg, err, "could not generate origin ContainerRuntime Configs: %v", err)
609608
}
@@ -903,7 +902,7 @@ func registriesConfigIgnition(templateDir string, controllerConfig *mcfgv1.Contr
903902
)
904903

905904
// Generate the original registries config
906-
_, originalRegistriesIgn, originalPolicyIgn, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role, featureGateAccess)
905+
_, originalRegistriesIgn, originalPolicyIgn, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role)
907906
if err != nil {
908907
return nil, fmt.Errorf("could not generate original ContainerRuntime Configs: %w", err)
909908
}

pkg/controller/kubelet-config/kubelet_config_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (ctrl *Controller) handleFeatureErr(err error, key interface{}) {
361361
// generateOriginalKubeletConfigWithFeatureGates generates a KubeletConfig and ensure the correct feature gates are set
362362
// based on the given FeatureGate.
363363
func generateOriginalKubeletConfigWithFeatureGates(cc *mcfgv1.ControllerConfig, templatesDir, role string, featureGateAccess featuregates.FeatureGateAccess) (*kubeletconfigv1beta1.KubeletConfiguration, error) {
364-
originalKubeletIgn, err := generateOriginalKubeletConfigIgn(cc, templatesDir, role, featureGateAccess)
364+
originalKubeletIgn, err := generateOriginalKubeletConfigIgn(cc, templatesDir, role)
365365
if err != nil {
366366
return nil, fmt.Errorf("could not generate the original Kubelet config ignition: %w", err)
367367
}
@@ -391,9 +391,9 @@ func generateOriginalKubeletConfigWithFeatureGates(cc *mcfgv1.ControllerConfig,
391391
return originalKubeConfig, nil
392392
}
393393

394-
func generateOriginalKubeletConfigIgn(cc *mcfgv1.ControllerConfig, templatesDir, role string, featureGateAccess featuregates.FeatureGateAccess) (*ign3types.File, error) {
394+
func generateOriginalKubeletConfigIgn(cc *mcfgv1.ControllerConfig, templatesDir, role string) (*ign3types.File, error) {
395395
// Render the default templates
396-
rc := &mtmpl.RenderConfig{ControllerConfigSpec: &cc.Spec, FeatureGateAccess: featureGateAccess}
396+
rc := &mtmpl.RenderConfig{ControllerConfigSpec: &cc.Spec}
397397
generatedConfigs, err := mtmpl.GenerateMachineConfigsForRole(rc, role, templatesDir)
398398
if err != nil {
399399
return nil, fmt.Errorf("GenerateMachineConfigsforRole failed with error: %w", err)

pkg/controller/kubelet-config/kubelet_config_features_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestFeatureGateDrift(t *testing.T) {
2828
fgAccess := createNewDefaultFeatureGateAccess()
2929
ctrl := f.newController(fgAccess)
3030

31-
kubeletConfig, err := generateOriginalKubeletConfigIgn(cc, ctrl.templatesDir, "master", fgAccess)
31+
kubeletConfig, err := generateOriginalKubeletConfigIgn(cc, ctrl.templatesDir, "master")
3232
if err != nil {
3333
t.Errorf("could not generate kubelet config from templates %v", err)
3434
}

pkg/controller/kubelet-config/kubelet_config_nodes_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestOriginalKubeletConfigDefaultNodeConfig(t *testing.T) {
2727
fgAccess := createNewDefaultFeatureGateAccess()
2828
ctrl := f.newController(fgAccess)
2929

30-
kubeletConfig, err := generateOriginalKubeletConfigIgn(cc, ctrl.templatesDir, "master", fgAccess)
30+
kubeletConfig, err := generateOriginalKubeletConfigIgn(cc, ctrl.templatesDir, "master")
3131
if err != nil {
3232
t.Errorf("could not generate kubelet config from templates %v", err)
3333
}

pkg/controller/template/render.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
configv1 "github.com/openshift/api/config/v1"
1717
"github.com/openshift/library-go/pkg/cloudprovider"
18-
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
1918

2019
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
2120
"github.com/openshift/machine-config-operator/pkg/constants"
@@ -36,7 +35,6 @@ type RenderConfig struct {
3635
*mcfgv1.ControllerConfigSpec
3736
PullSecret string
3837
InternalRegistryPullSecret string
39-
FeatureGateAccess featuregates.FeatureGateAccess
4038

4139
// no need to set this, will be automatically configured
4240
Constants map[string]string

pkg/controller/template/render_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
ign3types "github.com/coreos/ignition/v2/config/v3_4/types"
1414
configv1 "github.com/openshift/api/config/v1"
15-
"github.com/openshift/library-go/pkg/cloudprovider"
1615
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
1716
"k8s.io/client-go/kubernetes/scheme"
1817

@@ -85,7 +84,7 @@ func TestCloudProvider(t *testing.T) {
8584
},
8685
}
8786

88-
got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil, nil}, name, dummyTemplate)
87+
got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, name, dummyTemplate)
8988
if err != nil {
9089
t.Fatalf("expected nil error %v", err)
9190
}
@@ -146,9 +145,7 @@ func TestCredentialProviderConfigFlag(t *testing.T) {
146145
},
147146
}
148147

149-
fgAccess := featuregates.NewHardcodedFeatureGateAccess(nil, nil)
150-
151-
got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, fgAccess, nil}, name, dummyTemplate)
148+
got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, name, dummyTemplate)
152149
if err != nil {
153150
t.Fatalf("expected nil error %v", err)
154151
}
@@ -240,18 +237,16 @@ func TestInvalidPlatform(t *testing.T) {
240237
}
241238
}
242239

243-
fgAccess := featuregates.NewHardcodedFeatureGateAccess(nil, nil)
244-
245240
// we must treat unrecognized constants as "none"
246241
controllerConfig.Spec.Infra.Status.PlatformStatus.Type = "_bad_"
247-
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, fgAccess, nil}, templateDir)
242+
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, templateDir)
248243
if err != nil {
249244
t.Errorf("expect nil error, got: %v", err)
250245
}
251246

252247
// explicitly blocked
253248
controllerConfig.Spec.Infra.Status.PlatformStatus.Type = "_base"
254-
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, fgAccess, nil}, templateDir)
249+
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, templateDir)
255250
expectErr(err, "failed to create MachineConfig for role master: platform _base unsupported")
256251
}
257252

@@ -262,9 +257,7 @@ func TestGenerateMachineConfigs(t *testing.T) {
262257
t.Fatalf("failed to get controllerconfig config: %v", err)
263258
}
264259

265-
fgAccess := featuregates.NewHardcodedFeatureGateAccess(nil, []configv1.FeatureGateName{cloudprovider.ExternalCloudProviderFeature, cloudprovider.ExternalCloudProviderFeatureAzure, cloudprovider.ExternalCloudProviderFeatureGCP, cloudprovider.ExternalCloudProviderFeatureExternal})
266-
267-
cfgs, err := generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, fgAccess, nil}, templateDir)
260+
cfgs, err := generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, templateDir)
268261
if err != nil {
269262
t.Fatalf("failed to generate machine configs: %v", err)
270263
}
@@ -391,7 +384,7 @@ func TestGetPaths(t *testing.T) {
391384
}
392385
c.res = append(c.res, platformBase)
393386

394-
got := getPaths(&RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil, nil}, config.Spec.Platform)
387+
got := getPaths(&RenderConfig{&config.Spec, `{"dummy":"dummy"}`, `{"dummy":"dummy"}`, nil}, config.Spec.Platform)
395388
if reflect.DeepEqual(got, c.res) {
396389
t.Fatalf("mismatch got: %s want: %s", got, c.res)
397390
}

pkg/controller/template/template_controller.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/openshift/client-go/machineconfiguration/clientset/versioned/scheme"
2020
mcfginformersv1 "github.com/openshift/client-go/machineconfiguration/informers/externalversions/machineconfiguration/v1"
2121
mcfglistersv1 "github.com/openshift/client-go/machineconfiguration/listers/machineconfiguration/v1"
22-
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
2322
mcoResourceApply "github.com/openshift/machine-config-operator/lib/resourceapply"
2423
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
2524
"k8s.io/klog/v2"
@@ -66,8 +65,6 @@ type Controller struct {
6665
mcListerSynced cache.InformerSynced
6766
secretsInformerSynced cache.InformerSynced
6867

69-
featureGateAccess featuregates.FeatureGateAccess
70-
7168
queue workqueue.RateLimitingInterface
7269
}
7370

@@ -79,7 +76,6 @@ func New(
7976
secretsInformer coreinformersv1.SecretInformer,
8077
kubeClient clientset.Interface,
8178
mcfgClient mcfgclientset.Interface,
82-
fgAccess featuregates.FeatureGateAccess,
8379
) *Controller {
8480
eventBroadcaster := record.NewBroadcaster()
8581
eventBroadcaster.StartLogging(klog.Infof)
@@ -121,8 +117,6 @@ func New(
121117
ctrl.mcListerSynced = mcInformer.Informer().HasSynced
122118
ctrl.secretsInformerSynced = secretsInformer.Informer().HasSynced
123119

124-
ctrl.featureGateAccess = fgAccess
125-
126120
return ctrl
127121
}
128122

@@ -563,7 +557,7 @@ func (ctrl *Controller) syncControllerConfig(key string) error {
563557
clusterPullSecretRaw = clusterPullSecret.Data[corev1.DockerConfigJsonKey]
564558
}
565559

566-
mcs, err := getMachineConfigsForControllerConfig(ctrl.templatesDir, cfg, clusterPullSecretRaw, cfg.Spec.InternalRegistryPullSecret, ctrl.featureGateAccess)
560+
mcs, err := getMachineConfigsForControllerConfig(ctrl.templatesDir, cfg, clusterPullSecretRaw, cfg.Spec.InternalRegistryPullSecret)
567561
if err != nil {
568562
return ctrl.syncFailingStatus(cfg, err)
569563
}
@@ -582,7 +576,7 @@ func (ctrl *Controller) syncControllerConfig(key string) error {
582576
return ctrl.syncCompletedStatus(cfg)
583577
}
584578

585-
func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.ControllerConfig, clusterPullSecretRaw, internalRegistryPullSecretRaw []byte, featureGateAccess featuregates.FeatureGateAccess) ([]*mcfgv1.MachineConfig, error) {
579+
func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.ControllerConfig, clusterPullSecretRaw, internalRegistryPullSecretRaw []byte) ([]*mcfgv1.MachineConfig, error) {
586580
buf := &bytes.Buffer{}
587581
if err := json.Compact(buf, clusterPullSecretRaw); err != nil {
588582
return nil, fmt.Errorf("couldn't compact pullsecret %q: %w", string(clusterPullSecretRaw), err)
@@ -591,7 +585,6 @@ func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.Co
591585
ControllerConfigSpec: &config.Spec,
592586
PullSecret: string(buf.Bytes()),
593587
InternalRegistryPullSecret: string(internalRegistryPullSecretRaw),
594-
FeatureGateAccess: featureGateAccess,
595588
}
596589
mcs, err := generateTemplateMachineConfigs(rc, templatesDir)
597590
if err != nil {
@@ -608,6 +601,6 @@ func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.Co
608601
}
609602

610603
// RunBootstrap runs the tempate controller in boostrap mode.
611-
func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte, featureGateAccess featuregates.FeatureGateAccess) ([]*mcfgv1.MachineConfig, error) {
612-
return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, nil, featureGateAccess)
604+
func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte) ([]*mcfgv1.MachineConfig, error) {
605+
return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, nil)
613606
}

0 commit comments

Comments
 (0)