Skip to content

Commit 1ae2c05

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

14 files changed

+35
-110
lines changed

cmd/machine-config-controller/start.go

Lines changed: 0 additions & 2 deletions
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(
@@ -177,7 +176,6 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
177176
ctx.ClientBuilder.KubeClientOrDie("container-runtime-config-controller"),
178177
ctx.ClientBuilder.MachineConfigClientOrDie("container-runtime-config-controller"),
179178
ctx.ClientBuilder.ConfigClientOrDie("container-runtime-config-controller"),
180-
ctx.FeatureGateAccess,
181179
),
182180
// The renderer creates "rendered" MCs from the MC fragments generated by
183181
// the above sub-controllers, which are then consumed by the node controller

pkg/controller/bootstrap/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ 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
}
167167
klog.Infof("Successfully generated MachineConfigs from templates.")
168168

169169
configs = append(configs, iconfigs...)
170170

171-
rconfigs, err := containerruntimeconfig.RunImageBootstrap(b.templatesDir, cconfig, pools, icspRules, idmsRules, itmsRules, imgCfg, fgAccess)
171+
rconfigs, err := containerruntimeconfig.RunImageBootstrap(b.templatesDir, cconfig, pools, icspRules, idmsRules, itmsRules, imgCfg)
172172
if err != nil {
173173
return err
174174
}
@@ -177,7 +177,7 @@ func (b *Bootstrap) Run(destDir string) error {
177177
configs = append(configs, rconfigs...)
178178

179179
if len(crconfigs) > 0 {
180-
containerRuntimeConfigs, err := containerruntimeconfig.RunContainerRuntimeBootstrap(b.templatesDir, crconfigs, cconfig, pools, fgAccess)
180+
containerRuntimeConfigs, err := containerruntimeconfig.RunContainerRuntimeBootstrap(b.templatesDir, crconfigs, cconfig, pools)
181181
if err != nil {
182182
return err
183183
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55

66
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
7-
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
87
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
98
"github.com/openshift/machine-config-operator/pkg/version"
109
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -13,7 +12,7 @@ import (
1312
)
1413

1514
// RunContainerRuntimeBootstrap generates ignition configs at bootstrap
16-
func RunContainerRuntimeBootstrap(templateDir string, crconfigs []*mcfgv1.ContainerRuntimeConfig, controllerConfig *mcfgv1.ControllerConfig, mcpPools []*mcfgv1.MachineConfigPool, featureGateAccess featuregates.FeatureGateAccess) ([]*mcfgv1.MachineConfig, error) {
15+
func RunContainerRuntimeBootstrap(templateDir string, crconfigs []*mcfgv1.ContainerRuntimeConfig, controllerConfig *mcfgv1.ControllerConfig, mcpPools []*mcfgv1.MachineConfigPool) ([]*mcfgv1.MachineConfig, error) {
1716
var res []*mcfgv1.MachineConfig
1817
managedKeyExist := make(map[string]bool)
1918
for _, cfg := range crconfigs {
@@ -33,7 +32,7 @@ func RunContainerRuntimeBootstrap(templateDir string, crconfigs []*mcfgv1.Contai
3332
}
3433
role := pool.Name
3534
// Generate the original ContainerRuntimeConfig
36-
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role, featureGateAccess)
35+
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role)
3736
if err != nil {
3837
return nil, fmt.Errorf("could not generate origin ContainerRuntime Configs: %w", err)
3938
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestAddKubeletCfgAfterBootstrapKubeletCfg(t *testing.T) {
2929
f.mccrLister = append(f.mccrLister, ctrcfg)
3030
f.objects = append(f.objects, ctrcfg)
3131

32-
mcs, err := RunContainerRuntimeBootstrap("../../../templates", []*mcfgv1.ContainerRuntimeConfig{ctrcfg}, cc, pools, f.fgAccess)
32+
mcs, err := RunContainerRuntimeBootstrap("../../../templates", []*mcfgv1.ContainerRuntimeConfig{ctrcfg}, cc, pools)
3333
require.NoError(t, err)
3434
require.Len(t, mcs, 1)
3535

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
cligolistersv1 "github.com/openshift/client-go/config/listers/config/v1"
1818
operatorinformersv1alpha1 "github.com/openshift/client-go/operator/informers/externalversions/operator/v1alpha1"
1919
operatorlistersv1alpha1 "github.com/openshift/client-go/operator/listers/operator/v1alpha1"
20-
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
2120
corev1 "k8s.io/api/core/v1"
2221
"k8s.io/apimachinery/pkg/api/equality"
2322
"k8s.io/apimachinery/pkg/api/errors"
@@ -104,8 +103,6 @@ type Controller struct {
104103
clusterVersionLister cligolistersv1.ClusterVersionLister
105104
clusterVersionListerSynced cache.InformerSynced
106105

107-
featureGateAccess featuregates.FeatureGateAccess
108-
109106
queue workqueue.RateLimitingInterface
110107
imgQueue workqueue.RateLimitingInterface
111108
}
@@ -124,7 +121,6 @@ func New(
124121
kubeClient clientset.Interface,
125122
mcfgClient mcfgclientset.Interface,
126123
configClient configclientset.Interface,
127-
featureGateAccess featuregates.FeatureGateAccess,
128124
) *Controller {
129125
eventBroadcaster := record.NewBroadcaster()
130126
eventBroadcaster.StartLogging(klog.Infof)
@@ -197,8 +193,6 @@ func New(
197193
ctrl.clusterVersionLister = clusterVersionInformer.Lister()
198194
ctrl.clusterVersionListerSynced = clusterVersionInformer.Informer().HasSynced
199195

200-
ctrl.featureGateAccess = featureGateAccess
201-
202196
return ctrl
203197
}
204198

@@ -426,11 +420,10 @@ func (ctrl *Controller) handleImgErr(err error, key interface{}) {
426420
}
427421

428422
// 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) {
423+
func generateOriginalContainerRuntimeConfigs(templateDir string, cc *mcfgv1.ControllerConfig, role string) (*ign3types.File, *ign3types.File, *ign3types.File, error) {
430424
// Render the default templates
431425
rc := &mtmpl.RenderConfig{
432426
ControllerConfigSpec: &cc.Spec,
433-
FeatureGateAccess: featureGateAccess,
434427
}
435428
generatedConfigs, err := mtmpl.GenerateMachineConfigsForRole(rc, role, templateDir)
436429
if err != nil {
@@ -603,7 +596,7 @@ func (ctrl *Controller) syncContainerRuntimeConfig(key string) error {
603596
}
604597
}
605598
// Generate the original ContainerRuntimeConfig
606-
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(ctrl.templatesDir, controllerConfig, role, ctrl.featureGateAccess)
599+
originalStorageIgn, _, _, err := generateOriginalContainerRuntimeConfigs(ctrl.templatesDir, controllerConfig, role)
607600
if err != nil {
608601
return ctrl.syncStatusOnly(cfg, err, "could not generate origin ContainerRuntime Configs: %v", err)
609602
}
@@ -833,7 +826,7 @@ func (ctrl *Controller) syncImageConfig(key string) error {
833826
if err := retry.RetryOnConflict(updateBackoff, func() error {
834827
registriesIgn, err := registriesConfigIgnition(ctrl.templatesDir, controllerConfig, role, releaseImage,
835828
imgcfg.Spec.RegistrySources.InsecureRegistries, registriesBlocked, policyBlocked, allowedRegs,
836-
imgcfg.Spec.RegistrySources.ContainerRuntimeSearchRegistries, icspRules, idmsRules, itmsRules, ctrl.featureGateAccess)
829+
imgcfg.Spec.RegistrySources.ContainerRuntimeSearchRegistries, icspRules, idmsRules, itmsRules)
837830
if err != nil {
838831
return err
839832
}
@@ -895,15 +888,15 @@ func (ctrl *Controller) syncImageConfig(key string) error {
895888

896889
func registriesConfigIgnition(templateDir string, controllerConfig *mcfgv1.ControllerConfig, role, releaseImage string,
897890
insecureRegs, registriesBlocked, policyBlocked, allowedRegs, searchRegs []string,
898-
icspRules []*apioperatorsv1alpha1.ImageContentSourcePolicy, idmsRules []*apicfgv1.ImageDigestMirrorSet, itmsRules []*apicfgv1.ImageTagMirrorSet, featureGateAccess featuregates.FeatureGateAccess) (*ign3types.Config, error) {
891+
icspRules []*apioperatorsv1alpha1.ImageContentSourcePolicy, idmsRules []*apicfgv1.ImageDigestMirrorSet, itmsRules []*apicfgv1.ImageTagMirrorSet) (*ign3types.Config, error) {
899892

900893
var (
901894
registriesTOML []byte
902895
policyJSON []byte
903896
)
904897

905898
// Generate the original registries config
906-
_, originalRegistriesIgn, originalPolicyIgn, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role, featureGateAccess)
899+
_, originalRegistriesIgn, originalPolicyIgn, err := generateOriginalContainerRuntimeConfigs(templateDir, controllerConfig, role)
907900
if err != nil {
908901
return nil, fmt.Errorf("could not generate original ContainerRuntime Configs: %w", err)
909902
}
@@ -949,7 +942,7 @@ func registriesConfigIgnition(templateDir string, controllerConfig *mcfgv1.Contr
949942
// RunImageBootstrap generates MachineConfig objects for mcpPools that would have been generated by syncImageConfig,
950943
// except that mcfgv1.Image is not available.
951944
func RunImageBootstrap(templateDir string, controllerConfig *mcfgv1.ControllerConfig, mcpPools []*mcfgv1.MachineConfigPool, icspRules []*apioperatorsv1alpha1.ImageContentSourcePolicy,
952-
idmsRules []*apicfgv1.ImageDigestMirrorSet, itmsRules []*apicfgv1.ImageTagMirrorSet, imgCfg *apicfgv1.Image, featureGateAccess featuregates.FeatureGateAccess) ([]*mcfgv1.MachineConfig, error) {
945+
idmsRules []*apicfgv1.ImageDigestMirrorSet, itmsRules []*apicfgv1.ImageTagMirrorSet, imgCfg *apicfgv1.Image) ([]*mcfgv1.MachineConfig, error) {
953946

954947
var (
955948
insecureRegs, registriesBlocked, policyBlocked, allowedRegs, searchRegs []string
@@ -977,7 +970,7 @@ func RunImageBootstrap(templateDir string, controllerConfig *mcfgv1.ControllerCo
977970
return nil, err
978971
}
979972
registriesIgn, err := registriesConfigIgnition(templateDir, controllerConfig, role, controllerConfig.Spec.ReleaseImage,
980-
insecureRegs, registriesBlocked, policyBlocked, allowedRegs, searchRegs, icspRules, idmsRules, itmsRules, featureGateAccess)
973+
insecureRegs, registriesBlocked, policyBlocked, allowedRegs, searchRegs, icspRules, idmsRules, itmsRules)
981974
if err != nil {
982975
return nil, err
983976
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ func (f *fixture) newController() *Controller {
228228
oi.Operator().V1alpha1().ImageContentSourcePolicies(),
229229
ci.Config().V1().ClusterVersions(),
230230
k8sfake.NewSimpleClientset(), f.client, f.imgClient,
231-
f.fgAccess,
232231
)
233232

234233
c.mcpListerSynced = alwaysReady
@@ -1104,9 +1103,7 @@ func TestRunImageBootstrap(t *testing.T) {
11041103
// both registries.conf and policy.json as blocked
11051104
imgCfg := newImageConfig("cluster", &apicfgv1.RegistrySources{InsecureRegistries: []string{"insecure-reg-1.io", "insecure-reg-2.io"}, BlockedRegistries: []string{"blocked-reg.io", "release-reg.io"}, ContainerRuntimeSearchRegistries: []string{"search-reg.io"}})
11061105

1107-
fgAccess := featuregates.NewHardcodedFeatureGateAccess([]apicfgv1.FeatureGateName{}, []apicfgv1.FeatureGateName{})
1108-
1109-
mcs, err := RunImageBootstrap("../../../templates", cc, pools, tc.icspRules, tc.idmsRules, tc.itmsRules, imgCfg, fgAccess)
1106+
mcs, err := RunImageBootstrap("../../../templates", cc, pools, tc.icspRules, tc.idmsRules, tc.itmsRules, imgCfg)
11101107
require.NoError(t, err)
11111108
require.Len(t, mcs, len(pools))
11121109

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

0 commit comments

Comments
 (0)