Skip to content

Commit

Permalink
Updated FeatureGate logic to use cluster profiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
vr4manta committed Mar 25, 2024
1 parent c5adb0f commit 6156758
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
9 changes: 8 additions & 1 deletion pkg/destroy/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ func Destroy(ctx context.Context, dir string) (err error) {
}
}

fg := featuregates.FeatureGateFromFeatureSets(configv1.FeatureSets, metadata.FeatureSet, metadata.CustomFeatureSet)
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
// SelfManaged.
clusterProfile := configv1.SelfManaged
if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" {
logrus.Warnf("Found override for Cluster Profile: %q", cp)
clusterProfile = configv1.ClusterProfileName(cp)
}
fg := featuregates.FeatureGateFromFeatureSets(configv1.AllFeatureSets()[clusterProfile], metadata.FeatureSet, metadata.CustomFeatureSet)

provider, err := infra.ProviderForPlatform(platform, fg)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package types

import (
"fmt"
"os"
"strings"

"github.com/sirupsen/logrus"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

configv1 "github.com/openshift/api/config/v1"
Expand Down Expand Up @@ -547,7 +550,14 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
customFS = featuregates.GenerateCustomFeatures(c.FeatureGates)
}

fg := featuregates.FeatureGateFromFeatureSets(configv1.FeatureSets, c.FeatureSet, customFS)
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
// SelfManaged.
clusterProfile := configv1.SelfManaged
if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" {
logrus.Warnf("Found override for Cluster Profile: %q", cp)
clusterProfile = configv1.ClusterProfileName(cp)
}
fg := featuregates.FeatureGateFromFeatureSets(configv1.AllFeatureSets()[clusterProfile], c.FeatureSet, customFS)

return fg
}
11 changes: 9 additions & 2 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,10 +1212,17 @@ func validateAdditionalCABundlePolicy(c *types.InstallConfig) error {
func ValidateFeatureSet(c *types.InstallConfig) field.ErrorList {
allErrs := field.ErrorList{}

if _, ok := configv1.FeatureSets[c.FeatureSet]; !ok {
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
// SelfManaged.
clusterProfile := configv1.SelfManaged
if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" {
logrus.Warnf("Found override for Cluster Profile: %q", cp)
clusterProfile = configv1.ClusterProfileName(cp)
}
if _, ok := configv1.AllFeatureSets()[clusterProfile][c.FeatureSet]; !ok {
sortedFeatureSets := func() []string {
v := []string{}
for n := range configv1.FeatureSets {
for n := range configv1.AllFeatureSets()[clusterProfile] {
v = append(v, string(n))
}
sort.Strings(v)
Expand Down

0 comments on commit 6156758

Please sign in to comment.