Skip to content
Merged
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
27 changes: 27 additions & 0 deletions pkg/features/patch_kube_features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package features

import (
"os"

"k8s.io/apimachinery/pkg/util/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
)

// This override should only be used with a support exception. It provides a way
// to set the NewVolumeManagerReconstruction feature gate in a way that still
// allows the cluster to be upgradable. This is only needed on 4.14, since the
// feature gate defaults to true on 4.15 and later. Owners: @jsafrane @dobsonj
func OpenShiftNewVolumeManagerReconstructionOverride() {
overrideVariable := "OCP_4_14_SUPPORT_EXCEPTION_ENABLE_NEW_VOLUME_MANAGER_RECONSTRUCTION"
_, enabled := os.LookupEnv(overrideVariable)
if enabled {
klog.Infof("Environment variable %s is set, setting feature gate %s to true", overrideVariable, string(NewVolumeManagerReconstruction))
fg := map[string]bool{string(NewVolumeManagerReconstruction): true}
runtime.Must(utilfeature.DefaultMutableFeatureGate.SetFromMap(fg))
}
}

func init() {
OpenShiftNewVolumeManagerReconstructionOverride()
}
Comment on lines +25 to +27
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case anyone else has the same question I had: What happens when two files in a single package both have their own init() routine?

The files are processed alphabetically. First the init() in kube_features.go is called, and then the init() here in patch_kube_features.go. They are always called exactly once, in serial, in order.

In other words, OpenShiftNewVolumeManagerReconstructionOverride() should always be called after the default feature gates are added.

Copy link

@jsafrane jsafrane Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have this information as a comment in the code