Skip to content

Commit

Permalink
Add check if VIPs are defined to determine if UPI
Browse files Browse the repository at this point in the history
In previous versions of the installer we didn't
check for network or connect to vCenter to
get the port group details. This PR checks
if vips are defined our only ok way to determine
if UPI vs. IPI. If there are no VIPs do
not run network gathering functions.
  • Loading branch information
jcpowermac committed Jan 15, 2025
1 parent cbcd65f commit 4011bff
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
37 changes: 27 additions & 10 deletions pkg/asset/machines/clusterapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,21 @@ func (c *ClusterAPI) Generate(ctx context.Context, dependencies asset.Parents) e
PreferGo: true,
}

/* We don't have a good way to determine if an install is UPI or IPI
Previously we were able to just say if there are no VIPs defined its UPI.
It isn't documented _but_ you can set VIPs in a UPI scenario and the assisted installer
exploits this. For our customers that are using UPI though there might be scenarios
where the network is unavailable (probably related to NSX-T). To work around this issue
as port group name is not required we are going to skip any network gathering functions in capi
manifest creation.
*/

// if isVipDefined is true then this is most likely IPI perform network checks
isVipDefined := false
if len(platform.APIVIPs) >= 1 || len(platform.IngressVIPs) >= 1 {
isVipDefined = true
}

for _, v := range platform.VCenters {
// Defense against potential issues with assisted installer
// If the installer is unable to resolve vCenter there is a good possibility
Expand All @@ -372,17 +387,19 @@ func (c *ClusterAPI) Generate(ctx context.Context, dependencies asset.Parents) e
ctx, cancel = context.WithTimeout(ctx, 60*time.Second)
defer cancel()

err = installConfig.VSphere.Networks(ctx, v, platform.FailureDomains)
if err != nil {
// If we are receiving an error as a Soap Fault this is caused by
// incorrect credentials and in the scenario of assisted installer
// the credentials are never valid. Since vCenter hostname is
// incorrect as well we shouldn't get this far.
if soap.IsSoapFault(err) {
logrus.Warn("authentication failure to vCenter, Cluster API machine manifests not created, cluster may not install")
return nil
if isVipDefined {
err = installConfig.VSphere.Networks(ctx, v, platform.FailureDomains)
if err != nil {
// If we are receiving an error as a Soap Fault this is caused by
// incorrect credentials and in the scenario of assisted installer
// the credentials are never valid. Since vCenter hostname is
// incorrect as well we shouldn't get this far.
if soap.IsSoapFault(err) {
logrus.Warn("authentication failure to vCenter, Cluster API machine manifests not created, cluster may not install")
return nil
}
return err
}
return err
}
}

Expand Down
24 changes: 21 additions & 3 deletions pkg/asset/machines/vsphere/capimachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ func GenerateMachines(ctx context.Context, clusterID string, config *types.Insta
result := make([]*asset.RuntimeFile, 0, len(machines))
staticIP := false

/* We don't have a good way to determine if an install is UPI or IPI
Previously we were able to just say if there are no VIPs defined its UPI.
It isn't documented _but_ you can set VIPs in a UPI scenario and the assisted installer
exploits this. For our customers that are using UPI though there might be scenarios
where the network is unavailable (probably related to NSX-T). To work around this issue
as port group name is not required we are going to skip any network gathering functions in capi
manifest creation.
*/

// if isVipDefined is true then this is most likely IPI perform network checks
isVipDefined := false
if len(config.VSphere.APIVIPs) >= 1 || len(config.VSphere.IngressVIPs) >= 1 {
isVipDefined = true
}

for mIndex, machine := range machines {
providerSpec, ok := machine.Spec.ProviderSpec.Value.Object.(*machinev1.VSphereMachineProviderSpec)
if !ok {
Expand All @@ -99,9 +114,12 @@ func GenerateMachines(ctx context.Context, clusterID string, config *types.Insta

capvNetworkDevices := []capv.NetworkDeviceSpec{}
for _, networkDevice := range providerSpec.Network.Devices {
networkName, err := getNetworkInventoryPath(vcenterContext, networkDevice.NetworkName, providerSpec)
if err != nil {
return nil, fmt.Errorf("unable to get network inventory path: %w", err)
networkName := ""
if isVipDefined {
networkName, err = getNetworkInventoryPath(vcenterContext, networkDevice.NetworkName, providerSpec)
if err != nil {
return nil, fmt.Errorf("unable to get network inventory path: %w", err)
}
}
deviceSpec := capv.NetworkDeviceSpec{
NetworkName: networkName,
Expand Down

0 comments on commit 4011bff

Please sign in to comment.