Skip to content
Closed
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
9 changes: 8 additions & 1 deletion pkg/controller/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/controller/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/kubelet-config/kubelet_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/template/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}