Skip to content

Commit f668504

Browse files
Merge pull request #8311 from patrickdillon/capi-provider-fgs
no-jira: CAPI-Install Feature Gates per Platform
2 parents f3d9c1f + cc6a078 commit f668504

File tree

258 files changed

+2361
-54536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+2361
-54536
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ require (
6464
github.com/nutanix-cloud-native/cluster-api-provider-nutanix v1.3.3-0.20240416171357-98239ba02cb2
6565
github.com/nutanix-cloud-native/prism-go-client v0.3.4
6666
github.com/onsi/gomega v1.32.0
67-
github.com/openshift/api v0.0.0-20240313103236-5f1498accd5d
67+
github.com/openshift/api v0.0.0-20240429104249-ac9356ba1784
6868
github.com/openshift/assisted-image-service v0.0.0-20240408153851-f822399afa8a
6969
github.com/openshift/assisted-service/api v0.0.0
7070
github.com/openshift/assisted-service/client v0.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,8 +1972,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
19721972
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
19731973
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8=
19741974
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
1975-
github.com/openshift/api v0.0.0-20240313103236-5f1498accd5d h1:WE1fNTWjcCQMZ+8flkBER/ygsYvQIum25F/2qBQPi+g=
1976-
github.com/openshift/api v0.0.0-20240313103236-5f1498accd5d/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
1975+
github.com/openshift/api v0.0.0-20240429104249-ac9356ba1784 h1:SmOZFMxuAH4d1Cj7dOftVyo4Wg/mEC4pwz6QIJJsAkc=
1976+
github.com/openshift/api v0.0.0-20240429104249-ac9356ba1784/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
19771977
github.com/openshift/assisted-image-service v0.0.0-20240408153851-f822399afa8a h1:xWlqkUnY9N6aiKFgzHG27fc3kyjoxeanVdwVUUzgTs0=
19781978
github.com/openshift/assisted-image-service v0.0.0-20240408153851-f822399afa8a/go.mod h1:o2H5VwQhUD8P6XsK6dRmKpCCJqVvv12KJQZBXmcCXCU=
19791979
github.com/openshift/assisted-service/api v0.0.0-20230831114549-1922eda29cf8 h1:+fZLKbycDo4JeLwPGVSAgf2XPaJGLM341l9ZfrrlxG0=

pkg/asset/machines/master.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/openshift/installer/pkg/asset/machines/ovirt"
4444
"github.com/openshift/installer/pkg/asset/machines/powervs"
4545
"github.com/openshift/installer/pkg/asset/machines/vsphere"
46+
"github.com/openshift/installer/pkg/asset/manifests/capiutils"
4647
"github.com/openshift/installer/pkg/asset/rhcos"
4748
rhcosutils "github.com/openshift/installer/pkg/rhcos"
4849
"github.com/openshift/installer/pkg/types"
@@ -270,7 +271,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {
270271
// so we don't want to include target pools in the control plane machineset.
271272
// TODO(padillon): once this feature gate is the default and we are
272273
// no longer using Terraform, we can update ConfigMasters not to populate this.
273-
if ic.EnabledFeatureGates().Enabled(configv1.FeatureGateClusterAPIInstall) {
274+
if capiutils.IsEnabled(installConfig) {
274275
for _, machine := range machines {
275276
providerSpec, ok := machine.Spec.ProviderSpec.Value.Object.(*machinev1beta1.GCPMachineProviderSpec)
276277
if !ok {

pkg/asset/manifests/capiutils/helpers.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package capiutils
22

33
import (
4-
v1 "github.com/openshift/api/config/v1"
54
"github.com/openshift/installer/pkg/asset/installconfig"
65
"github.com/openshift/installer/pkg/ipnet"
6+
"github.com/openshift/installer/pkg/types"
7+
typesazure "github.com/openshift/installer/pkg/types/azure"
78
)
89

910
var (
@@ -21,7 +22,11 @@ func CIDRFromInstallConfig(installConfig *installconfig.InstallConfig) *ipnet.IP
2122

2223
// IsEnabled returns true if the feature gate is enabled.
2324
func IsEnabled(installConfig *installconfig.InstallConfig) bool {
24-
return installConfig.Config.EnabledFeatureGates().Enabled(v1.FeatureGateClusterAPIInstall)
25+
platform := installConfig.Config.Platform.Name()
26+
if azure := installConfig.Config.Platform.Azure; azure != nil && azure.CloudName == typesazure.StackCloud {
27+
platform = typesazure.StackTerraformName
28+
}
29+
return types.ClusterAPIFeatureGateEnabled(platform, installConfig.Config.EnabledFeatureGates())
2530
}
2631

2732
// GenerateBoostrapMachineName generates the Cluster API Machine used for bootstrapping

pkg/destroy/bootstrap/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/pkg/errors"
1111
"github.com/sirupsen/logrus"
1212

13-
configv1 "github.com/openshift/api/config/v1"
13+
"github.com/openshift/api/features"
1414
"github.com/openshift/installer/pkg/asset/cluster/metadata"
1515
osp "github.com/openshift/installer/pkg/destroy/openstack"
1616
"github.com/openshift/installer/pkg/infrastructure/openstack/preprovision"
@@ -73,7 +73,7 @@ func Destroy(ctx context.Context, dir string) (err error) {
7373
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
7474
// SelfManaged.
7575
clusterProfile := types.GetClusterProfileName()
76-
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
76+
featureSets, ok := features.AllFeatureSets()[clusterProfile]
7777
if !ok {
7878
return fmt.Errorf("no feature sets for cluster profile %q", clusterProfile)
7979
}

pkg/infrastructure/platform/platform.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package platform
66
import (
77
"fmt"
88

9-
configv1 "github.com/openshift/api/config/v1"
9+
"github.com/openshift/api/features"
1010
"github.com/openshift/installer/pkg/infrastructure"
1111
awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
1212
awsinfra "github.com/openshift/installer/pkg/infrastructure/aws/sdk"
@@ -30,6 +30,7 @@ import (
3030
"github.com/openshift/installer/pkg/terraform/stages/ovirt"
3131
"github.com/openshift/installer/pkg/terraform/stages/powervs"
3232
"github.com/openshift/installer/pkg/terraform/stages/vsphere"
33+
"github.com/openshift/installer/pkg/types"
3334
awstypes "github.com/openshift/installer/pkg/types/aws"
3435
azuretypes "github.com/openshift/installer/pkg/types/azure"
3536
baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
@@ -50,15 +51,15 @@ import (
5051
func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
5152
switch platform {
5253
case awstypes.Name:
53-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
54+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
5455
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
5556
}
56-
if fg.Enabled(configv1.FeatureGateInstallAlternateInfrastructureAWS) {
57+
if fg.Enabled(features.FeatureGateInstallAlternateInfrastructureAWS) {
5758
return awsinfra.InitializeProvider(), nil
5859
}
5960
return terraform.InitializeProvider(aws.PlatformStages), nil
6061
case azuretypes.Name:
61-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
62+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
6263
return clusterapi.InitializeProvider(&azureinfra.Provider{}), nil
6364
}
6465
return terraform.InitializeProvider(azure.PlatformStages), nil
@@ -67,36 +68,36 @@ func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastr
6768
case baremetaltypes.Name:
6869
return baremetalinfra.InitializeProvider(), nil
6970
case gcptypes.Name:
70-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
71+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
7172
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
7273
}
7374
return terraform.InitializeProvider(gcp.PlatformStages), nil
7475
case ibmcloudtypes.Name:
75-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
76+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
7677
return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
7778
}
7879
return terraform.InitializeProvider(ibmcloud.PlatformStages), nil
7980
case libvirttypes.Name:
8081
return terraform.InitializeProvider(libvirt.PlatformStages), nil
8182
case nutanixtypes.Name:
82-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
83+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
8384
return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
8485
}
8586
return terraform.InitializeProvider(nutanix.PlatformStages), nil
8687
case powervstypes.Name:
87-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
88+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
8889
return clusterapi.InitializeProvider(&powervscapi.Provider{}), nil
8990
}
9091
return terraform.InitializeProvider(powervs.PlatformStages), nil
9192
case openstacktypes.Name:
92-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
93+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
9394
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
9495
}
9596
return terraform.InitializeProvider(openstack.PlatformStages), nil
9697
case ovirttypes.Name:
9798
return terraform.InitializeProvider(ovirt.PlatformStages), nil
9899
case vspheretypes.Name:
99-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
100+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
100101
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
101102
}
102103
return terraform.InitializeProvider(vsphere.PlatformStages), nil

pkg/infrastructure/platform/platform_altinfra.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package platform
66
import (
77
"fmt"
88

9-
configv1 "github.com/openshift/api/config/v1"
109
"github.com/openshift/installer/pkg/infrastructure"
1110
awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
1211
awsinfra "github.com/openshift/installer/pkg/infrastructure/aws/sdk"
@@ -18,6 +17,7 @@ import (
1817
openstackcapi "github.com/openshift/installer/pkg/infrastructure/openstack/clusterapi"
1918
powervscapi "github.com/openshift/installer/pkg/infrastructure/powervs/clusterapi"
2019
vspherecapi "github.com/openshift/installer/pkg/infrastructure/vsphere/clusterapi"
20+
"github.com/openshift/installer/pkg/types"
2121
awstypes "github.com/openshift/installer/pkg/types/aws"
2222
azuretypes "github.com/openshift/installer/pkg/types/azure"
2323
"github.com/openshift/installer/pkg/types/featuregates"
@@ -33,40 +33,40 @@ import (
3333
func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
3434
switch platform {
3535
case awstypes.Name:
36-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
36+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
3737
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
3838
}
3939
return awsinfra.InitializeProvider(), nil
4040
case azuretypes.Name:
41-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
41+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
4242
return clusterapi.InitializeProvider(&azurecapi.Provider{}), nil
4343
}
4444
return nil, nil
4545
case gcptypes.Name:
46-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
46+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
4747
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
4848
}
4949
return nil, nil
5050
case ibmcloudtypes.Name:
51-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
51+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
5252
return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
5353
}
5454
return nil, nil
5555
case vspheretypes.Name:
56-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
56+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
5757
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
5858
}
5959
case powervstypes.Name:
60-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
60+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
6161
return clusterapi.InitializeProvider(powervscapi.Provider{}), nil
6262
}
6363
return nil, nil
6464
case openstacktypes.Name:
65-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
65+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
6666
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
6767
}
6868
case nutanixtypes.Name:
69-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
69+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
7070
return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
7171
}
7272
}

pkg/types/featuregates/featuregates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"k8s.io/apimachinery/pkg/util/sets"
1010

1111
configv1 "github.com/openshift/api/config/v1"
12+
features "github.com/openshift/api/features"
1213
)
1314

14-
func toFeatureGateNames(in []configv1.FeatureGateDescription) []configv1.FeatureGateName {
15+
func toFeatureGateNames(in []features.FeatureGateDescription) []configv1.FeatureGateName {
1516
out := []configv1.FeatureGateName{}
1617
for _, curr := range in {
1718
out = append(out, curr.FeatureGateAttributes.Name)
@@ -21,7 +22,7 @@ func toFeatureGateNames(in []configv1.FeatureGateDescription) []configv1.Feature
2122
}
2223

2324
// completeFeatureGates identifies every known feature and ensures that is explicitly on or explicitly off.
24-
func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*configv1.FeatureGateEnabledDisabled, enabled, disabled []configv1.FeatureGateName) ([]configv1.FeatureGateName, []configv1.FeatureGateName) {
25+
func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*features.FeatureGateEnabledDisabled, enabled, disabled []configv1.FeatureGateName) ([]configv1.FeatureGateName, []configv1.FeatureGateName) {
2526
specificallyEnabledFeatureGates := sets.New[configv1.FeatureGateName]()
2627
specificallyEnabledFeatureGates.Insert(enabled...)
2728

@@ -41,7 +42,7 @@ func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*configv1.Fea
4142
}
4243

4344
// FeatureGateFromFeatureSets creates a FeatureGate from the active feature sets.
44-
func FeatureGateFromFeatureSets(knownFeatureSets map[configv1.FeatureSet]*configv1.FeatureGateEnabledDisabled, fs configv1.FeatureSet, customFS *configv1.CustomFeatureGates) FeatureGate {
45+
func FeatureGateFromFeatureSets(knownFeatureSets map[configv1.FeatureSet]*features.FeatureGateEnabledDisabled, fs configv1.FeatureSet, customFS *configv1.CustomFeatureGates) FeatureGate {
4546
if customFS != nil {
4647
completeEnabled, completeDisabled := completeFeatureGates(knownFeatureSets, customFS.Enabled, customFS.Disabled)
4748
return newFeatureGate(completeEnabled, completeDisabled)

pkg/types/gcp/validation/featuregates.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package validation
33
import (
44
"k8s.io/apimachinery/pkg/util/validation/field"
55

6-
configv1 "github.com/openshift/api/config/v1"
6+
features "github.com/openshift/api/features"
77
"github.com/openshift/installer/pkg/types"
88
"github.com/openshift/installer/pkg/types/featuregates"
99
"github.com/openshift/installer/pkg/types/gcp"
@@ -15,17 +15,17 @@ func GatedFeatures(c *types.InstallConfig) []featuregates.GatedInstallConfigFeat
1515
g := c.GCP
1616
return []featuregates.GatedInstallConfigFeature{
1717
{
18-
FeatureGateName: configv1.FeatureGateGCPLabelsTags,
18+
FeatureGateName: features.FeatureGateGCPLabelsTags,
1919
Condition: len(g.UserLabels) > 0,
2020
Field: field.NewPath("platform", "gcp", "userLabels"),
2121
},
2222
{
23-
FeatureGateName: configv1.FeatureGateGCPLabelsTags,
23+
FeatureGateName: features.FeatureGateGCPLabelsTags,
2424
Condition: len(g.UserTags) > 0,
2525
Field: field.NewPath("platform", "gcp", "userTags"),
2626
},
2727
{
28-
FeatureGateName: configv1.FeatureGateGCPClusterHostedDNS,
28+
FeatureGateName: features.FeatureGateGCPClusterHostedDNS,
2929
Condition: g.UserProvisionedDNS == gcp.UserProvisionedDNSEnabled,
3030
Field: field.NewPath("platform", "gcp", "userProvisionedDNS"),
3131
},

pkg/types/installconfig.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99

1010
configv1 "github.com/openshift/api/config/v1"
11+
features "github.com/openshift/api/features"
1112
"github.com/openshift/installer/pkg/ipnet"
1213
"github.com/openshift/installer/pkg/types/aws"
1314
"github.com/openshift/installer/pkg/types/azure"
@@ -549,11 +550,44 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
549550
}
550551

551552
clusterProfile := GetClusterProfileName()
552-
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
553+
featureSets, ok := features.AllFeatureSets()[clusterProfile]
553554
if !ok {
554555
logrus.Warnf("no feature sets for cluster profile %q", clusterProfile)
555556
}
556557
fg := featuregates.FeatureGateFromFeatureSets(featureSets, c.FeatureSet, customFS)
557558

558559
return fg
559560
}
561+
562+
// ClusterAPIFeatureGateEnabled checks whether feature gates enabling
563+
// cluster api installs are enabled.
564+
func ClusterAPIFeatureGateEnabled(platform string, fgs featuregates.FeatureGate) bool {
565+
// FeatureGateClusterAPIInstall enables for all platforms.
566+
if fgs.Enabled(features.FeatureGateClusterAPIInstall) {
567+
return true
568+
}
569+
570+
// Check if CAPI install is enabled for individual platforms.
571+
switch platform {
572+
case aws.Name:
573+
return fgs.Enabled(features.FeatureGateClusterAPIInstallAWS)
574+
case azure.StackTerraformName, azure.StackCloud.Name():
575+
return false
576+
case azure.Name:
577+
return fgs.Enabled(features.FeatureGateClusterAPIInstallAzure)
578+
case gcp.Name:
579+
return fgs.Enabled(features.FeatureGateClusterAPIInstallGCP)
580+
case ibmcloud.Name:
581+
return fgs.Enabled(features.FeatureGateClusterAPIInstallIBMCloud)
582+
case nutanix.Name:
583+
return fgs.Enabled(features.FeatureGateClusterAPIInstallNutanix)
584+
case openstack.Name:
585+
return fgs.Enabled(features.FeatureGateClusterAPIInstallOpenStack)
586+
case powervs.Name:
587+
return fgs.Enabled(features.FeatureGateClusterAPIInstallPowerVS)
588+
case vsphere.Name:
589+
return fgs.Enabled(features.FeatureGateClusterAPIInstallVSphere)
590+
default:
591+
return false
592+
}
593+
}

0 commit comments

Comments
 (0)