Skip to content

Commit d181eed

Browse files
author
Joshua Reed
committed
Adress failure domain potentially set by etcdadm.
1 parent afd033b commit d181eed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

controllers/cloudstackmachine_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"reflect"
2424
"strings"
2525

26-
2726
"github.com/pkg/errors"
2827
corev1 "k8s.io/api/core/v1"
2928
"k8s.io/apimachinery/pkg/types"
@@ -136,7 +135,10 @@ func (r *CloudStackMachineReconciliationRunner) ConsiderAffinity() (ctrl.Result,
136135
func (r *CloudStackMachineReconciliationRunner) SetFailureDomainOnCSMachine() (retRes ctrl.Result, reterr error) {
137136
r.Log.Info(r.ReconciliationSubject.Spec.FailureDomainName)
138137
if r.ReconciliationSubject.Spec.FailureDomainName == "" { // Needs random FD, but not yet set.
139-
if util.IsControlPlaneMachine(r.CAPIMachine) { // Is control plane machine -- CAPI will specify.
138+
139+
if r.CAPIMachine.Spec.FailureDomain != nil &&
140+
(util.IsControlPlaneMachine(r.CAPIMachine) || // Is control plane machine -- CAPI will specify.
141+
*r.CAPIMachine.Spec.FailureDomain != "") { // Or potentially another machine controller specified.
140142
r.ReconciliationSubject.Spec.FailureDomainName = *r.CAPIMachine.Spec.FailureDomain
141143
} else { // Not a control plane machine. Place randomly.
142144
randNum := (rand.Int() % len(r.CSCluster.Spec.FailureDomains)) // #nosec G404 -- weak crypt rand doesn't matter here.

0 commit comments

Comments
 (0)