Skip to content

Commit

Permalink
Merge pull request #9058 from tsorya/update-assisted_for_ibio
Browse files Browse the repository at this point in the history
MGMT-18292: in order to be able to import openshift installer we need to update assisted service as it requires new hive
  • Loading branch information
openshift-merge-bot[bot] authored Oct 8, 2024
2 parents 9bb1e65 + 9e41924 commit 7534652
Show file tree
Hide file tree
Showing 178 changed files with 19,362 additions and 437 deletions.
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ require (
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20220408122422-7a548effc26e
github.com/openshift/cluster-api-provider-libvirt v0.2.1-0.20230308152226-83c0473d4429
github.com/openshift/cluster-api-provider-ovirt v0.1.1-0.20220323121149-e3f2850dd519
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a
github.com/openshift/hive/apis v0.0.0-20231220215202-ad99b9e52d27
github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b
github.com/openshift/machine-api-provider-gcp v0.0.1-0.20231014045125-6096cc86f3ba
github.com/openshift/machine-api-provider-ibmcloud v0.0.0-20231207164151-6b0b8ea7b16d
Expand Down Expand Up @@ -216,6 +216,7 @@ require (
github.com/kr/fs v0.1.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down Expand Up @@ -243,7 +244,8 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/openshift/assisted-service v1.0.10-0.20230830164851-6573b5d7021d // indirect
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 // indirect
github.com/openshift/machine-api-operator v0.2.1-0.20240930121047-57b7917e6140 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -258,6 +260,7 @@ require (
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/thoas/go-funk v0.9.3 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
Expand Down Expand Up @@ -311,11 +314,11 @@ replace (

replace sigs.k8s.io/cluster-api-provider-ibmcloud => sigs.k8s.io/cluster-api-provider-ibmcloud v0.9.0-alpha.0.0.20240913094112-c6bcd313bce0

replace github.com/openshift/assisted-service/api => github.com/openshift/assisted-service/api v0.0.0-20230831114549-1922eda29cf8
replace github.com/openshift/assisted-service/api => github.com/openshift/assisted-service/api v0.0.0-20241001055825-63e8b0d3ad63

replace github.com/openshift/assisted-service/client => github.com/openshift/assisted-service/client v0.0.0-20230831114549-1922eda29cf8
replace github.com/openshift/assisted-service/client => github.com/openshift/assisted-service/client v0.0.0-20241001055825-63e8b0d3ad63

replace github.com/openshift/assisted-service/models => github.com/openshift/assisted-service/models v0.0.0-20230831114549-1922eda29cf8
replace github.com/openshift/assisted-service/models => github.com/openshift/assisted-service/models v0.0.0-20241001055825-63e8b0d3ad63

// https://issues.redhat.com/browse/OCPBUGS-8119
// https://issues.redhat.com/browse/OCPBUGS-27507
Expand Down
26 changes: 16 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ github.com/lestrrat-go/httpcc v1.0.0/go.mod h1:tGS/u00Vh5N6FHNkExqGGNId8e0Big+++
github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc=
github.com/lestrrat-go/jwx v1.2.20/go.mod h1:tLE1XszaFgd7zaS5wHe4NxA+XVhu7xgdRvDpNyi3kNM=
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
Expand Down Expand Up @@ -768,12 +770,14 @@ github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f h1:ya1OmyZm3LIIxI3U9
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/openshift/assisted-image-service v0.0.0-20240607085136-02df2e56dde6 h1:U6ve+dnHlHhAELoxX+rdFOHVhoaYl0l9qtxwYtsO6C0=
github.com/openshift/assisted-image-service v0.0.0-20240607085136-02df2e56dde6/go.mod h1:o2H5VwQhUD8P6XsK6dRmKpCCJqVvv12KJQZBXmcCXCU=
github.com/openshift/assisted-service/api v0.0.0-20230831114549-1922eda29cf8 h1:+fZLKbycDo4JeLwPGVSAgf2XPaJGLM341l9ZfrrlxG0=
github.com/openshift/assisted-service/api v0.0.0-20230831114549-1922eda29cf8/go.mod h1:PmMnbVno5ocinfELDdKOaatvT5ucJLrau+fjHQNeCiY=
github.com/openshift/assisted-service/client v0.0.0-20230831114549-1922eda29cf8 h1:9NpCGby6O44BlWqWCbd8wcN4QwBebR8McQGrjTwhlzQ=
github.com/openshift/assisted-service/client v0.0.0-20230831114549-1922eda29cf8/go.mod h1:k0S4WqxFuMBJYyinCgHjtWoEnE6/R2OyakW60MUHPYQ=
github.com/openshift/assisted-service/models v0.0.0-20230831114549-1922eda29cf8 h1:lQO/vwmLX4kSmZitusnqdq9KbuW402DWkcmR0CJfgBI=
github.com/openshift/assisted-service/models v0.0.0-20230831114549-1922eda29cf8/go.mod h1:ImkG1jQgM72erhLaZtWqEn0g0Y8AYUOxLR/HgvlPi2Y=
github.com/openshift/assisted-service v1.0.10-0.20230830164851-6573b5d7021d h1:CKw2Y4EdaFsMoqAdr2Tq0nlYTaaXmCRdP0gOu7pN64U=
github.com/openshift/assisted-service v1.0.10-0.20230830164851-6573b5d7021d/go.mod h1:1J9kimemAdpLZVb3yLDEGmzwK0DXZ4/x6POeEog8A+4=
github.com/openshift/assisted-service/api v0.0.0-20241001055825-63e8b0d3ad63 h1:ErPj1LW5RatF+Z9vSdAiXUHMuWdJM1kBbQA6rRixo1E=
github.com/openshift/assisted-service/api v0.0.0-20241001055825-63e8b0d3ad63/go.mod h1:Jhy3+Azp3IkLDCe4ET54nQondYKa+BlHOsurSgZsD4s=
github.com/openshift/assisted-service/client v0.0.0-20241001055825-63e8b0d3ad63 h1:wYkC5wQIGjTORD3CVSNTs3dLaly9Vge/GrluayUMe+g=
github.com/openshift/assisted-service/client v0.0.0-20241001055825-63e8b0d3ad63/go.mod h1:y+GNZgra/iQDYlacSjgscim8ldrSOMtV3jQaSKC3APc=
github.com/openshift/assisted-service/models v0.0.0-20241001055825-63e8b0d3ad63 h1:192yBdPaJccBdFhBVKgt4Nirm6X5IA+yhh54CnGd/n8=
github.com/openshift/assisted-service/models v0.0.0-20241001055825-63e8b0d3ad63/go.mod h1:bx9NsPeBkhn7az/qFHo3hW8wFqFj4BmT3g1R7wR9gcw=
github.com/openshift/baremetal-operator/apis v0.0.0-20231128154154-6736c9b9c6c8 h1:f5nZJ4mB9Rf1epInmKoqDJGdoHyqZwHCiaE/OH4Yx84=
github.com/openshift/baremetal-operator/apis v0.0.0-20231128154154-6736c9b9c6c8/go.mod h1:CvKrrnAcvvtrZIc9y9WaqWmJhK0AJ9sWnh+VP4d7jcM=
github.com/openshift/baremetal-operator/pkg/hardwareutils v0.0.0-20231128154154-6736c9b9c6c8 h1:38vY9w7dXqB7tI9g1GCUnpahNDyBbp9Yylq+BQ154YE=
Expand All @@ -794,10 +798,10 @@ github.com/openshift/cluster-api-provider-ovirt v0.1.1-0.20220323121149-e3f2850d
github.com/openshift/cluster-api-provider-ovirt v0.1.1-0.20220323121149-e3f2850dd519/go.mod h1:C7unCUThP8eqT4xQfbvg3oIDn2S9TYtb0wbBoH/SR2U=
github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20240909043600-373ac49835bf h1:mfMmaD9+vZIZQq3MGXsS/AGHXekj4wIn3zc1Cs1EY8M=
github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20240909043600-373ac49835bf/go.mod h1:2fZsjZ3QSPkoMUc8QntXfeBb8AnvW+WIYwwQX8vmgvQ=
github.com/openshift/custom-resource-status v1.1.2 h1:C3DL44LEbvlbItfd8mT5jWrqPfHnSOQoQf/sypqA6A4=
github.com/openshift/custom-resource-status v1.1.2/go.mod h1:DB/Mf2oTeiAmVVX1gN+NEqweonAPY0TKUwADizj8+ZA=
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a h1:E+XPJs/aVvYsrlJzo2ED38ZTR2RTNUlFMmOaFAAdMZg=
github.com/openshift/hive/apis v0.0.0-20220222213051-def9088fdb5a/go.mod h1:E1bgquRiwfugdArdecPbpYIrAdve5kTzMaJb0+8jMXI=
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 h1:cHyxR+Y8rAMT6m1jQCaYGRwikqahI0OjjUDhFNf3ySQ=
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87/go.mod h1:DB/Mf2oTeiAmVVX1gN+NEqweonAPY0TKUwADizj8+ZA=
github.com/openshift/hive/apis v0.0.0-20231220215202-ad99b9e52d27 h1:9C86viyQl7HE9yg7Gctgx803Oq6DbrCUAberyMVcWDE=
github.com/openshift/hive/apis v0.0.0-20231220215202-ad99b9e52d27/go.mod h1:RRH8lt09SAiPECNdsbh7Gun0lkcRWi1nYKq6tDp5WxQ=
github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b h1:y2DduJug7UZqTu0QTkRPAu73nskuUbFA66fmgxVf/fI=
github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b/go.mod h1:f8QcnrooSwGa96xI4UaKbKGJZskhTCGeimXKyc4t/ZU=
github.com/openshift/machine-api-operator v0.2.1-0.20240930121047-57b7917e6140 h1:VKn644y4Ra94L8YZ3JT8ZuOZMEspZt8yoIjHeaRM3pA=
Expand Down Expand Up @@ -902,6 +906,8 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtse
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/thedevsaddam/retry v0.0.0-20200324223450-9769a859cc6d h1:U8ZUZKRBI+Xgo3QWD/alCQ2vIysyl0Efx8yCJWPdaGQ=
github.com/thedevsaddam/retry v0.0.0-20200324223450-9769a859cc6d/go.mod h1:2rz2mY+1qEXG47loLDkV+ZJHGFwmhax5rOTpP+5aR80=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
Expand Down
5 changes: 5 additions & 0 deletions pkg/asset/agent/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/openshift/installer/pkg/types/vsphere"
)

const (
// ExternalPlatformNameOci is the name of the external platform for OCP.
ExternalPlatformNameOci = "oci"
)

// SupportedInstallerPlatforms lists the supported platforms for agent installer.
func SupportedInstallerPlatforms() []string {
return []string{baremetal.Name, vsphere.Name, none.Name, external.Name}
Expand Down
4 changes: 2 additions & 2 deletions pkg/asset/agent/image/agentartifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"

"github.com/openshift/assisted-image-service/pkg/isoeditor"
"github.com/openshift/assisted-service/models"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
config "github.com/openshift/installer/pkg/asset/agent/agentconfig"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/mirror"
Expand Down Expand Up @@ -76,7 +76,7 @@ func (a *AgentArtifacts) Generate(_ context.Context, dependencies asset.Parents)
}

var agentTuiFiles []string
if agentClusterInstall.GetExternalPlatformName() != string(models.PlatformTypeOci) {
if agentClusterInstall.GetExternalPlatformName() != agent.ExternalPlatformNameOci {
agentTuiFiles, err = a.fetchAgentTuiFiles(agentManifests.ClusterImageSet.Spec.ReleaseImage, agentManifests.GetPullSecretData(), registriesConf.MirrorConfig)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/asset/agent/image/kargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/sirupsen/logrus"

hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
"github.com/openshift/assisted-service/models"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
"github.com/openshift/installer/pkg/asset/agent/joiner"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/workflow"
Expand Down Expand Up @@ -40,8 +40,8 @@ func (a *Kargs) Generate(_ context.Context, dependencies asset.Parents) error {
case workflow.AgentWorkflowTypeInstall:
a.fips = agentClusterInstall.FIPSEnabled()
// Add kernel args for external oci platform
if agentClusterInstall.GetExternalPlatformName() == string(models.PlatformTypeOci) {
logrus.Debugf("Added kernel args to enable serial console for %s %s platform", hiveext.ExternalPlatformType, string(models.PlatformTypeOci))
if agentClusterInstall.GetExternalPlatformName() == agent.ExternalPlatformNameOci {
logrus.Debugf("Added kernel args to enable serial console for %s %s platform", hiveext.ExternalPlatformType, agent.ExternalPlatformNameOci)
a.consoleArgs = " console=ttyS0"
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/asset/agent/image/kargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/openshift/assisted-service/api/hiveextension/v1beta1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
"github.com/openshift/installer/pkg/asset/agent/joiner"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/workflow"
Expand Down Expand Up @@ -54,7 +55,7 @@ func TestKargs_Generate(t *testing.T) {
},
Spec: v1beta1.AgentClusterInstallSpec{
ExternalPlatformSpec: &v1beta1.ExternalPlatformSpec{
PlatformName: "oci",
PlatformName: agent.ExternalPlatformNameOci,
},
},
},
Expand Down
7 changes: 4 additions & 3 deletions pkg/asset/agent/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"

configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/assisted-service/models"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/releaseimage"
Expand Down Expand Up @@ -133,10 +132,12 @@ func (a *OptionalInstallConfig) validatePlatformsByName(installConfig *types.Ins
var allErrs field.ErrorList

if installConfig.Platform.Name() == external.Name {
if installConfig.Platform.External.PlatformName == string(models.PlatformTypeOci) &&
if installConfig.Platform.External.PlatformName == ExternalPlatformNameOci &&
installConfig.Platform.External.CloudControllerManager != external.CloudControllerManagerTypeExternal {
fieldPath := field.NewPath("Platform", "External", "CloudControllerManager")
allErrs = append(allErrs, field.Invalid(fieldPath, installConfig.Platform.External.CloudControllerManager, fmt.Sprintf("When using external %s platform, %s must be set to %s", string(models.PlatformTypeOci), fieldPath, external.CloudControllerManagerTypeExternal)))
allErrs = append(allErrs, field.Invalid(fieldPath, installConfig.Platform.External.CloudControllerManager,
fmt.Sprintf("When using external %s platform, %s must be set to %s",
ExternalPlatformNameOci, fieldPath, external.CloudControllerManagerTypeExternal)))
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/asset/agent/manifests/agentclusterinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

configv1 "github.com/openshift/api/config/v1"
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
"github.com/openshift/assisted-service/models"
hivev1 "github.com/openshift/hive/apis/hive/v1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
Expand Down Expand Up @@ -104,7 +103,7 @@ func TestAgentClusterInstall_Generate(t *testing.T) {
installConfigWExternalOCIPlatform := getValidOptionalInstallConfig()
installConfigWExternalOCIPlatform.Config.Platform = types.Platform{
External: &externaltype.Platform{
PlatformName: string(models.PlatformTypeOci),
PlatformName: agent.ExternalPlatformNameOci,
CloudControllerManager: externaltype.CloudControllerManagerTypeExternal,
},
}
Expand All @@ -118,7 +117,7 @@ func TestAgentClusterInstall_Generate(t *testing.T) {
goodExternalOCIPlatformACI.Spec.Networking.UserManagedNetworking = &val
goodExternalOCIPlatformACI.Spec.PlatformType = hiveext.ExternalPlatformType
goodExternalOCIPlatformACI.Spec.ExternalPlatformSpec = &hiveext.ExternalPlatformSpec{
PlatformName: string(models.PlatformTypeOci),
PlatformName: agent.ExternalPlatformNameOci,
}
goodExternalOCIPlatformACI.SetAnnotations(map[string]string{
installConfigOverrides: `{"platform":{"external":{"platformName":"oci","cloudControllerManager":"External"}}}`,
Expand Down Expand Up @@ -405,7 +404,7 @@ spec:
IngressVIP: "192.168.111.4",
PlatformType: hiveext.ExternalPlatformType,
ExternalPlatformSpec: &hiveext.ExternalPlatformSpec{
PlatformName: string(models.PlatformTypeOci),
PlatformName: agent.ExternalPlatformNameOci,
},
ClusterDeploymentRef: corev1.LocalObjectReference{
Name: "ostest",
Expand Down
15 changes: 13 additions & 2 deletions pkg/asset/imagebased/configimage/clusterconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func (cc *ClusterConfiguration) Generate(_ context.Context, dependencies asset.P
if installConfig.Config == nil || imageBasedConfig.Config == nil {
return cc.finish()
}
if imageBasedConfig.Config.ClusterID != "" {
clusterID.UUID = imageBasedConfig.Config.ClusterID
}
if imageBasedConfig.Config.InfraID != "" {
clusterID.InfraID = imageBasedConfig.Config.InfraID
}

cc.Config = &imagebased.SeedReconfiguration{
APIVersion: imagebased.SeedReconfigurationVersion,
Expand All @@ -101,11 +107,14 @@ func (cc *ClusterConfiguration) Generate(_ context.Context, dependencies asset.P
KubeadminPasswordHash: pwdHash,
Proxy: installConfig.Config.Proxy,
PullSecret: installConfig.Config.PullSecret,
RawNMStateConfig: imageBasedConfig.Config.NetworkConfig.String(),
ReleaseRegistry: imageBasedConfig.Config.ReleaseRegistry,
SSHKey: installConfig.Config.SSHKey,
}

if imageBasedConfig.Config.NetworkConfig != nil {
cc.Config.RawNMStateConfig = imageBasedConfig.Config.NetworkConfig.String()
}

if len(imageBasedConfig.Config.AdditionalNTPSources) > 0 {
cc.Config.ChronyConfig = chronyConfWithAdditionalNTPSources(imageBasedConfig.Config.AdditionalNTPSources)
}
Expand Down Expand Up @@ -139,7 +148,9 @@ func (cc *ClusterConfiguration) Generate(_ context.Context, dependencies asset.P
}

// validation for the length of the MachineNetwork is performed in the InstallConfig
cc.Config.MachineNetwork = installConfig.Config.Networking.MachineNetwork[0].CIDR.String()
if len(installConfig.Config.Networking.MachineNetwork) > 0 {
cc.Config.MachineNetwork = installConfig.Config.Networking.MachineNetwork[0].CIDR.String()
}

clusterConfigurationData, err := json.Marshal(cc.Config)
if err != nil {
Expand Down
23 changes: 23 additions & 0 deletions pkg/asset/imagebased/configimage/clusterconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ func TestClusterConfiguration_Generate(t *testing.T) {

expectedConfig: clusterConfiguration().build().Config,
},
{
name: "valid configuration with cluster and infra ID",
dependencies: []asset.Asset{
clusterID(),
kubeadminPassword(),
lbCertKey(),
localhostCertKey(),
serviceNetworkCertKey(),
adminKubeConfigCertKey(),
ingressCertKey(),
installConfig().build(),
imageBasedConfigWithSetClusterID("some-id", "some-infra-id"),
},

expectedConfig: clusterConfigurationWithProvidedIDs("some-id", "some-infra-id").build().Config,
},
{
name: "valid configuration with proxy",
dependencies: []asset.Asset{
Expand Down Expand Up @@ -340,6 +356,13 @@ func clusterConfiguration() *ClusterConfigurationBuilder {
return ccb
}

func clusterConfigurationWithProvidedIDs(clusterID string, infraID string) *ClusterConfigurationBuilder {
ccb := clusterConfiguration()
ccb.ClusterConfiguration.Config.ClusterID = clusterID
ccb.ClusterConfiguration.Config.InfraID = infraID
return ccb
}

func clusterID() *ClusterID {
return &ClusterID{
installconfig.ClusterID{
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/imagebased/configimage/imagebased_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (i *ImageBasedConfig) validateNetworkConfig() field.ErrorList {
var allErrs field.ErrorList

// empty NetworkConfig is fine
if i.Config.NetworkConfig.String() == "" {
if i.Config.NetworkConfig == nil || i.Config.NetworkConfig.String() == "" {
return nil
}

Expand Down
Loading

0 comments on commit 7534652

Please sign in to comment.