Skip to content

Commit 1273434

Browse files
authored
add events for HVS client failures (#960)
* add events for HVS client failures * change err name * fix naming
1 parent b0b381e commit 1273434

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

consts/reasons.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ const (
2121
ReasonStatusUpdateError = "StatusUpdateError"
2222
ReasonUnrecoverable = "Unrecoverable"
2323
ReasonVaultClientConfigError = "VaultClientConfigError"
24+
ReasonHVSClientConfigError = "HVSClientConfigError"
2425
ReasonVaultClientError = "VaultClientError"
2526
ReasonVaultStaticSecret = "VaultStaticSecretError"
27+
ReasonHVSSecret = "HVSSecretError"
2628
ReasonSecretDataDrift = "SecretDataDrift"
2729
ReasonInexistentDestination = "InexistentDestination"
2830
ReasonResourceUpdated = "ResourceUpdated"

controllers/hcpvaultsecretsapp_controller.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (r *HCPVaultSecretsAppReconciler) Reconcile(ctx context.Context, req ctrl.R
128128
d, err := parseDurationString(o.Spec.RefreshAfter, ".spec.refreshAfter", r.MinRefreshAfter)
129129
if err != nil {
130130
logger.Error(err, "Field validation failed")
131-
r.Recorder.Eventf(o, corev1.EventTypeWarning, consts.ReasonVaultStaticSecret,
131+
r.Recorder.Eventf(o, corev1.EventTypeWarning, consts.ReasonHVSSecret,
132132
"Field validation failed, err=%s", err)
133133
return ctrl.Result{}, err
134134
}
@@ -147,6 +147,8 @@ func (r *HCPVaultSecretsAppReconciler) Reconcile(ctx context.Context, req ctrl.R
147147
c, err := r.hvsClient(ctx, o)
148148
if err != nil {
149149
logger.Error(err, "Get HCP Vault Secrets Client")
150+
r.Recorder.Eventf(o, corev1.EventTypeWarning, consts.ReasonHVSClientConfigError,
151+
"Failed to instantiate HVS client: %s", err)
150152
return ctrl.Result{
151153
RequeueAfter: computeHorizonWithJitter(requeueDurationOnError),
152154
}, nil
@@ -164,6 +166,8 @@ func (r *HCPVaultSecretsAppReconciler) Reconcile(ctx context.Context, req ctrl.R
164166
resp, err := fetchOpenSecretsPaginated(ctx, c, params, nil)
165167
if err != nil {
166168
logger.Error(err, "Get App Secrets", "appName", o.Spec.AppName)
169+
r.Recorder.Eventf(o, corev1.EventTypeWarning, consts.ReasonHVSSecret,
170+
"Failed to get HVS App secrets: %s", err)
167171
entry, _ := r.BackOffRegistry.Get(req.NamespacedName)
168172
return ctrl.Result{
169173
RequeueAfter: entry.NextBackOff(),
@@ -185,6 +189,8 @@ func (r *HCPVaultSecretsAppReconciler) Reconcile(ctx context.Context, req ctrl.R
185189
dynamicSecrets, err := getHVSDynamicSecrets(ctx, c, o.Spec.AppName, renewPercent, shadowSecrets)
186190
if err != nil {
187191
logger.Error(err, "Get Dynamic Secrets", "appName", o.Spec.AppName)
192+
r.Recorder.Eventf(o, corev1.EventTypeWarning, consts.ReasonHVSSecret,
193+
"Failed to get HVS dynamic secrets: %s", err)
188194
entry, _ := r.BackOffRegistry.Get(req.NamespacedName)
189195
return ctrl.Result{
190196
RequeueAfter: entry.NextBackOff(),

0 commit comments

Comments
 (0)