Skip to content

Add application credential finalizer management#356

Merged
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:mainfrom
Deydra71:appcred-finalizer
Jun 2, 2026
Merged

Add application credential finalizer management#356
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:mainfrom
Deydra71:appcred-finalizer

Conversation

@Deydra71
Copy link
Copy Markdown
Contributor

@Deydra71 Deydra71 commented Apr 1, 2026

Jira: OSPRH-27509

Application Credential dev-doc: https://github.com/openstack-k8s-operators/dev-docs/blob/main/application_credentials.md

  • Tracks the active AC secret name in Status.ApplicationCredentialSecret
  • Add openstack.org/barbican-ac-consumer finalizer to the AC secret after service config is rendered
  • On AC rotation, move the finalizer from the old secret to the new one
  • On CR deletion, remove the consumer finalizer from the AC secret before cleaning up the CR

This ensures that the keystone-operator cannot revoke a rotated AC secret while Barbican is still consuming it.

2026-04-28T11:47:49Z	INFO	Controllers.Barbican	Added consumer finalizer	{"controller": "barbican", "controllerGroup": "barbican.openstack.org", "controllerKind": "Barbican", "Barbican": {"name":"barbican","namespace":"openstack"}, "namespace": "openstack", "name": "barbican", "reconcileID": "f36c0bd9-d99c-4c90-8337-7e5017c93a55", "object": "ac-barbican-37683-secret", "finalizer": "openstack.org/barbican-ac-consumer"}
2026-04-28T11:47:49Z	INFO	Controllers.Barbican	Removed consumer finalizer	{"controller": "barbican", "controllerGroup": "barbican.openstack.org", "controllerKind": "Barbican", "Barbican": {"name":"barbican","namespace":"openstack"}, "namespace": "openstack", "name": "barbican", "reconcileID": "f36c0bd9-d99c-4c90-8337-7e5017c93a55", "object": "ac-barbican-d6d05-secret", "finalizer": "openstack.org/barbican-ac-consumer"}

Depends-On: openstack-k8s-operators/keystone-operator#685

Assisted-by: Claude Opus 4.6 noreply@anthropic.com

@softwarefactory-project-zuul
Copy link
Copy Markdown

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/barbican-operator for 356,4d15dc1e663ccd9e65873abe3307f575303f8b8d

secret := &corev1.Secret{}
key := types.NamespacedName{Name: newSecretName, Namespace: instance.Namespace}
if err := h.GetClient().Get(ctx, key, secret); err != nil {
return fmt.Errorf("failed to get new AC secret %s: %w", newSecretName, err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This wraps every error the same way, including NotFound. In practice, if the openstack-operator points Spec.Auth.ApplicationCredentialSecret to a new secret before the keystone-operator has actually created it, you'll get a stream of errors in the logs for something that's perfectly normal and resolves on its own.

What about treating NotFound as a softer case?

if k8s_errors.IsNotFound(err) {
    Log.Info("AC secret not yet available, will retry", "secret", newSecretName)
    return nil
}
return fmt.Errorf("failed to get new AC secret %s: %w", newSecretName, err)

That way the logs stay clean during the normal window where keystone hasn't caught up yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to think about a scenario when this situation would actually happen...

In keystone-operator - k8s Secret is created first, then Status.SecretName is set, then the AC CR is marked Ready all in the same reconcile + deferred status.

openstack-operator reads the secretn ame from Status.SecretName only after AC is marked as Ready, then it is written to the service CR https://github.com/openstack-k8s-operators/openstack-operator/blob/main/internal/openstack/barbican.go#L107 from where the service reads it. openstack-operator never propagates a secret name that doesn't already exist, because it gates on acCR.IsReady()

g.Expect(b.Status.ApplicationCredentialSecret).To(Equal(newACSecretName))
}, timeout, interval).Should(Succeed())
})
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice set of tests here - covers the add, the status tracking, and the rotation move. One thing I'm missing though: what happens when the Barbican CR itself gets deleted? The reconcileDelete logic removes the consumer finalizer from the AC secret, but there's no test exercising that path.

Something along the lines of:

It("should remove the consumer finalizer from AC secret on Barbican CR deletion", func() {
    // Wait for the consumer finalizer to appear on the AC secret
    // ...
    // Delete the Barbican CR
    // ...
    // Verify the AC secret no longer carries the barbican-ac-consumer finalizer
    // ...
})

Would be good to have that covered so regressions don't sneak in.

Copy link
Copy Markdown
Contributor

@mauricioharley mauricioharley left a comment

Choose a reason for hiding this comment

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

Please check the inline comments.

@Deydra71 Deydra71 force-pushed the appcred-finalizer branch 2 times, most recently from 1c93fae to 0f410be Compare April 8, 2026 06:41
@softwarefactory-project-zuul
Copy link
Copy Markdown

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/barbican-operator for 356,0f410be1cf2a4e1dd51b36516b2b5e76498bd208

@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/1bbbb520d40b4187b469ebbbbf9135a7

openstack-k8s-operators-content-provider FAILURE in 17m 48s
⚠️ barbican-operator-kuttl SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)
⚠️ barbican-operator-tempest SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)

@centosinfra-prod-github-app
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/05ba9254b8874e49a720e88168f9b466

openstack-k8s-operators-content-provider FAILURE in 3m 54s
⚠️ barbican-operator-kuttl SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)
⚠️ barbican-operator-tempest SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)

@Deydra71
Copy link
Copy Markdown
Contributor Author

recheck

Comment thread internal/controller/barbican_controller.go Outdated
Comment thread test/functional/barbican_controller_test.go Outdated
Comment thread go.mod Outdated
Copy link
Copy Markdown
Contributor

@vakwetu vakwetu left a comment

Choose a reason for hiding this comment

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

looks good in general. Just a couple points that claude picked up on.

@fmount
Copy link
Copy Markdown
Contributor

fmount commented May 27, 2026

/retest

@fmount
Copy link
Copy Markdown
Contributor

fmount commented May 27, 2026

Seems in line with all other operators that we just merged. @Deydra71 I assume we can land this one, it looks good, but let me know if we want to wait the green light from other reviewers.

Copy link
Copy Markdown
Contributor

@vakwetu vakwetu left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci Bot added the lgtm label Jun 1, 2026
@Deydra71
Copy link
Copy Markdown
Contributor Author

Deydra71 commented Jun 2, 2026

/retest

Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
@Deydra71 Deydra71 force-pushed the appcred-finalizer branch from 45b421b to bd43c90 Compare June 2, 2026 06:29
@openshift-ci openshift-ci Bot removed the lgtm label Jun 2, 2026
@Deydra71
Copy link
Copy Markdown
Contributor Author

Deydra71 commented Jun 2, 2026

Had to rebase

Copy link
Copy Markdown
Contributor

@fmount fmount left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Deydra71, fmount, vakwetu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mauricioharley mauricioharley dismissed their stale review June 2, 2026 10:59

Author asked me to dismiss the review.

@openshift-merge-bot openshift-merge-bot Bot merged commit 199a63d into openstack-k8s-operators:main Jun 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants