mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 06:46:36 +01:00
Merge pull request #10286 from vimauro/add-tna-platform-external
OCPEDGE-2276: Add support for platform None and External in TNA clusters
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
|||||||
"github.com/openshift/installer/pkg/asset/rhcos"
|
"github.com/openshift/installer/pkg/asset/rhcos"
|
||||||
"github.com/openshift/installer/pkg/types"
|
"github.com/openshift/installer/pkg/types"
|
||||||
baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
|
baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
|
||||||
|
externaltypes "github.com/openshift/installer/pkg/types/external"
|
||||||
nonetypes "github.com/openshift/installer/pkg/types/none"
|
nonetypes "github.com/openshift/installer/pkg/types/none"
|
||||||
ibmcloudapi "github.com/openshift/machine-api-provider-ibmcloud/pkg/apis"
|
ibmcloudapi "github.com/openshift/machine-api-provider-ibmcloud/pkg/apis"
|
||||||
ibmcloudprovider "github.com/openshift/machine-api-provider-ibmcloud/pkg/apis/ibmcloudprovider/v1"
|
ibmcloudprovider "github.com/openshift/machine-api-provider-ibmcloud/pkg/apis/ibmcloudprovider/v1"
|
||||||
@@ -116,8 +117,8 @@ func (m *Arbiter) Generate(ctx context.Context, dependencies asset.Parents) erro
|
|||||||
if ic.Arbiter == nil {
|
if ic.Arbiter == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if ic.Platform.Name() != baremetaltypes.Name && ic.Platform.Name() != nonetypes.Name {
|
if ic.Platform.Name() != baremetaltypes.Name && ic.Platform.Name() != externaltypes.Name && ic.Platform.Name() != nonetypes.Name {
|
||||||
return fmt.Errorf("only BareMetal and None platforms are supported for Arbiter deployments")
|
return fmt.Errorf("only BareMetal, External, and None platforms are supported for Arbiter deployments")
|
||||||
}
|
}
|
||||||
|
|
||||||
pool := *ic.Arbiter
|
pool := *ic.Arbiter
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/openshift/installer/pkg/types"
|
"github.com/openshift/installer/pkg/types"
|
||||||
awstypes "github.com/openshift/installer/pkg/types/aws"
|
awstypes "github.com/openshift/installer/pkg/types/aws"
|
||||||
"github.com/openshift/installer/pkg/types/baremetal"
|
"github.com/openshift/installer/pkg/types/baremetal"
|
||||||
|
"github.com/openshift/installer/pkg/types/external"
|
||||||
"github.com/openshift/installer/pkg/types/none"
|
"github.com/openshift/installer/pkg/types/none"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -220,51 +221,66 @@ func TestArbiterInstallOnlyForBaremetal(t *testing.T) {
|
|||||||
arbiter := &Arbiter{}
|
arbiter := &Arbiter{}
|
||||||
err := arbiter.Generate(context.Background(), parents)
|
err := arbiter.Generate(context.Background(), parents)
|
||||||
assert.NotNil(t, err, "expected arbiter generate to fail for non baremetal platforms")
|
assert.NotNil(t, err, "expected arbiter generate to fail for non baremetal platforms")
|
||||||
assert.Contains(t, err.Error(), "only BareMetal and None platforms are supported for Arbiter deployments")
|
assert.Contains(t, err.Error(), "only BareMetal, External, and None platforms are supported for Arbiter deployments")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArbiterInstallNonePlatform(t *testing.T) {
|
func TestArbiterInstallNoneExternalPlatforms(t *testing.T) {
|
||||||
parents := asset.Parents{}
|
cases := []struct {
|
||||||
installConfig := installconfig.MakeAsset(
|
name string
|
||||||
&types.InstallConfig{
|
platform types.Platform
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
}{
|
||||||
Name: "test-cluster",
|
{
|
||||||
},
|
name: "None platform",
|
||||||
SSHKey: "ssh-rsa: dummy-key",
|
platform: types.Platform{None: &none.Platform{}},
|
||||||
BaseDomain: "test-domain",
|
},
|
||||||
Platform: types.Platform{
|
{
|
||||||
None: &none.Platform{},
|
name: "External platform",
|
||||||
},
|
platform: types.Platform{External: &external.Platform{}},
|
||||||
Arbiter: &types.MachinePool{
|
},
|
||||||
Hyperthreading: types.HyperthreadingDisabled,
|
}
|
||||||
Replicas: ptr.To(int64(1)),
|
for _, tc := range cases {
|
||||||
},
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
})
|
parents := asset.Parents{}
|
||||||
|
installConfig := installconfig.MakeAsset(
|
||||||
|
&types.InstallConfig{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "test-cluster",
|
||||||
|
},
|
||||||
|
SSHKey: "ssh-rsa: dummy-key",
|
||||||
|
BaseDomain: "test-domain",
|
||||||
|
Platform: tc.platform,
|
||||||
|
Arbiter: &types.MachinePool{
|
||||||
|
Hyperthreading: types.HyperthreadingDisabled,
|
||||||
|
Replicas: ptr.To(int64(1)),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
parents.Add(
|
parents.Add(
|
||||||
&installconfig.ClusterID{
|
&installconfig.ClusterID{
|
||||||
UUID: "test-uuid",
|
UUID: "test-uuid",
|
||||||
InfraID: "test-infra-id",
|
InfraID: "test-infra-id",
|
||||||
},
|
},
|
||||||
installConfig,
|
installConfig,
|
||||||
rhcos.MakeAsset("test-image"),
|
rhcos.MakeAsset("test-image"),
|
||||||
(*rhcos.Release)(ptr.To("412.86.202208101040-0")),
|
(*rhcos.Release)(ptr.To("412.86.202208101040-0")),
|
||||||
&machine.Arbiter{
|
&machine.Arbiter{
|
||||||
File: &asset.File{
|
File: &asset.File{
|
||||||
Filename: "arbiter-ignition",
|
Filename: "arbiter-ignition",
|
||||||
Data: []byte("test-ignition"),
|
Data: []byte("test-ignition"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
arbiter := &Arbiter{}
|
arbiter := &Arbiter{}
|
||||||
err := arbiter.Generate(context.Background(), parents)
|
err := arbiter.Generate(context.Background(), parents)
|
||||||
assert.Nil(t, err, "expected arbiter generate to succeed for None platform")
|
assert.Nil(t, err, "expected arbiter generate to succeed for %s", tc.name)
|
||||||
// For None platform, no Machine API objects or BareMetalHost CRs should be generated
|
// For non-baremetal platforms, no Machine API objects or BareMetalHost CRs should be generated
|
||||||
assert.Equal(t, 0, len(arbiter.MachineFiles), "expected no machine files for None platform")
|
assert.Equal(t, 0, len(arbiter.MachineFiles), "expected no machine files for %s", tc.name)
|
||||||
assert.Equal(t, 0, len(arbiter.HostFiles), "expected no host files for None platform")
|
assert.Equal(t, 0, len(arbiter.HostFiles), "expected no host files for %s", tc.name)
|
||||||
assert.Equal(t, 0, len(arbiter.SecretFiles), "expected no secret files for None platform")
|
assert.Equal(t, 0, len(arbiter.SecretFiles), "expected no secret files for %s", tc.name)
|
||||||
// MachineConfigs should still be generated (hyperthreading disabled + SSH key)
|
// MachineConfigs should still be generated (hyperthreading disabled + SSH key)
|
||||||
assert.Greater(t, len(arbiter.MachineConfigFiles), 0, "expected machine config files for None platform")
|
assert.Greater(t, len(arbiter.MachineConfigFiles), 0, "expected machine config files for %s", tc.name)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArbiterIsNotModified(t *testing.T) {
|
func TestArbiterIsNotModified(t *testing.T) {
|
||||||
|
|||||||
@@ -779,8 +779,8 @@ func validateControlPlane(installConfig *types.InstallConfig, fldPath *field.Pat
|
|||||||
|
|
||||||
func validateArbiter(platform *types.Platform, arbiterPool, masterPool *types.MachinePool, fldPath *field.Path) field.ErrorList {
|
func validateArbiter(platform *types.Platform, arbiterPool, masterPool *types.MachinePool, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
if platform != nil && platform.BareMetal == nil && platform.None == nil {
|
if platform != nil && platform.BareMetal == nil && platform.External == nil && platform.None == nil {
|
||||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("platform"), platform.Name(), []string{baremetal.Name, none.Name}))
|
allErrs = append(allErrs, field.NotSupported(fldPath.Child("platform"), platform.Name(), []string{baremetal.Name, external.Name, none.Name}))
|
||||||
}
|
}
|
||||||
if arbiterPool.Name != types.MachinePoolArbiterRoleName {
|
if arbiterPool.Name != types.MachinePoolArbiterRoleName {
|
||||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("name"), arbiterPool.Name, []string{types.MachinePoolArbiterRoleName}))
|
allErrs = append(allErrs, field.NotSupported(fldPath.Child("name"), arbiterPool.Name, []string{types.MachinePoolArbiterRoleName}))
|
||||||
|
|||||||
@@ -3232,6 +3232,20 @@ func TestValidateArbiter(t *testing.T) {
|
|||||||
name: "valid_platform_baremetal",
|
name: "valid_platform_baremetal",
|
||||||
expected: "",
|
expected: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
config: installConfig().
|
||||||
|
PlatformExternal().
|
||||||
|
MachinePoolArbiter(
|
||||||
|
machinePool().
|
||||||
|
Name("arbiter").
|
||||||
|
Hyperthreading(types.HyperthreadingEnabled).
|
||||||
|
Architecture(types.ArchitectureAMD64)).
|
||||||
|
MachinePoolCP(machinePool()).
|
||||||
|
ArbiterReplicas(1).
|
||||||
|
CpReplicas(2).build(),
|
||||||
|
name: "valid_platform_external",
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
config: installConfig().
|
config: installConfig().
|
||||||
PlatformAWS().
|
PlatformAWS().
|
||||||
@@ -3243,7 +3257,7 @@ func TestValidateArbiter(t *testing.T) {
|
|||||||
ArbiterReplicas(1).
|
ArbiterReplicas(1).
|
||||||
CpReplicas(2).build(),
|
CpReplicas(2).build(),
|
||||||
name: "invalid_platform",
|
name: "invalid_platform",
|
||||||
expected: `supported values: "baremetal", "none"`,
|
expected: `supported values: "baremetal", "external", "none"`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
config: installConfig().
|
config: installConfig().
|
||||||
|
|||||||
Reference in New Issue
Block a user