Skip to content

Commit 304af67

Browse files
Merge pull request #8227 from 2uasimojo/HIVE-2476/osp-msets-nil-replicas
HIVE-2476: OpenStack.MachineSets(): Allow nil Replicas
2 parents ac3ac89 + eea5219 commit 304af67

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/asset/machines/openstack/machinesets.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
88
"k8s.io/apimachinery/pkg/runtime"
9+
"k8s.io/utils/ptr"
910

1011
clusterapi "github.com/openshift/api/machine/v1beta1"
1112
"github.com/openshift/installer/pkg/types"
@@ -32,16 +33,21 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
3233
}
3334
mpool := pool.Platform.OpenStack
3435

36+
// In installer CLI code paths, the replica number is set to 3 by default
37+
// when install-config does not have any Compute machine-pool, or when the
38+
// Compute machine-pool does not have the `replicas` property.
39+
// However, external consumers of this func may not be so kind...
40+
if pool.Replicas == nil {
41+
pool.Replicas = ptr.To[int64](0)
42+
}
43+
3544
failureDomains := failureDomainsFromSpec(*mpool)
3645
numberOfFailureDomains := int64(len(failureDomains))
3746

3847
machinesets := make([]*clusterapi.MachineSet, len(failureDomains))
3948
for idx := range machinesets {
4049
var replicaNumber int32
4150
{
42-
// The replica number is set to 3 by default when install-config does not have
43-
// any Compute machine-pool, or when the Compute machine-pool does not have the
44-
// `replicas` property. As a consequence, pool.Replicas is never nil
4551
replicas := *pool.Replicas / numberOfFailureDomains
4652
if int64(idx) < *pool.Replicas%numberOfFailureDomains {
4753
replicas++

0 commit comments

Comments
 (0)