Skip to content

Commit f07c671

Browse files
committed
VC: address related review feedback
1 parent 3d75f0c commit f07c671

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

controllers/vaultconnection_controller.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package controllers
66
import (
77
"context"
88
"errors"
9+
"fmt"
910
"time"
1011

1112
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -91,8 +92,8 @@ func (r *VaultConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
9192
newConditionNow(o, "VaultClient",
9293
consts.ReasonVaultClientConfigError,
9394
metav1.ConditionFalse,
94-
"Failed to setup Vault client, address=%s, errs=%s",
95-
o.Spec.Address, errs),
95+
"Failed to setup Vault client, address=%s, err=%s",
96+
o.Spec.Address, err),
9697
)
9798

9899
errs = errors.Join(errs, err)
@@ -115,7 +116,7 @@ func (r *VaultConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
115116
} else {
116117
o.Status.Valid = ptr.To(true)
117118
o.Status.Conditions = append(o.Status.Conditions,
118-
newConditionNow(o, "VaultPing", consts.ReasonInvalidConfiguration,
119+
newConditionNow(o, "VaultPing", consts.ReasonAccepted,
119120
metav1.ConditionTrue, "Vault ping, address=%s",
120121
o.Spec.Address),
121122
)
@@ -136,11 +137,16 @@ func (r *VaultConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
136137
errs = errors.Join(errs, err)
137138
}
138139

139-
// TODO: cleanup error reporting
140140
var horizon time.Duration
141-
if errs != nil || !*o.Status.Valid {
141+
142+
isValid := ptr.Deref(o.Status.Valid, false)
143+
if !isValid {
144+
errs = errors.Join(errs, fmt.Errorf("invalid VaultConnection %s", client.ObjectKeyFromObject(o)))
145+
}
146+
147+
if errs != nil {
142148
logger.Error(errs, "Resource validation failed")
143-
r.Recorder.Event(o, corev1.EventTypeWarning, consts.ReasonAccepted, "VaultConnection invalid")
149+
r.Recorder.Event(o, corev1.EventTypeWarning, consts.ReasonInvalidConfiguration, "VaultConnection invalid")
144150
horizon = computeHorizonWithJitter(requeueDurationOnError)
145151
o.Status.Conditions = append(o.Status.Conditions,
146152
newConditionNow(o, consts.TypeResourceValidation, consts.ReasonInvalidConfiguration,
@@ -152,8 +158,7 @@ func (r *VaultConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
152158
}
153159

154160
if err := r.updateStatus(ctx, o); err != nil {
155-
errs = errors.Join(errs, err)
156-
return ctrl.Result{}, errs
161+
return ctrl.Result{}, errors.Join(errs, err)
157162
}
158163

159164
return ctrl.Result{

0 commit comments

Comments
 (0)