Skip to content

FIX: Return error on Vault failure paths to prevent VSS from dropping off work queue - #1323

Merged
tejashwiniingalagi merged 7 commits into
mainfrom
VAULT-46124
Aug 26, 2026
Merged

FIX: Return error on Vault failure paths to prevent VSS from dropping off work queue#1323
tejashwiniingalagi merged 7 commits into
mainfrom
VAULT-46124

Conversation

@tejashwiniingalagi

@tejashwiniingalagi tejashwiniingalagi commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description:

Problem
After a Vault HA event (leader re-election, pod restart), VSO emits transient errors like:

"local node not active but active cluster node not found"

This is expected and self-resolving — once the new leader is established, Vault recovers. However, VSO permanently stopped reconciling the affected VaultStaticSecret resources. Days later, secrets were stale with zero controller log entries since the failure. Restarting the VSO pod alone did not recover them; the only workaround was a manual spec-touch to force a re-enqueue.

Root Cause
Two error return paths in VaultStaticSecretReconciler.Reconcile returned nil error alongside RequeueAfter:

// Before — both error paths
return ctrl.Result{RequeueAfter: horizon}, nil

controller-runtime treats a nil error + RequeueAfter as a one-shot delayed retry. Once that timer fires and Vault has not yet recovered, no further retries are scheduled — the resource is silently dropped from the work queue.

A secondary issue: when hmacSecretData=true and the Vault read succeeds but the secret data is unchanged (doSync=false), the SecretSynced condition was never updated — leaving it permanently False even after full recovery.

Fix

  1. Return the non-nil error on both Vault error paths (ClientFactory.Get and c.Read):

// After
return ctrl.Result{RequeueAfter: horizon}, err

Returning a non-nil error alongside RequeueAfter tells controller-runtime to place the resource back into the rate-limiter queue. It will keep retrying with exponential backoff via BackOffRegistry (5s → 60s plateau) indefinitely until Vault recovers — no spec-touch required.

  1. Write SecretSynced=True in the doSync=false branch:

When HMAC comparison shows the secret data is unchanged, the reconciler previously wrote no condition at all — leaving a stale SecretSynced=False from the prior failure. Now both the sync and no-sync paths always write the condition, accurately reflecting the healthy post-recovery state.

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

Screenshot 2026-08-04 at 8 59 22 AM

@tejashwiniingalagi
tejashwiniingalagi requested review from a team as code owners July 31, 2026 05:57
Comment thread controllers/vaultstaticsecret_controller.go
Comment thread controllers/vaultstaticsecret_controller_test.go Outdated
Comment 1 (siyer-corp): Drop the new ReasonSecretUpToDate constant and the
newUpToDateCondition helper. Instead, reuse Reason=Synced with
ConditionTrue in the doSync=false branch. This avoids a breaking change
for scripts, alerting rules, and Argo CD health checks that match on the
existing reason value.

Comment 2 (siyer-corp): Refactor vaultstaticsecret_controller_test.go to
follow the conventions used by vaultdynamicsecret_controller_test.go:
- Add an err field to the shared reconcileTestClientFactory (defined in
  vaultdynamicsecret_controller_test.go) instead of introducing a new
  errClientFactory type
- Use reconcileTestVaultClient with MockRecordingVaultClient{CheckPaths:true}
  instead of a separate errReadVaultClient/okReadVaultClient type
- Construct the reconciler inline in each subtest rather than via helper
  functions, so setup is immediately visible
- Collapse the four separate test functions into a single table-driven
  TestVaultStaticSecretReconciler_Reconcile
@siyer-corp

Copy link
Copy Markdown
Collaborator

Can we update the title of the PR with the actual fix being made?

@tejashwiniingalagi tejashwiniingalagi changed the title Fix for VSO Stops Reconciling for VSS After a Transient Vault HA Event Return error on Vault failure paths to prevent VSS from dropping off work queue Aug 26, 2026
@tejashwiniingalagi tejashwiniingalagi changed the title Return error on Vault failure paths to prevent VSS from dropping off work queue FIX: Return error on Vault failure paths to prevent VSS from dropping off work queue Aug 26, 2026

@siyer-corp siyer-corp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tejashwiniingalagi
tejashwiniingalagi merged commit 65eede9 into main Aug 26, 2026
51 checks passed
@tejashwiniingalagi
tejashwiniingalagi deleted the VAULT-46124 branch August 26, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants