Skip to content

Conversation

benashz
Copy link
Collaborator

@benashz benashz commented Apr 24, 2025

Adds support for setting the status conditions on the following types:

  • vaultstaticsecrets
  • vaultpkisecrets
  • vaultdynamicsecrets
  • hcpauths
  • hcpvaultsecretsapps

Adds support for setting the status conditions on the following types:

- vaultstaticsecrets
- vaultpkisecrets
- vaultdynamicsecrets
- hcpauths
- hcpvaultsecretsapps
@benashz benashz force-pushed the VAULT-22933/adopt-status-conditions-for-all-crds branch from 0052f71 to 3d75f0c Compare April 24, 2025 13:55
@mtparet
Copy link

mtparet commented Jun 25, 2025

Would be awesome to get it merged!

@dm3ch
Copy link

dm3ch commented Jun 27, 2025

@benashz Sorry for bothering you, but is there any reason why this PR is still a draft?

Is something is still missing or non functional or it's finished and just awaiting a merge?

@benashz benashz requested review from tvoran, digivava and Zlaticanin and removed request for tvoran July 8, 2025 22:26
@benashz benashz marked this pull request as ready for review July 30, 2025 17:37
@benashz benashz requested a review from a team as a code owner July 30, 2025 17:37
@benashz benashz requested a review from tvoran July 30, 2025 17:37
Comment on lines +54 to +55
// Conditions hold information that be used by other apps to determine the health
// the resource instance.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Conditions hold information that be used by other apps to determine the health
// the resource instance.
// Conditions hold information that be used by other apps to determine the health
// of the resource instance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also missing a "can" here -- "that can be used by other apps"

Comment on lines 288 to 289
// we key conditions on their type and reason
// e.g: type=VaultAuthGlobal reason=Available, ...
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this isn't quite true anymore? i.e. the key seems to just be Type now on line 295.

@@ -388,6 +388,7 @@ func Test_waitForStoppedCh(t *testing.T) {
}

func TestVaultAuthReconciler_updateConditions(t *testing.T) {
t.Skip("This test is not working as expected. It is failing with the following error: expected 1 conditions, got 2")
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to be addressed in this PR? I don't see updateCondtions() being tested anywhere else.

Comment on lines +117 to +121
o.Status.Conditions = append(o.Status.Conditions,
newConditionNow(o, "VaultPing", consts.ReasonInvalidConfiguration,
metav1.ConditionTrue, "Vault ping, address=%s",
o.Spec.Address),
)
Copy link
Member

Choose a reason for hiding this comment

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

Should the the reason be something besides InvalidConfiguration here? Seems like the ping was successful at this point?

@@ -108,16 +136,29 @@ func (r *VaultConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
errs = errors.Join(errs, err)
}

if err := r.updateStatus(ctx, o); err != nil {
errs = errors.Join(errs, err)
// TODO: cleanup error reporting
Copy link
Member

Choose a reason for hiding this comment

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

Can this comment be more specific about what needs cleanup and why?

Comment on lines +314 to +317
conditions = append(conditions,
newSyncCondition(o, metav1.ConditionTrue,
"Secret synced, horizon=%s", horizon),
)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this change to conditions isn't used.

r.recordEvent(o, reason, fmt.Sprintf("Secret synced, horizon=%s", horizon))
logger.Info("Successfully updated the secret", "horizon", horizon)
return ctrl.Result{
RequeueAfter: horizon,
}, nil
}

func (r *VaultPKISecretReconciler) syncSecret(ctx context.Context, o *secretsv1beta1.VaultPKISecret) (*vault.PKICertResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this function going to be used somewhere?

Comment on lines +153 to +159
if err := r.updateStatus(ctx, o, newSyncCondition(o, metav1.ConditionFalse, "Failed to sync the secret, horizon=%s, err=%s", horizon, err)); err != nil {
return ctrl.Result{}, err
}

if err := r.updateStatus(ctx, o, newSyncCondition(o, metav1.ConditionFalse, "Failed to sync the secret, horizon=%s, err=%s", horizon, err)); err != nil {
return ctrl.Result{}, err
}
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate?

Suggested change
if err := r.updateStatus(ctx, o, newSyncCondition(o, metav1.ConditionFalse, "Failed to sync the secret, horizon=%s, err=%s", horizon, err)); err != nil {
return ctrl.Result{}, err
}
if err := r.updateStatus(ctx, o, newSyncCondition(o, metav1.ConditionFalse, "Failed to sync the secret, horizon=%s, err=%s", horizon, err)); err != nil {
return ctrl.Result{}, err
}
if err := r.updateStatus(ctx, o, newSyncCondition(o, metav1.ConditionFalse, "Failed to sync the secret, horizon=%s, err=%s", horizon, err)); err != nil {
return ctrl.Result{}, err
}

for _, newCond := range updates {
// we key conditions on their type and reason
// e.g: type=VaultAuthGlobal reason=Available, ...
key := fmt.Sprintf("%s/%s", newCond.Type, newCond.Reason)
// if newCond.Reason == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was probably meant to be removed

o.Status.Conditions = append(o.Status.Conditions,
newConditionNow(o, consts.TypeResourceValidation, consts.ReasonInvalidConfiguration,
metav1.ConditionFalse, "Failed to validate resource, address=%s, errs=%s",
o.Spec.Address, errs),
Copy link
Collaborator

@digivava digivava Jul 30, 2025

Choose a reason for hiding this comment

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

Just double-checking, does this work okay if errs is nil? Since this is an || conditional, it can hit this piece of code if the status is invalid but errs is nil. Should we populate the error with something if it's the !*o.Status.Valid case?

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.

Status fields for resource health in VaultStaticSecret and VaultDynamicSecret resources
5 participants