From 3ab8bca2abcfd6d3f420dc5fdb53ab296629d931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Tue, 8 Oct 2024 08:51:47 +0200 Subject: [PATCH] OCPBUGS-41785: Validate MTU when controlPlanePort uses FixedIPs The minimum MTU for the IPv6 network was previously only enforced when the controlPlanePort used the Network filter. This commit change the validation to also work when using the Subnet filter from FixedIPs. This commit does two things: - populate the ControlPlanePortNetwork struct in CloudInfo even when using the Subnet filter and not the Network one. - move the validation for MTU out of the branch for Network filter from the install-config.yaml --- pkg/asset/installconfig/openstack/validation/cloudinfo.go | 8 ++++++-- pkg/asset/installconfig/openstack/validation/platform.go | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/asset/installconfig/openstack/validation/cloudinfo.go b/pkg/asset/installconfig/openstack/validation/cloudinfo.go index 526f509e55a..17099a42b5b 100644 --- a/pkg/asset/installconfig/openstack/validation/cloudinfo.go +++ b/pkg/asset/installconfig/openstack/validation/cloudinfo.go @@ -380,11 +380,15 @@ func (ci *CloudInfo) getNetwork(ctx context.Context, controlPlanePort *openstack networkName := controlPlanePort.Network.Name networkID := controlPlanePort.Network.ID if networkName == "" && networkID == "" { - return nil, nil + if len(ci.ControlPlanePortSubnets) > 0 && ci.ControlPlanePortSubnets[0].NetworkID != "" { + networkID = ci.ControlPlanePortSubnets[0].NetworkID + } else { + return nil, nil + } } opts := networks.ListOpts{} if networkID != "" { - opts.ID = controlPlanePort.Network.ID + opts.ID = networkID } if networkName != "" { opts.Name = controlPlanePort.Network.Name diff --git a/pkg/asset/installconfig/openstack/validation/platform.go b/pkg/asset/installconfig/openstack/validation/platform.go index 5ce363b2d49..73af7c51db4 100644 --- a/pkg/asset/installconfig/openstack/validation/platform.go +++ b/pkg/asset/installconfig/openstack/validation/platform.go @@ -97,9 +97,9 @@ func validateControlPlanePort(p *openstack.Platform, n *types.Networking, ci *Cl } else if ci.ControlPlanePortNetwork.ID != networkID { allErrs = append(allErrs, field.Invalid(fldPath.Child("controlPlanePort").Child("network"), networkDetail, "network must contain subnets")) } - if hasIPv6Subnet && ci.ControlPlanePortNetwork.MTU < minimumMTUv6 { - allErrs = append(allErrs, field.InternalError(fldPath.Child("controlPlanePort").Child("network"), fmt.Errorf("network should have an MTU of at least %d", minimumMTUv6))) - } + } + if hasIPv6Subnet && ci.ControlPlanePortNetwork != nil && ci.ControlPlanePortNetwork.MTU < minimumMTUv6 { + allErrs = append(allErrs, field.InternalError(fldPath.Child("controlPlanePort").Child("network"), fmt.Errorf("network should have an MTU of at least %d", minimumMTUv6))) } return allErrs }