Skip to content

Commit 7142cf9

Browse files
committed
capi gcp: don't set target pools on machines
CAPG installs will only use backend services--no target pools, so we need to remove target pools from the machine and control plane machineset manifests, so the machine-api operator doesn't throw an error looking for a target pool that doesn't exist.
1 parent de247d1 commit 7142cf9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/asset/machines/master.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,26 @@ func (m *Master) Generate(dependencies asset.Parents) error {
265265
if err != nil {
266266
return err
267267
}
268+
269+
// CAPG-based installs will use only backend services--no target pools,
270+
// so we don't want to include target pools in the control plane machineset.
271+
// TODO(padillon): once this feature gate is the default and we are
272+
// no longer using Terraform, we can update ConfigMasters not to populate this.
273+
if ic.EnabledFeatureGates().Enabled(configv1.FeatureGateClusterAPIInstall) {
274+
for _, machine := range machines {
275+
providerSpec, ok := machine.Spec.ProviderSpec.Value.Object.(*machinev1beta1.GCPMachineProviderSpec)
276+
if !ok {
277+
return errors.New("unable to convert ProviderSpec to GCPMachineProviderSpec")
278+
}
279+
providerSpec.TargetPools = nil
280+
}
281+
cpms := controlPlaneMachineSet.Spec.Template.OpenShiftMachineV1Beta1Machine.Spec.ProviderSpec.Value.Object
282+
providerSpec, ok := cpms.(*machinev1beta1.GCPMachineProviderSpec)
283+
if !ok {
284+
return errors.New("Unable to set target pools to control plane machine set")
285+
}
286+
providerSpec.TargetPools = nil
287+
}
268288
case ibmcloudtypes.Name:
269289
subnets := map[string]string{}
270290
if len(ic.Platform.IBMCloud.ControlPlaneSubnets) > 0 {

0 commit comments

Comments
 (0)