diff --git a/cmd/machine-config-controller/start.go b/cmd/machine-config-controller/start.go index 81ec8793f4..b4621f15d1 100644 --- a/cmd/machine-config-controller/start.go +++ b/cmd/machine-config-controller/start.go @@ -112,6 +112,14 @@ func runStartCmd(_ *cobra.Command, _ []string) { klog.Fatalf("unable to start cert rotation controller: %v", err) } + pinnedImageSet := pinnedimageset.New( + ctrlctx.InformerFactory.Machineconfiguration().V1().PinnedImageSets(), + ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(), + ctrlctx.ClientBuilder.KubeClientOrDie("pinned-image-set-controller"), + ctrlctx.ClientBuilder.MachineConfigClientOrDie("pinned-image-set-controller"), + ) + go pinnedImageSet.Run(2, ctrlctx.Stop) + // Start the shared factory informers that you need to use in your controller ctrlctx.InformerFactory.Start(ctrlctx.Stop) ctrlctx.KubeInformerFactory.Start(ctrlctx.Stop) @@ -124,20 +132,6 @@ func runStartCmd(_ *cobra.Command, _ []string) { close(ctrlctx.InformersStarted) - if ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGatePinnedImages) && ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGateMachineConfigNodes) { - pinnedImageSet := pinnedimageset.New( - ctrlctx.InformerFactory.Machineconfiguration().V1().PinnedImageSets(), - ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(), - ctrlctx.ClientBuilder.KubeClientOrDie("pinned-image-set-controller"), - ctrlctx.ClientBuilder.MachineConfigClientOrDie("pinned-image-set-controller"), - ) - - go pinnedImageSet.Run(2, ctrlctx.Stop) - // start the informers again to enable feature gated types. - // see comments in SharedInformerFactory interface. - ctrlctx.InformerFactory.Start(ctrlctx.Stop) - } - if ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGateNoRegistryClusterInstall) { iriController := internalreleaseimage.New( ctrlctx.InformerFactory.Machineconfiguration().V1alpha1().InternalReleaseImages(), diff --git a/cmd/machine-config-daemon/start.go b/cmd/machine-config-daemon/start.go index 09e6061c40..16c639fee0 100644 --- a/cmd/machine-config-daemon/start.go +++ b/cmd/machine-config-daemon/start.go @@ -9,8 +9,6 @@ import ( "os" "time" - "github.com/openshift/api/features" - "k8s.io/apimachinery/pkg/api/resource" "k8s.io/client-go/tools/clientcmd" @@ -213,6 +211,28 @@ func runStartCmd(_ *cobra.Command, _ []string) { klog.Fatalf("Failed to initialize: %v", err) } + // Create CRI client and pinned image set manager before starting informers + criClient, err := cri.NewClient(ctx, constants.DefaultCRIOSocketPath) + if err != nil { + klog.Fatalf("Failed to initialize CRI client: %v", err) + } + prefetchTimeout := 2 * time.Minute + pinnedImageSetManager := daemon.NewPinnedImageSetManager( + startOpts.nodeName, + criClient, + ctrlctx.ClientBuilder.MachineConfigClientOrDie(componentName), + ctrlctx.InformerFactory.Machineconfiguration().V1().PinnedImageSets(), + nodeScopedInformer, + ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(), + resource.MustParse(constants.MinFreeStorageAfterPrefetch), + constants.DefaultCRIOSocketPath, + constants.KubeletAuthFile, + constants.ContainerRegistryConfPath, + prefetchTimeout, + ctrlctx.FeatureGatesHandler, + ) + go pinnedImageSetManager.Run(2, stopCh) + ctrlctx.KubeInformerFactory.Start(stopCh) ctrlctx.KubeNamespacedInformerFactory.Start(stopCh) ctrlctx.InformerFactory.Start(stopCh) @@ -220,36 +240,6 @@ func runStartCmd(_ *cobra.Command, _ []string) { nodeScopedInformerStartFunc(ctrlctx.Stop) close(ctrlctx.InformersStarted) - // ok to start the rest of the informers now that we have observed the initial feature gates - if ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGatePinnedImages) && ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGateMachineConfigNodes) { - klog.Infof("Feature enabled: %s", features.FeatureGatePinnedImages) - criClient, err := cri.NewClient(ctx, constants.DefaultCRIOSocketPath) - if err != nil { - klog.Fatalf("Failed to initialize CRI client: %v", err) - } - - prefetchTimeout := 2 * time.Minute - pinnedImageSetManager := daemon.NewPinnedImageSetManager( - startOpts.nodeName, - criClient, - ctrlctx.ClientBuilder.MachineConfigClientOrDie(componentName), - ctrlctx.InformerFactory.Machineconfiguration().V1().PinnedImageSets(), - nodeScopedInformer, - ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(), - resource.MustParse(constants.MinFreeStorageAfterPrefetch), - constants.DefaultCRIOSocketPath, - constants.KubeletAuthFile, - constants.ContainerRegistryConfPath, - prefetchTimeout, - ctrlctx.FeatureGatesHandler, - ) - - go pinnedImageSetManager.Run(2, stopCh) - // start the informers for the pinned image set again after the feature gate is enabled this is allowed. - // see comments in SharedInformerFactory interface. - ctrlctx.InformerFactory.Start(stopCh) - } - if err := dn.Run(stopCh, exitCh, errCh); err != nil { ctrlcommon.WriteTerminationError(err) if errors.Is(err, daemon.ErrAuxiliary) { diff --git a/pkg/controller/node/node_controller.go b/pkg/controller/node/node_controller.go index ee4fb6e14c..373a43f9ea 100644 --- a/pkg/controller/node/node_controller.go +++ b/pkg/controller/node/node_controller.go @@ -911,11 +911,9 @@ func (ctrl *Controller) updateNode(old, cur interface{}) { return } - if ctrl.fgHandler.Enabled(features.FeatureGatePinnedImages) { - for _, pool := range pools { - if isPinnedImageSetsInProgressForPool(pool) { - changed = true - } + for _, pool := range pools { + if isPinnedImageSetsInProgressForPool(pool) { + changed = true } } diff --git a/pkg/controller/node/node_controller_test.go b/pkg/controller/node/node_controller_test.go index 55f80dacfd..cd4918ed06 100644 --- a/pkg/controller/node/node_controller_test.go +++ b/pkg/controller/node/node_controller_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - features "github.com/openshift/api/features" "github.com/openshift/library-go/pkg/operator/configobserver/featuregates" "github.com/openshift/machine-config-operator/pkg/apihelpers" @@ -97,7 +96,7 @@ func newFixtureWithFeatureGates(t *testing.T, enabled, disabled []configv1.Featu } func newFixture(t *testing.T) *fixture { - return newFixtureWithFeatureGates(t, []configv1.FeatureGateName{features.FeatureGatePinnedImages}, []configv1.FeatureGateName{}) + return newFixtureWithFeatureGates(t, []configv1.FeatureGateName{}, []configv1.FeatureGateName{}) } func (f *fixture) newControllerWithStopChan(stopCh <-chan struct{}) *Controller { @@ -270,6 +269,7 @@ func filterInformerActions(actions []core.Action) []core.Action { action.Matches("watch", "machineosbuilds") || action.Matches("list", "machineosconfigs") || action.Matches("watch", "machineosconfigs") || + action.Matches("get", "machineconfignodes") || action.Matches("list", "machineconfignodes") || action.Matches("watch", "machineconfignodes")) { continue diff --git a/pkg/controller/node/status.go b/pkg/controller/node/status.go index 4022704d77..ba0733aef2 100644 --- a/pkg/controller/node/status.go +++ b/pkg/controller/node/status.go @@ -31,15 +31,13 @@ func (ctrl *Controller) syncStatusOnly(pool *mcfgv1.MachineConfigPool) error { } machineConfigStates := []*mcfgv1.MachineConfigNode{} - if ctrl.fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { - for _, node := range nodes { - ms, err := ctrl.client.MachineconfigurationV1().MachineConfigNodes().Get(context.TODO(), node.Name, metav1.GetOptions{}) - if err != nil { - klog.Errorf("Could not find our MachineConfigNode for node. %s: %v", node.Name, err) - continue - } - machineConfigStates = append(machineConfigStates, ms) + for _, node := range nodes { + ms, err := ctrl.client.MachineconfigurationV1().MachineConfigNodes().Get(context.TODO(), node.Name, metav1.GetOptions{}) + if err != nil { + klog.Errorf("Could not find our MachineConfigNode for node. %s: %v", node.Name, err) + continue } + machineConfigStates = append(machineConfigStates, ms) } // Get fresh copy of MCP from lister to ensure we have the latest status @@ -100,7 +98,6 @@ func (ctrl *Controller) calculateStatus(mcns []*mcfgv1.MachineConfigNode, cconfi // Determine if pool is layered and get enabled feature gates isLayeredPool := ctrl.isLayeredPool(mosc, mosb) - pisIsEnabled := ctrl.fgHandler.Enabled(features.FeatureGatePinnedImages) imageModeReportingIsEnabled := ctrl.fgHandler.Enabled(features.FeatureGateImageModeStatusReporting) // Update the number of degraded and updated machines from conditions in the MCNs for the nodes @@ -128,11 +125,9 @@ func (ctrl *Controller) calculateStatus(mcns []*mcfgv1.MachineConfigNode, cconfi break } - // If the PIS feature gate is enabled, update the PIS reference in the PoolSynchronizer object - if pisIsEnabled { - if isPinnedImageSetsUpdated(mcn) { - poolSynchronizer.SetUpdated(mcfgv1.PinnedImageSets) - } + // Update the PIS reference in the PoolSynchronizer object + if isPinnedImageSetsUpdated(mcn) { + poolSynchronizer.SetUpdated(mcfgv1.PinnedImageSets) } // Loop through the MCN conditions to determine if the associated node is updating, updated, or degraded @@ -220,18 +215,16 @@ func (ctrl *Controller) calculateStatus(mcns []*mcfgv1.MachineConfigNode, cconfi } // Update synchronizer status for pinned image sets - if pisIsEnabled { - syncStatus := poolSynchronizer.GetStatus(mcfgv1.PinnedImageSets) - status.PoolSynchronizersStatus = []mcfgv1.PoolSynchronizerStatus{ - { - PoolSynchronizerType: mcfgv1.PinnedImageSets, - MachineCount: syncStatus.MachineCount, - UpdatedMachineCount: syncStatus.UpdatedMachineCount, - ReadyMachineCount: int64(readyMachineCount), - UnavailableMachineCount: int64(unavailableMachineCount), - AvailableMachineCount: int64(totalMachineCount - unavailableMachineCount), - }, - } + syncStatus := poolSynchronizer.GetStatus(mcfgv1.PinnedImageSets) + status.PoolSynchronizersStatus = []mcfgv1.PoolSynchronizerStatus{ + { + PoolSynchronizerType: mcfgv1.PinnedImageSets, + MachineCount: syncStatus.MachineCount, + UpdatedMachineCount: syncStatus.UpdatedMachineCount, + ReadyMachineCount: int64(readyMachineCount), + UnavailableMachineCount: int64(unavailableMachineCount), + AvailableMachineCount: int64(totalMachineCount - unavailableMachineCount), + }, } // Update MCP status configuation & conditions diff --git a/pkg/controller/node/status_test.go b/pkg/controller/node/status_test.go index 37b535e416..bc20bc2faa 100644 --- a/pkg/controller/node/status_test.go +++ b/pkg/controller/node/status_test.go @@ -921,8 +921,6 @@ func TestCalculateStatus(t *testing.T) { } f := newFixtureWithFeatureGates(t, []apicfgv1.FeatureGateName{ - features.FeatureGateMachineConfigNodes, - features.FeatureGatePinnedImages, features.FeatureGateOSStreams, }, []apicfgv1.FeatureGateName{}, @@ -944,8 +942,6 @@ func TestCalculateStatusWithImageModeReporting(t *testing.T) { // This simulates a DevPreview environment where this feature gate is available fgHandler := ctrlcommon.NewFeatureGatesHardcodedHandler( []apicfgv1.FeatureGateName{ - features.FeatureGateMachineConfigNodes, - features.FeatureGatePinnedImages, features.FeatureGateImageModeStatusReporting, // Enable ImageModeStatusReporting directly }, []apicfgv1.FeatureGateName{}, @@ -1342,8 +1338,6 @@ func TestCalculateStatusWithImageModeReporting(t *testing.T) { // Create fixture with our ImageModeStatusReporting feature gate handler f := newFixtureWithFeatureGates(t, []apicfgv1.FeatureGateName{ - features.FeatureGateMachineConfigNodes, - features.FeatureGatePinnedImages, features.FeatureGateImageModeStatusReporting, }, []apicfgv1.FeatureGateName{}, diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 38fad81c72..53e63f22f1 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -422,7 +422,7 @@ func (dn *Daemon) ClusterConnect( // If the IrreconcilableMachineConfig FG is enabled turn on the reporting of irreconcilable differences // MCN is required too, as the irreconcilable diffs report is stored as part of the MCN status - if dn.fgHandler.Enabled(features.FeatureGateIrreconcilableMachineConfig) && dn.fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { + if dn.fgHandler.Enabled(features.FeatureGateIrreconcilableMachineConfig) { dn.irreconcilableReporter = NewIrreconcilableReporter(dn.mcfgClient) } diff --git a/pkg/daemon/update.go b/pkg/daemon/update.go index 82eabdb0f9..1ff962f05e 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -2736,10 +2736,9 @@ func (dn *Daemon) updateLayeredOS(config *mcfgv1.MachineConfig) error { } func (dn *Daemon) isPinnedImageSetConfigured() (bool, error) { - if dn.fgHandler == nil || !dn.fgHandler.Enabled(features.FeatureGatePinnedImages) || dn.node == nil || dn.mcpLister == nil { - // Two options: - // - PIS is not enabled - // - MCD first boot run: No connection to the cluster and node not populated -> Cannot check PIS config + if dn.node == nil || dn.mcpLister == nil { + // If we are here it means we are in the MCD first boot run. No connection to the cluster + // and the node not being populated means we cannot check the PIS config. return false, nil } diff --git a/pkg/operator/status.go b/pkg/operator/status.go index 344eb00255..ceb07ab51a 100644 --- a/pkg/operator/status.go +++ b/pkg/operator/status.go @@ -510,25 +510,25 @@ func (optr *Operator) allMachineConfigPoolStatus() (map[string]string, error) { ret := map[string]string{} for _, pool := range pools { - ret[pool.GetName()] = machineConfigPoolStatus(optr.fgHandler, pool) + ret[pool.GetName()] = machineConfigPoolStatus(pool) } return ret, nil } // isMachineConfigPoolConfigurationValid returns nil, or error when the configuration of a `pool` is created by the controller at version `version`, // when the osImageURL does not match what's in the configmap or when the rendered-config-xxx does not match the OCP release version. -func isMachineConfigPoolConfigurationValid(fgHandler ctrlcommon.FeatureGatesHandler, pool *mcfgv1.MachineConfigPool, version, releaseVersion, osURL string, machineConfigGetter func(string) (*mcfgv1.MachineConfig, error)) error { +func isMachineConfigPoolConfigurationValid(pool *mcfgv1.MachineConfigPool, version, releaseVersion, osURL string, machineConfigGetter func(string) (*mcfgv1.MachineConfig, error)) error { // both .status.configuration.name and .status.configuration.source must be set. if pool.Spec.Configuration.Name == "" { - return fmt.Errorf("configuration spec for pool %s is empty: %v", pool.GetName(), machineConfigPoolStatus(fgHandler, pool)) + return fmt.Errorf("configuration spec for pool %s is empty: %v", pool.GetName(), machineConfigPoolStatus(pool)) } if pool.Status.Configuration.Name == "" { // if status is empty, it means the node controller hasn't seen any node at the target configuration // we bubble up any error from the pool to make the info more visible - return fmt.Errorf("configuration status for pool %s is empty: %s", pool.GetName(), machineConfigPoolStatus(fgHandler, pool)) + return fmt.Errorf("configuration status for pool %s is empty: %s", pool.GetName(), machineConfigPoolStatus(pool)) } if len(pool.Status.Configuration.Source) == 0 { - return fmt.Errorf("list of MachineConfigs that were used to generate configuration for pool %s is empty: %v", pool.GetName(), machineConfigPoolStatus(fgHandler, pool)) + return fmt.Errorf("list of MachineConfigs that were used to generate configuration for pool %s is empty: %v", pool.GetName(), machineConfigPoolStatus(pool)) } mcs := []string{pool.Status.Configuration.Name} for _, fragment := range pool.Status.Configuration.Source { @@ -547,13 +547,13 @@ func isMachineConfigPoolConfigurationValid(fgHandler ctrlcommon.FeatureGatesHand // The bootstrapped MCs fragments have this annotation, however, we don't fail (???) if they don't have // the annotation for some reason. if !ok && pool.Status.Configuration.Name == mcName { - return fmt.Errorf("%s must be created by controller version %s: %v", mcName, version, machineConfigPoolStatus(fgHandler, pool)) + return fmt.Errorf("%s must be created by controller version %s: %v", mcName, version, machineConfigPoolStatus(pool)) } // user provided MC fragments do not have the annotation, so we just skip the version check there. // The check below is for: 1) the generated MC for the pool, and 2) the bootstrapped fragments // that do have this annotation set with a version. if ok && v != version { - return fmt.Errorf("controller version mismatch for %s expected %s has %s: %v", mcName, version, v, machineConfigPoolStatus(fgHandler, pool)) + return fmt.Errorf("controller version mismatch for %s expected %s has %s: %v", mcName, version, v, machineConfigPoolStatus(pool)) } } // all MCs were generated by correct controller, but osImageURL is not a source, so let's double check here @@ -588,7 +588,7 @@ func isMachineConfigPoolConfigurationValid(fgHandler ctrlcommon.FeatureGatesHand return nil } -func machineConfigPoolStatus(fgHandler ctrlcommon.FeatureGatesHandler, pool *mcfgv1.MachineConfigPool) string { +func machineConfigPoolStatus(pool *mcfgv1.MachineConfigPool) string { switch { case apihelpers.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolRenderDegraded): cond := apihelpers.GetMachineConfigPoolCondition(pool.Status, mcfgv1.MachineConfigPoolRenderDegraded) @@ -601,11 +601,9 @@ func machineConfigPoolStatus(fgHandler ctrlcommon.FeatureGatesHandler, pool *mcf case apihelpers.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolUpdating): return fmt.Sprintf("%d (ready %d) out of %d nodes are updating to latest configuration %s", pool.Status.UpdatedMachineCount, pool.Status.ReadyMachineCount, pool.Status.MachineCount, pool.Spec.Configuration.Name) default: - if fgHandler.Enabled(features.FeatureGatePinnedImages) { - if apihelpers.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolPinnedImageSetsDegraded) { - cond := apihelpers.GetMachineConfigPoolCondition(pool.Status, mcfgv1.MachineConfigPoolPinnedImageSetsDegraded) - return fmt.Sprintf("pool is degraded because pinned image sets failed with %q: %q", cond.Reason, cond.Message) - } + if apihelpers.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolPinnedImageSetsDegraded) { + cond := apihelpers.GetMachineConfigPoolCondition(pool.Status, mcfgv1.MachineConfigPoolPinnedImageSetsDegraded) + return fmt.Sprintf("pool is degraded because pinned image sets failed with %q: %q", cond.Reason, cond.Message) } return "" } diff --git a/pkg/operator/status_test.go b/pkg/operator/status_test.go index 428741a5ff..2737954dd4 100644 --- a/pkg/operator/status_test.go +++ b/pkg/operator/status_test.go @@ -19,7 +19,6 @@ import ( "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/util/uuid" - apicfgv1 "github.com/openshift/api/config/v1" configv1 "github.com/openshift/api/config/v1" features "github.com/openshift/api/features" mcfgv1 "github.com/openshift/api/machineconfiguration/v1" @@ -194,14 +193,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) { source = append(source, corev1.ObjectReference{Name: s}) } - fgHandler := ctrlcommon.NewFeatureGatesHardcodedHandler( - []apicfgv1.FeatureGateName{ - features.FeatureGateMachineConfigNodes, - features.FeatureGatePinnedImages, - }, - []apicfgv1.FeatureGateName{}, - ) - err := isMachineConfigPoolConfigurationValid(fgHandler, &mcfgv1.MachineConfigPool{ + err := isMachineConfigPoolConfigurationValid(&mcfgv1.MachineConfigPool{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy-pool", }, @@ -639,7 +631,7 @@ func TestOperatorSyncStatus(t *testing.T) { optr := &Operator{ eventRecorder: &record.FakeRecorder{}, fgHandler: ctrlcommon.NewFeatureGatesHardcodedHandler( - []configv1.FeatureGateName{features.FeatureGatePinnedImages}, []configv1.FeatureGateName{}, + []configv1.FeatureGateName{}, []configv1.FeatureGateName{}, ), } optr.vStore = newVersionStore() @@ -729,7 +721,7 @@ func TestInClusterBringUpStayOnErr(t *testing.T) { optr := &Operator{ eventRecorder: &record.FakeRecorder{}, fgHandler: ctrlcommon.NewFeatureGatesHardcodedHandler( - []configv1.FeatureGateName{features.FeatureGatePinnedImages}, []configv1.FeatureGateName{}, + []configv1.FeatureGateName{}, []configv1.FeatureGateName{}, ), } optr.vStore = newVersionStore() diff --git a/pkg/operator/sync.go b/pkg/operator/sync.go index 640cb9dfa4..03defc9271 100644 --- a/pkg/operator/sync.go +++ b/pkg/operator/sync.go @@ -796,9 +796,6 @@ func (optr *Operator) syncMachineConfigPools(config *renderConfig, _ *configv1.C // we need to mimic this func (optr *Operator) syncMachineConfigNodes(_ *renderConfig, _ *configv1.ClusterOperator) error { - if !optr.fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { - return nil - } nodes, err := optr.nodeLister.List(labels.Everything()) if err != nil { return err @@ -1775,7 +1772,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c } releaseVersion, _ := optr.vStore.Get("operator") - if err := isMachineConfigPoolConfigurationValid(optr.fgHandler, pool, version.Hash, releaseVersion, opURL, optr.mcLister.Get); err != nil { + if err := isMachineConfigPoolConfigurationValid(pool, version.Hash, releaseVersion, opURL, optr.mcLister.Get); err != nil { lastErr = fmt.Errorf("MachineConfigPool %s has not progressed to latest configuration: %w, retrying", pool.Name, err) newCO := co.DeepCopy() syncerr := optr.syncUpgradeableStatus(newCO) diff --git a/pkg/upgrademonitor/upgrade_monitor.go b/pkg/upgrademonitor/upgrade_monitor.go index 43e18fd3a5..12e9a85b1b 100644 --- a/pkg/upgrademonitor/upgrade_monitor.go +++ b/pkg/upgrademonitor/upgrade_monitor.go @@ -97,10 +97,6 @@ func generateAndApplyMachineConfigNodes( return nil } - if !fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { - return nil - } - // get the existing MCN, or if it DNE create one below mcNode, needNewMCNode := createOrGetMachineConfigNode(mcfgClient, node) newMCNode := mcNode.DeepCopy() @@ -128,9 +124,9 @@ func generateAndApplyMachineConfigNodes( } // singleton conditions are conditions that should only have one instance (no children) in the MCN status. - var singletonConditionTypes []mcfgv1.StateProgress - if fgHandler.Enabled(features.FeatureGatePinnedImages) { - singletonConditionTypes = append(singletonConditionTypes, mcfgv1.MachineConfigNodePinnedImageSetsDegraded, mcfgv1.MachineConfigNodePinnedImageSetsProgressing) + singletonConditionTypes := []mcfgv1.StateProgress{ + mcfgv1.MachineConfigNodePinnedImageSetsDegraded, + mcfgv1.MachineConfigNodePinnedImageSetsProgressing, } // we use this array to see if the MCN has all of its conditions set @@ -311,29 +307,27 @@ func generateAndApplyMachineConfigNodes( statusApplyConfig = statusApplyConfig.WithConfigImage(configImageApplyConfig) } - if fgHandler.Enabled(features.FeatureGatePinnedImages) { - if imageSetApplyConfig == nil { - for _, imageSet := range newMCNode.Status.PinnedImageSets { - // By default, a PinnedImageSet reference must include the name of the PIS and the desired generation - pisApplyConfig := &machineconfigurationv1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration{ - DesiredGeneration: ptr.To(imageSet.DesiredGeneration), - Name: ptr.To(imageSet.Name), - } - // Only set `CurrentGeneration` value when we are currently on a valid generation (imageSet.CurrentGeneration value is non-0) - if imageSet.CurrentGeneration != 0 { - pisApplyConfig.CurrentGeneration = ptr.To(imageSet.CurrentGeneration) - } - // Only set `LastFailedGeneration` value when it is a non-default (non-0) value - if imageSet.LastFailedGeneration != 0 { - pisApplyConfig.LastFailedGeneration = ptr.To(imageSet.LastFailedGeneration) - pisApplyConfig.LastFailedGenerationError = ptr.To(imageSet.LastFailedGenerationError) - } - - statusApplyConfig = statusApplyConfig.WithPinnedImageSets(pisApplyConfig) + if imageSetApplyConfig == nil { + for _, imageSet := range newMCNode.Status.PinnedImageSets { + // By default, a PinnedImageSet reference must include the name of the PIS and the desired generation + pisApplyConfig := &machineconfigurationv1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration{ + DesiredGeneration: ptr.To(imageSet.DesiredGeneration), + Name: ptr.To(imageSet.Name), + } + // Only set `CurrentGeneration` value when we are currently on a valid generation (imageSet.CurrentGeneration value is non-0) + if imageSet.CurrentGeneration != 0 { + pisApplyConfig.CurrentGeneration = ptr.To(imageSet.CurrentGeneration) } - } else if len(imageSetApplyConfig) > 0 { - statusApplyConfig = statusApplyConfig.WithPinnedImageSets(imageSetApplyConfig...) + // Only set `LastFailedGeneration` value when it is a non-default (non-0) value + if imageSet.LastFailedGeneration != 0 { + pisApplyConfig.LastFailedGeneration = ptr.To(imageSet.LastFailedGeneration) + pisApplyConfig.LastFailedGenerationError = ptr.To(imageSet.LastFailedGenerationError) + } + + statusApplyConfig = statusApplyConfig.WithPinnedImageSets(pisApplyConfig) } + } else if len(imageSetApplyConfig) > 0 { + statusApplyConfig = statusApplyConfig.WithPinnedImageSets(imageSetApplyConfig...) } mcnodeApplyConfig := machineconfigurationv1.MachineConfigNode(newMCNode.Name).WithStatus(statusApplyConfig) @@ -391,12 +385,6 @@ func UpdateMachineConfigNodeSpecDesiredAnnotations(fgHandler ctrlcommon.FeatureG return nil } - // Check that the MachineConfigNode feature gate is enabled - if !fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { - klog.Infof("MachineConfigNode FeatureGate is not enabled.") - return nil - } - // Get the existing MCN mcn, mcnErr := mcfgClient.MachineconfigurationV1().MachineConfigNodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) // Note that this function is only intended to update the Spec of an existing MCN. We should @@ -437,11 +425,6 @@ func GenerateAndApplyMachineConfigNodeSpec(fgHandler ctrlcommon.FeatureGatesHand return nil } - if !fgHandler.Enabled(features.FeatureGateMachineConfigNodes) { - klog.Infof("MachineConfigNode FeatureGate is not enabled.") - return nil - } - // get the existing MCN, or if it DNE create one below mcNode, needNewMCNode := createOrGetMachineConfigNode(mcfgClient, node) newMCNode := mcNode.DeepCopy()