diff --git a/pkg/controller/bootstrap/bootstrap.go b/pkg/controller/bootstrap/bootstrap.go index c18f391a8e..7e23ff7e0f 100644 --- a/pkg/controller/bootstrap/bootstrap.go +++ b/pkg/controller/bootstrap/bootstrap.go @@ -20,6 +20,7 @@ import ( apicfgv1 "github.com/openshift/api/config/v1" apioperatorsv1alpha1 "github.com/openshift/api/operator/v1alpha1" mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" + ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common" containerruntimeconfig "github.com/openshift/machine-config-operator/pkg/controller/container-runtime-config" "github.com/openshift/machine-config-operator/pkg/controller/render" "github.com/openshift/machine-config-operator/pkg/controller/template" @@ -46,6 +47,7 @@ func New(templatesDir, manifestDir, pullSecretFile string) *Bootstrap { // Run runs boostrap for Machine Config Controller // It writes all the assets to destDir +// nolint: gocyclo func (b *Bootstrap) Run(destDir string) error { infos, err := ioutil.ReadDir(b.manifestDir) if err != nil { @@ -70,6 +72,7 @@ func (b *Bootstrap) Run(destDir string) error { decoder := codecFactory.UniversalDecoder(mcfgv1.GroupVersion, apioperatorsv1alpha1.GroupVersion, apicfgv1.GroupVersion) var cconfig *mcfgv1.ControllerConfig + var featureGate *apicfgv1.FeatureGate var pools []*mcfgv1.MachineConfigPool var configs []*mcfgv1.MachineConfig var icspRules []*apioperatorsv1alpha1.ImageContentSourcePolicy @@ -112,6 +115,10 @@ func (b *Bootstrap) Run(destDir string) error { icspRules = append(icspRules, obj) case *apicfgv1.Image: imgCfg = obj + case *apicfgv1.FeatureGate: + if obj.GetName() == ctrlcommon.ClusterFeatureInstanceName { + featureGate = obj + } default: glog.Infof("skipping %q [%d] manifest because of unhandled %T", file.Name(), idx+1, obji) } @@ -121,7 +128,7 @@ func (b *Bootstrap) Run(destDir string) error { if cconfig == nil { return fmt.Errorf("error: no controllerconfig found in dir: %q", destDir) } - iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw) + iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw, featureGate) if err != nil { return err } diff --git a/pkg/controller/bootstrap/bootstrap_test.go b/pkg/controller/bootstrap/bootstrap_test.go index 4d5fe08743..469a0d070b 100644 --- a/pkg/controller/bootstrap/bootstrap_test.go +++ b/pkg/controller/bootstrap/bootstrap_test.go @@ -44,6 +44,19 @@ spec: want: []manifest{{ Raw: []byte(`{"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"name":"test-ingress","namespace":"test-namespace"},"spec":{"rules":[{"http":{"paths":[{"backend":{"serviceName":"test","servicePort":80},"path":"/testpath"}]}}]}}`), }}, + }, { + name: "feature gate", + raw: ` +apiVersion: config.openshift.io/v1 +kind: FeatureGate +metadata: + name: cluster +spec: + featureSet: TechPreviewNoUpgrade +`, + want: []manifest{{ + Raw: []byte(`{"apiVersion":"config.openshift.io/v1","kind":"FeatureGate","metadata":{"name":"cluster"},"spec":{"featureSet":"TechPreviewNoUpgrade"}}`), + }}, }, { name: "two-resources", raw: ` diff --git a/pkg/controller/kubelet-config/kubelet_config_controller.go b/pkg/controller/kubelet-config/kubelet_config_controller.go index 814f09d1b0..8cd30d185b 100644 --- a/pkg/controller/kubelet-config/kubelet_config_controller.go +++ b/pkg/controller/kubelet-config/kubelet_config_controller.go @@ -478,7 +478,7 @@ func (ctrl *Controller) syncKubeletConfig(key string) error { err := fmt.Errorf("could not fetch FeatureGates: %v", err) return ctrl.syncStatusOnly(cfg, err) } - featureGates, err := generateFeatureMap(features) + featureGates, err := generateFeatureMap(features, openshiftOnlyFeatureGates...) if err != nil { err := fmt.Errorf("could not generate FeatureMap: %v", err) glog.V(2).Infof("%v", err) diff --git a/pkg/controller/template/template_controller.go b/pkg/controller/template/template_controller.go index 909224bd03..96fa61e296 100644 --- a/pkg/controller/template/template_controller.go +++ b/pkg/controller/template/template_controller.go @@ -523,6 +523,6 @@ func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.Co } // RunBootstrap runs the tempate controller in boostrap mode. -func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte) ([]*mcfgv1.MachineConfig, error) { - return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, nil) +func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte, featureGate *configv1.FeatureGate) ([]*mcfgv1.MachineConfig, error) { + return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, featureGate) }