Skip to content

Commit cc6a078

Browse files
committed
Check CAPI-Install feature gate per platform
Adds the ability to check for a CAPI install feature gate per platform, rather than only checking whether CAPI is enabled for every platform. This will allow graduation of capi install feature gates per platform.
1 parent b1b7bb4 commit cc6a078

File tree

5 files changed

+60
-21
lines changed

5 files changed

+60
-21
lines changed

pkg/asset/machines/master.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sigs.k8s.io/yaml"
1818

1919
configv1 "github.com/openshift/api/config/v1"
20-
"github.com/openshift/api/features"
2120
machinev1 "github.com/openshift/api/machine/v1"
2221
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
2322
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
@@ -44,6 +43,7 @@ import (
4443
"github.com/openshift/installer/pkg/asset/machines/ovirt"
4544
"github.com/openshift/installer/pkg/asset/machines/powervs"
4645
"github.com/openshift/installer/pkg/asset/machines/vsphere"
46+
"github.com/openshift/installer/pkg/asset/manifests/capiutils"
4747
"github.com/openshift/installer/pkg/asset/rhcos"
4848
rhcosutils "github.com/openshift/installer/pkg/rhcos"
4949
"github.com/openshift/installer/pkg/types"
@@ -271,7 +271,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {
271271
// so we don't want to include target pools in the control plane machineset.
272272
// TODO(padillon): once this feature gate is the default and we are
273273
// no longer using Terraform, we can update ConfigMasters not to populate this.
274-
if ic.EnabledFeatureGates().Enabled(features.FeatureGateClusterAPIInstall) {
274+
if capiutils.IsEnabled(installConfig) {
275275
for _, machine := range machines {
276276
providerSpec, ok := machine.Spec.ProviderSpec.Value.Object.(*machinev1beta1.GCPMachineProviderSpec)
277277
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-
"github.com/openshift/api/features"
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(features.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/infrastructure/platform/platform.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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(features.FeatureGateClusterAPIInstall) {
54+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
5455
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
5556
}
5657
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(features.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(features.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(features.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(features.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(features.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(features.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(features.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-
"github.com/openshift/api/features"
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(features.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(features.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(features.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(features.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(features.FeatureGateClusterAPIInstall) {
56+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
5757
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
5858
}
5959
case powervstypes.Name:
60-
if fg.Enabled(features.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(features.FeatureGateClusterAPIInstall) {
65+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
6666
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
6767
}
6868
case nutanixtypes.Name:
69-
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
69+
if types.ClusterAPIFeatureGateEnabled(platform, fg) {
7070
return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
7171
}
7272
}

pkg/types/installconfig.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,36 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
558558

559559
return fg
560560
}
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)