Skip to content

Commit df7cfa3

Browse files
committed
minor naming changes
1 parent c5bc4de commit df7cfa3

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

cloud/scope/machine.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ func (m *MachineScope) GetOrCreateMachine(ctx context.Context) (*core.Instance,
237237
}
238238
// the random number generated is between zero and two, whereas we need a number between one and three
239239
failureDomain = common.String(strconv.Itoa(int(randomFailureDomain.Int64()) + 1))
240-
fd := m.OCIClusterAccessor.GetFailureDomains()[*failureDomain]
241-
availabilityDomain = fd.Attributes[AvailabilityDomain]
242-
faultDomain = fd.Attributes[FaultDomain]
240+
availabilityDomain = m.OCIClusterAccessor.GetFailureDomains()[*failureDomain].Attributes[AvailabilityDomain]
241+
faultDomain = m.OCIClusterAccessor.GetFailureDomains()[*failureDomain].Attributes[FaultDomain]
243242
}
244243

245244
metadata := m.OCIMachine.Spec.Metadata
@@ -295,8 +294,8 @@ func (m *MachineScope) GetOrCreateMachine(ctx context.Context) (*core.Instance,
295294
launchDetails.PreemptibleInstanceConfig = m.getPreemptibleInstanceConfig()
296295
launchDetails.PlatformConfig = m.getPlatformConfig()
297296
launchDetails.LaunchVolumeAttachments = m.getLaunchVolumeAttachments()
298-
attempts := m.buildFaultDomainLaunchAttempts(availabilityDomain, faultDomain)
299-
return m.launchInstanceWithFaultDomainRetry(ctx, launchDetails, attempts)
297+
faultDomains := m.buildFaultDomainLaunchAttempts(availabilityDomain, faultDomain)
298+
return m.launchInstanceWithFaultDomainRetry(ctx, launchDetails, faultDomains)
300299
}
301300

302301
func (m *MachineScope) launchInstanceWithFaultDomainRetry(ctx context.Context, baseDetails core.LaunchInstanceDetails, attempts []faultDomainAttempt) (*core.Instance, error) {
@@ -336,18 +335,20 @@ func (m *MachineScope) launchInstanceWithFaultDomainRetry(ctx context.Context, b
336335
return nil, lastErr
337336
}
338337

338+
const defaultFaultDomainKey = "__no_fault_domain__"
339+
339340
func (m *MachineScope) buildFaultDomainLaunchAttempts(availabilityDomain, initialFaultDomain string) []faultDomainAttempt {
340-
attempts := []faultDomainAttempt{}
341-
seen := map[string]struct{}{}
341+
var attempts []faultDomainAttempt
342+
seen := make(map[string]bool)
342343
addAttempt := func(fd string) {
343344
key := fd
344345
if fd == "" {
345-
key = "__default__"
346+
key = defaultFaultDomainKey
346347
}
347-
if _, exists := seen[key]; exists {
348+
if seen[key] {
348349
return
349350
}
350-
seen[key] = struct{}{}
351+
seen[key] = true
351352
attempts = append(attempts, faultDomainAttempt{
352353
AvailabilityDomain: availabilityDomain,
353354
FaultDomain: fd,

0 commit comments

Comments
 (0)