Skip to content

Commit e3f320c

Browse files
committed
Updated FeatureGate logic to use cluster profiles.
1 parent 129e33e commit e3f320c

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

pkg/destroy/bootstrap/bootstrap.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/openshift/installer/pkg/infrastructure/openstack/preprovision"
1717
infra "github.com/openshift/installer/pkg/infrastructure/platform"
1818
ibmcloudtfvars "github.com/openshift/installer/pkg/tfvars/ibmcloud"
19+
"github.com/openshift/installer/pkg/types"
1920
typesazure "github.com/openshift/installer/pkg/types/azure"
2021
"github.com/openshift/installer/pkg/types/featuregates"
2122
ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud"
@@ -69,7 +70,14 @@ func Destroy(ctx context.Context, dir string) (err error) {
6970
}
7071
}
7172

72-
fg := featuregates.FeatureGateFromFeatureSets(configv1.FeatureSets, metadata.FeatureSet, metadata.CustomFeatureSet)
73+
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
74+
// SelfManaged.
75+
clusterProfile := types.GetClusterProfileName()
76+
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
77+
if !ok {
78+
return fmt.Errorf("no feature sets for cluster profile %q", clusterProfile)
79+
}
80+
fg := featuregates.FeatureGateFromFeatureSets(featureSets, metadata.FeatureSet, metadata.CustomFeatureSet)
7381

7482
provider, err := infra.ProviderForPlatform(platform, fg)
7583
if err != nil {

pkg/types/installconfig.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/sirupsen/logrus"
78
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
89

910
configv1 "github.com/openshift/api/config/v1"
@@ -547,7 +548,12 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
547548
customFS = featuregates.GenerateCustomFeatures(c.FeatureGates)
548549
}
549550

550-
fg := featuregates.FeatureGateFromFeatureSets(configv1.FeatureSets, c.FeatureSet, customFS)
551+
clusterProfile := GetClusterProfileName()
552+
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
553+
if !ok {
554+
logrus.Warnf("no feature sets for cluster profile %q", clusterProfile)
555+
}
556+
fg := featuregates.FeatureGateFromFeatureSets(featureSets, c.FeatureSet, customFS)
551557

552558
return fg
553559
}

pkg/types/utils.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package types
22

3-
import configv1 "github.com/openshift/api/config/v1"
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/sirupsen/logrus"
8+
9+
configv1 "github.com/openshift/api/config/v1"
10+
)
411

512
// StringsToIPs is used to convert list of strings to list of IP addresses.
613
func StringsToIPs(ips []string) []configv1.IP {
@@ -32,3 +39,18 @@ func MachineNetworksToCIDRs(nets []MachineNetworkEntry) []configv1.CIDR {
3239

3340
return res
3441
}
42+
43+
// GetClusterProfileName utility method to retrieve the cluster profile setting. This is used
44+
// when dealing with openshift api to get FeatureSets.
45+
func GetClusterProfileName() configv1.ClusterProfileName {
46+
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
47+
// SelfManaged.
48+
clusterProfile := configv1.SelfManaged
49+
if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" {
50+
logrus.Warnf("Found override for Cluster Profile: %q", cp)
51+
// All profiles when getting FeatureSets need to have "include.release.openshift.io/" at the beginning.
52+
// See vendor/openshift/api/config/v1/feature_gates.go for more info.
53+
clusterProfile = configv1.ClusterProfileName(fmt.Sprintf("%s%s", "include.release.openshift.io/", cp))
54+
}
55+
return clusterProfile
56+
}

pkg/types/validation/installconfig.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,12 +1212,19 @@ func validateAdditionalCABundlePolicy(c *types.InstallConfig) error {
12121212
func ValidateFeatureSet(c *types.InstallConfig) field.ErrorList {
12131213
allErrs := field.ErrorList{}
12141214

1215-
if _, ok := configv1.FeatureSets[c.FeatureSet]; !ok {
1215+
clusterProfile := types.GetClusterProfileName()
1216+
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
1217+
if !ok {
1218+
logrus.Warnf("no feature sets for cluster profile %q", clusterProfile)
1219+
}
1220+
if _, ok := featureSets[c.FeatureSet]; c.FeatureSet != configv1.CustomNoUpgrade && !ok {
12161221
sortedFeatureSets := func() []string {
12171222
v := []string{}
1218-
for n := range configv1.FeatureSets {
1223+
for n := range configv1.AllFeatureSets()[clusterProfile] {
12191224
v = append(v, string(n))
12201225
}
1226+
// Add CustomNoUpgrade since it is not part of features sets for profiles
1227+
v = append(v, string(configv1.CustomNoUpgrade))
12211228
sort.Strings(v)
12221229
return v
12231230
}()

0 commit comments

Comments
 (0)