Skip to content

Commit

Permalink
Fix infinite loop when initial credentials fail (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchbg authored Apr 29, 2024
1 parent 7c86f60 commit 0964549
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions internal/controller/oob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package controller
import (
"context"
"fmt"
"maps"
"os"
"regexp"
"slices"
Expand Down Expand Up @@ -657,7 +658,7 @@ func (r *OOBReconciler) processCredentials(ctx context.Context, oob *metalv1alph
})
}

if a.Ignore {
if a.Ignore && !metav1.HasAnnotation(oob.ObjectMeta, OOBIgnoreAnnotation) {
if apply == nil {
var err error
apply, err = metalv1alpha1apply.ExtractOOB(oob, OOBFieldManager)
Expand All @@ -676,18 +677,21 @@ func (r *OOBReconciler) processCredentials(ctx context.Context, oob *metalv1alph
oob.Spec.Flags = a.Flags
defaultCreds = a.DefaultCredentials

if apply == nil {
var err error
apply, err = metalv1alpha1apply.ExtractOOB(oob, OOBFieldManager)
if err != nil {
return ctx, nil, nil, fmt.Errorf("cannot extract OOB: %w", err)
if !util.NilOrEqual(oob.Spec.Protocol, &a.Protocol) ||
!maps.Equal(oob.Spec.Flags, a.Flags) {
if apply == nil {
var err error
apply, err = metalv1alpha1apply.ExtractOOB(oob, OOBFieldManager)
if err != nil {
return ctx, nil, nil, fmt.Errorf("cannot extract OOB: %w", err)
}
}
apply = apply.WithSpec(util.Ensure(apply.Spec).
WithProtocol(metalv1alpha1apply.Protocol().
WithName(oob.Spec.Protocol.Name).
WithPort(oob.Spec.Protocol.Port)).
WithFlags(oob.Spec.Flags))
}
apply = apply.WithSpec(util.Ensure(apply.Spec).
WithProtocol(metalv1alpha1apply.Protocol().
WithName(oob.Spec.Protocol.Name).
WithPort(oob.Spec.Protocol.Port)).
WithFlags(oob.Spec.Flags))
}

b, err := bmc.NewBMC(string(oob.Spec.Protocol.Name), oob.Spec.Flags, ctx.Value(ctxkOOBHost{}).(string), oob.Spec.Protocol.Port, creds, expiration)
Expand Down

0 comments on commit 0964549

Please sign in to comment.