Skip to content

Commit d8edc23

Browse files
committed
Fix fetching 'inherited' credentials in OpenStackMachine
1 parent 94ba718 commit d8edc23

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

controllers/openstackmachine_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,14 @@ func (r *OpenStackMachineReconciler) getOrCreateMachineServer(ctx context.Contex
568568
return nil, err
569569
}
570570
if apierrors.IsNotFound(err) {
571-
machineServerSpec := openStackMachineSpecToOpenStackServerSpec(&openStackMachine.Spec, openStackCluster.Spec.IdentityRef, compute.InstanceTags(&openStackMachine.Spec, openStackCluster), failureDomain, userDataRef, getManagedSecurityGroup(openStackCluster, machine), openStackCluster.Status.Network.ID)
571+
// Use credentials from the machine object by default, falling back to cluster credentials.
572+
identityRef := func() infrav1.OpenStackIdentityReference {
573+
if openStackMachine.Spec.IdentityRef != nil {
574+
return *openStackMachine.Spec.IdentityRef
575+
}
576+
return openStackCluster.Spec.IdentityRef
577+
}()
578+
machineServerSpec := openStackMachineSpecToOpenStackServerSpec(&openStackMachine.Spec, identityRef, compute.InstanceTags(&openStackMachine.Spec, openStackCluster), failureDomain, userDataRef, getManagedSecurityGroup(openStackCluster, machine), openStackCluster.Status.Network.ID)
572579
machineServer = &infrav1alpha1.OpenStackServer{
573580
ObjectMeta: metav1.ObjectMeta{
574581
Labels: map[string]string{

pkg/scope/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func (f *providerScopeFactory) NewClientScopeFromObject(ctx context.Context, ctr
5858

5959
for _, o := range objects {
6060
namespace, identityRef = o.GetIdentityRef()
61+
if namespace != nil || identityRef != nil {
62+
break
63+
}
6164
}
6265

6366
if namespace == nil || identityRef == nil {

0 commit comments

Comments
 (0)