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 0c60787
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 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
2 changes: 1 addition & 1 deletion pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
customFS = featuregates.GenerateCustomFeatures(c.FeatureGates)
}

fg := featuregates.FeatureGateFromFeatureSets(configv1.FeatureSets, c.FeatureSet, customFS)
fg := featuregates.FeatureGateFromFeatureSets(configv1.AllFeatureSets()[GetClusterProfileName()], c.FeatureSet, customFS)

return fg
}
20 changes: 19 additions & 1 deletion pkg/types/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package types

import configv1 "github.com/openshift/api/config/v1"
import (
"os"

"github.com/sirupsen/logrus"

configv1 "github.com/openshift/api/config/v1"
)

// StringsToIPs is used to convert list of strings to list of IP addresses.
func StringsToIPs(ips []string) []configv1.IP {
Expand Down Expand Up @@ -32,3 +38,15 @@ func MachineNetworksToCIDRs(nets []MachineNetworkEntry) []configv1.CIDR {

return res
}

// GetClusterProfileName utility method to retrieve the cluster profile setting.
func GetClusterProfileName() configv1.ClusterProfileName {
// 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)
}
return clusterProfile
}
7 changes: 5 additions & 2 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,12 +1212,15 @@ func validateAdditionalCABundlePolicy(c *types.InstallConfig) error {
func ValidateFeatureSet(c *types.InstallConfig) field.ErrorList {
allErrs := field.ErrorList{}

if _, ok := configv1.FeatureSets[c.FeatureSet]; !ok {
clusterProfile := types.GetClusterProfileName()
if _, ok := configv1.AllFeatureSets()[clusterProfile][c.FeatureSet]; c.FeatureSet != configv1.CustomNoUpgrade && !ok {
sortedFeatureSets := func() []string {
v := []string{}
for n := range configv1.FeatureSets {
for n := range configv1.AllFeatureSets()[clusterProfile] {
v = append(v, string(n))
}
// Add CustomNoUpgrade since it is not part of features sets for profiles
v = append(v, string(configv1.CustomNoUpgrade))
sort.Strings(v)
return v
}()
Expand Down

0 comments on commit 0c60787

Please sign in to comment.