Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/imdario/mergo v0.3.7
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/opencontainers/go-digest v1.0.0
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183
github.com/openshift/api v0.0.0-20230613151523-ba04973d3ed1
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d
github.com/openshift/client-go v0.0.0-20230503144108-75015d2347cb
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183 h1:t/CahSnpqY46sQR01SoS+Jt0jtjgmhgE6lFmRnO4q70=
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/openshift/api v0.0.0-20230613151523-ba04973d3ed1 h1:sgr89m3ejIIKhSbTtHq7HEZ80et4IAXDrJlk+u+rYX8=
github.com/openshift/api v0.0.0-20230613151523-ba04973d3ed1/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d h1:RR4ah7FfaPR1WePizm0jlrsbmPu91xQZnAsVVreQV1k=
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/client-go v0.0.0-20230503144108-75015d2347cb h1:Nij5OnaECrkmcRQMAE9LMbQXPo95aqFnf+12B7SyFVI=
Expand Down
22 changes: 22 additions & 0 deletions pkg/cloudprovider/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var (

// ExternalCloudProviderFeatureGCP is the name of the external cloud provider feature gate for GCP.
ExternalCloudProviderFeatureGCP = configv1.FeatureGateExternalCloudProviderGCP

// ExternalCloudProviderFeatureExternal is the name of the external cloud provider feature gate for External platform.
ExternalCloudProviderFeatureExternal = configv1.FeatureGateExternalCloudProviderExternal
)

// IsCloudProviderExternal is used to check whether external cloud provider settings should be used in a component.
Expand Down Expand Up @@ -49,6 +52,8 @@ func IsCloudProviderExternal(platformStatus *configv1.PlatformStatus, featureGat
configv1.PowerVSPlatformType,
configv1.VSpherePlatformType:
return true, nil
case configv1.ExternalPlatformType:
return isExternalPlatformCCMEnabled(platformStatus, featureGateAccessor)
default:
// Platforms that do not have external cloud providers implemented
return false, nil
Expand All @@ -59,6 +64,23 @@ func isAzureStackHub(platformStatus *configv1.PlatformStatus) bool {
return platformStatus.Azure != nil && platformStatus.Azure.CloudName == configv1.AzureStackCloud
}

func isExternalPlatformCCMEnabled(platformStatus *configv1.PlatformStatus, featureGateAccessor featuregates.FeatureGateAccess) (bool, error) {
featureEnabled, err := isExternalFeatureGateEnabled(featureGateAccessor, ExternalCloudProviderFeature, ExternalCloudProviderFeatureExternal)
if err != nil || !featureEnabled {
return featureEnabled, err
}

if platformStatus == nil || platformStatus.External == nil {
return false, nil
}

if platformStatus.External.CloudControllerManager.State == configv1.CloudControllerManagerExternal {
return true, nil
}

return false, nil
}

// isExternalFeatureGateEnabled determines whether the ExternalCloudProvider feature gate is present in the current
// feature set.
func isExternalFeatureGateEnabled(featureGateAccess featuregates.FeatureGateAccess, featureGateNames ...configv1.FeatureGateName) (bool, error) {
Expand Down
64 changes: 64 additions & 0 deletions pkg/cloudprovider/external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,70 @@ func TestIsCloudProviderExternal(t *testing.T) {
},
featureGate: featuregates.NewHardcodedFeatureGateAccessForTesting(nil, nil, readyCh, fmt.Errorf("missing")),
expected: true,
}, {
name: "No FeatureGate, Platform: External, CloudControllerManager.State = External",
status: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerExternal,
},
},
},
featureGate: featuregates.NewHardcodedFeatureGateAccessForTesting(nil, nil, readyCh, fmt.Errorf("missing")),
expected: false,
}, {
name: "FeatureSet: TechPreviewNoUpgrade, Platform: External, CloudControllerManager.State = External",
status: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerExternal,
},
},
},
featureGate: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
nil,
),
expected: true,
}, {
name: "FeatureSet: TechPreviewNoUpgrade, Platform: External, CloudControllerManager.State = None",
status: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerNone,
},
},
},
featureGate: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
nil,
),
expected: false,
}, {
name: "FeatureSet: TechPreviewNoUpgrade, Platform: External, CloudControllerManager.State is empty",
status: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{},
},
featureGate: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
nil,
),
expected: false,
}, {
name: "FeatureSet: TechPreviewNoUpgrade, Platform: External, ExternalPlatformSpec is nil",
status: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: nil,
},
featureGate: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
nil,
),
expected: false,
}, {
name: "FeatureSet: CustomNoUpgrade (With External Feature Gate Enabled), Platform: Nutanix",
status: &configv1.PlatformStatus{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func GetPlatformName(platformType configv1.PlatformType, recorder events.Recorde
case configv1.KubevirtPlatformType:
case configv1.AlibabaCloudPlatformType:
case configv1.PowerVSPlatformType:
case configv1.ExternalPlatformType:
default:
// the new doc on the infrastructure fields requires that we treat an unrecognized thing the same bare metal.
// TODO find a way to indicate to the user that we didn't honor their choice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,43 @@ func TestObserveCloudProviderNames(t *testing.T) {
},
},
cloudProviderCount: 0,
}, {
name: "External platform, CloudControllerManager.State = External",
infrastructureStatus: configv1.InfrastructureStatus{
Platform: configv1.ExternalPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerExternal,
},
},
},
},
featureGateAccessor: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
[]configv1.FeatureGateName{},
),
expected: "external",
cloudProviderCount: 1,
}, {
name: "External platform, CloudControllerManager.State = None",
infrastructureStatus: configv1.InfrastructureStatus{
Platform: configv1.ExternalPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.ExternalPlatformType,
External: &configv1.ExternalPlatformStatus{
CloudControllerManager: configv1.CloudControllerManagerStatus{
State: configv1.CloudControllerManagerNone,
},
},
},
},
featureGateAccessor: featuregates.NewHardcodedFeatureGateAccess(
[]configv1.FeatureGateName{configv1.FeatureGateExternalCloudProvider, configv1.FeatureGateExternalCloudProviderExternal},
[]configv1.FeatureGateName{},
),
cloudProviderCount: 0,
}, {
name: "empty or unknown platform",
infrastructureStatus: configv1.InfrastructureStatus{
Expand Down
7 changes: 6 additions & 1 deletion vendor/github.com/openshift/api/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/openshift/api/apps/v1/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/openshift/api/apps/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/openshift/api/apps/v1/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading